-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from langchain_community.tools.tavily_search import TavilySearchResults | ||
from langchain_openai import ChatOpenAI | ||
from langchain_core.prompts import ChatPromptTemplate,MessagesPlaceholder | ||
from langchain.agents import create_openai_functions_agent,AgentExecutor | ||
search=TavilySearchResults() | ||
llm=ChatOpenAI(model="gpt-4o") | ||
prompt=ChatPromptTemplate.from_messages( | ||
[ | ||
("system","you are an expert in searching internet and returning output with nice formatted paragraphs"), | ||
("human","{input}"), | ||
MessagesPlaceholder(variable_name="agent_scratchpad") | ||
] | ||
) | ||
tools=[search] | ||
agent=create_openai_functions_agent(llm=llm,tools=tools,prompt=prompt) | ||
executor=AgentExecutor(agent=agent,tools=tools,verbose=True) | ||
response=executor.invoke({"input":"what is the latest news in Cricket in as per todays date 25th august , 2024"}) | ||
print(response["output"]) |
Binary file not shown.