i trying to use duckduckgo search engine
Tool list
tools = [duckduckgo_tool,makers_update]
chat_history = []
qa_system_prompt = """You are an assistant for question-answering tasks. \
Use the following pieces of retrieved context to answer the question. \
You have access to two tools: makers_update and duckduckgo_tool.\
Questions about current events, use the duckduckgo_tool tool to get information from the web. \
If somebody ask about your creator or ask about you,use makers_update tool to give the information.\
Use three sentences maximum and keep the answer concise.\
"""
qa_prompt = ChatPromptTemplate.from_messages(
[
("system", qa_system_prompt),
MessagesPlaceholder(variable_name="history"),
("human", "{input}"),
]
)
chain = qa_prompt | llm.bind_tools(tools)
from langchain_core.chat_history import (
BaseChatMessageHistory,
InMemoryChatMessageHistory,
)
from langchain_core.runnables.history import RunnableWithMessageHistory
store = {}
def get_session_history(session_id: str) -> BaseChatMessageHistory:
if session_id not in store:
store[session_id] = InMemoryChatMessageHistory()
return store[session_id]
def start_app():
while True:
question = input("You: ")
if question == "done":
return
with_message_history = RunnableWithMessageHistory(chain, get_session_history,input_messages_key="input",
history_messages_key="history",)
config = {"configurable": {"session_id": "abc"}}
# response = llm.invoke(question)
response = with_message_history.invoke({"input": question},config=config,)
print(response.content)
if name == "main":
start_app()
but whenever i ask something related to web search it is not using the tool
Top comments (0)