DEV Community

sanjay murmu
sanjay murmu

Posted on

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

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more