improve agent templates (#12528)

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
Harrison Chase 2023-10-30 18:15:13 -07:00 committed by GitHub
parent 75bb28afd8
commit f35a65124a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 9 deletions

View File

@ -56,8 +56,8 @@ These templates use OSS models.
Extract data in a structured format
- [Extraction Using OpenAI Functions](../extraction-openai-functions): Extract information from text using OpenAI Function Calling.
- [Extraction Using Anthropic Functions](../extraction-anthropic-functions): Extract information from text using a LangChain wrapper around the Anthropic endpoints intended to simulate function calling.
- [Extract BioTech Plate Data](../plate-chain): Extract plate data from messy Excel spreadsheets into a more normalized format.
- [Extract BioTech Plate Data](../plate-chain): Extract microplate data from messy Excel spreadsheets into a more normalized format.
## 🤖 Agents
- [OpenAI Functions Agent](../openai-functions-agent): Build a chatbot that can take actions. Uses OpenAI function calling and Tavily.
- [XML Agent](../xml-agent): Build a chatbot that can take actions. Uses Anthropic and You.com.
- [XML Agent](../xml-agent): Build a chatbot that can take actions. Uses Anthropic and You.com.

View File

@ -11,19 +11,24 @@ from langchain.tools.render import format_tool_to_openai_function
from langchain.tools.tavily_search import TavilySearchResults
from langchain.utilities.tavily_search import TavilySearchAPIWrapper
# Fake Tool
# Create the tool
search = TavilySearchAPIWrapper()
tavily_tool = TavilySearchResults(api_wrapper=search)
description = """"A search engine optimized for comprehensive, accurate, \
and trusted results. Useful for when you need to answer questions \
about current events or about recent information. \
Input should be a search query. \
If the user is asking about something that you don't know about, \
you should probably use this tool to see if that can provide any information."""
tavily_tool = TavilySearchResults(api_wrapper=search, description=description)
tools = [tavily_tool]
llm = ChatOpenAI(temperature=0)
assistant_system_message = """You are a helpful assistant. \
Use tools (only if necessary) to best answer the users questions."""
prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"You are very powerful assistant, but bad at calculating lengths of words.",
),
("system", assistant_system_message),
MessagesPlaceholder(variable_name="chat_history"),
("user", "{input}"),
MessagesPlaceholder(variable_name="agent_scratchpad"),

View File

@ -21,7 +21,6 @@ def _format_chat_history(chat_history: List[Tuple[str, str]]):
model = ChatAnthropic(model="claude-2")
tools = [DuckDuckGoSearchRun()]
prompt = conversational_prompt.partial(