unable to use search tool

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 quest…


This content originally appeared on DEV Community and was authored by sanjay murmu

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


This content originally appeared on DEV Community and was authored by sanjay murmu


Print Share Comment Cite Upload Translate Updates
APA

sanjay murmu | Sciencx (2024-07-31T17:37:31+00:00) unable to use search tool. Retrieved from https://www.scien.cx/2024/07/31/unable-to-use-search-tool/

MLA
" » unable to use search tool." sanjay murmu | Sciencx - Wednesday July 31, 2024, https://www.scien.cx/2024/07/31/unable-to-use-search-tool/
HARVARD
sanjay murmu | Sciencx Wednesday July 31, 2024 » unable to use search tool., viewed ,<https://www.scien.cx/2024/07/31/unable-to-use-search-tool/>
VANCOUVER
sanjay murmu | Sciencx - » unable to use search tool. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/31/unable-to-use-search-tool/
CHICAGO
" » unable to use search tool." sanjay murmu | Sciencx - Accessed . https://www.scien.cx/2024/07/31/unable-to-use-search-tool/
IEEE
" » unable to use search tool." sanjay murmu | Sciencx [Online]. Available: https://www.scien.cx/2024/07/31/unable-to-use-search-tool/. [Accessed: ]
rf:citation
» unable to use search tool | sanjay murmu | Sciencx | https://www.scien.cx/2024/07/31/unable-to-use-search-tool/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.