mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 19:47:13 +00:00
Replace You with DDG in xml agent (#12504)
You requires an email to get an API key which IMO is too much friction. Duckduck go is free and easy to install.
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
from typing import List, Tuple
|
||||
|
||||
from langchain.agents import AgentExecutor
|
||||
from langchain.agents.agent_toolkits.conversational_retrieval.tool import (
|
||||
create_retriever_tool,
|
||||
)
|
||||
from langchain.agents.format_scratchpad import format_xml
|
||||
from langchain.chat_models import ChatAnthropic
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
from langchain.retrievers.you import YouRetriever
|
||||
from langchain.schema import AIMessage, HumanMessage
|
||||
from langchain.tools import DuckDuckGoSearchRun
|
||||
from langchain.tools.render import render_text_description
|
||||
|
||||
from xml_agent.prompts import conversational_prompt, parse_output
|
||||
@@ -24,13 +21,8 @@ def _format_chat_history(chat_history: List[Tuple[str, str]]):
|
||||
|
||||
model = ChatAnthropic(model="claude-2")
|
||||
|
||||
# Fake Tool
|
||||
retriever = YouRetriever(k=5)
|
||||
retriever_tool = create_retriever_tool(
|
||||
retriever, "search", "Use this to search for current events."
|
||||
)
|
||||
|
||||
tools = [retriever_tool]
|
||||
tools = [DuckDuckGoSearchRun()]
|
||||
|
||||
prompt = conversational_prompt.partial(
|
||||
tools=render_text_description(tools),
|
||||
|
Reference in New Issue
Block a user