agent_executor.invoke({"input": "hi, i am bob"})["output"]
agent_executor.invoke({"input": "whats my name?"})["output"]
agent_executor.invoke({"input": "what are some movies showing 9/21/2023?"})["output"]
复制代码
2.3.4、对话型Agent返回答案全流程
对话型Agent返回:
> Entering new AgentExecutor chain...
Thought: Do I need to use a tool? No
Final Answer: Hi Bob, nice to meet you! How can I help you today?
> Finished chain.
> Entering new AgentExecutor chain...
Thought: Do I need to use a tool? No
Final Answer: Your name is Bob!
> Finished chain.
> Entering new AgentExecutor chain...
Thought: Do I need to use a tool? Yes
Action: Search
Action Input: Movies showing 9/21/2023
['September 2023 Movies: The Kill Room • The Creator • Expend4bles • Bottoms • PAW Patrol: The Mighty Movie • Dumb Money • A Haunting in Venice, ...',
'August 2023 welcomed some exciting stories, as were Teenage Mutant Ninja Turtles: Mutant Mayhem, the sci-fi action horror movie Meg 2: The ...',
'Domestic Box Office For September 2023 ; 7, Gran Turismo, - ; 8, Oppenheimer, - ; 9, PAW Patrol: The Mighty Movie, - ; 10, Teenage Mutant Ninja Turtles: Mutant ...',
'Movie (+ IMAX). April 7 (Friday). Paint · Chupa (Netflix) How to Blow Up a Pipeline (Theaters) Joyland (Theaters) One True Loves (Theaters) Showing Up (Theaters) ...', 'September 21, 2023 Network TV and Cable Premieres · Booked: First Day In (A&E) · Botched (E!) · The Challenge: USA (CBS) · The Dead Files (Travel ...', "“Asteroid City” isn't the only new Wes Anderson movie arriving in 2023. Up next for the beloved auteur is “The Wonderful Story of Henry Sugar,” ...", '2023 Movies ; The Amazing Maurice. January 6, 2023. The Amazing Maurice ; M3gan. January 6, 2023. M3GAN ; The Pale Blue Eye. January 6, 2023. The Pale Blue Eye.', 'January 2023 Movie Releases ; M3GAN, PG-13, Allison Williams, Kimberley Crossman ; Dog Gone (Netflix Release), PG, Rob Lowe, Kimberly Williams ...', 'September 2023: All new movies coming to theaters, from Dumb Money, The Creator and Saw X to upcoming films and releases to watch this ...', 'The Biggest Movies Coming to Theaters in September 2023 ; The Nun II. Friday, September 8 ; My Big Fat Greek Wedding 3. Friday, September 8 ; A ...']
Do I need to use a tool? No
Final Answer: It looks like there are several movies coming out in September 2023, including The Kill Room, The Creator, Expend4bles, Bottoms, PAW Patrol: The Mighty Movie, Dumb Money, A Haunting in Venice, Teenage Mutant Ninja Turtles: Mutant Mayhem, Gran Turismo, Oppenheimer, Paint, Chupa, How to Blow Up a Pipeline, Joyland, One True Loves, Showing Up, Booked: First Day In, Botched, The Challenge: USA, The Dead Files, The Wonderful Story of Henry Sugar, The Amazing Maurice, M3gan, The Pale Blue Eye, Dog Gone, My Big Fat Greek Wedding 3, and The Nun II.
> Finished chain.
'
It looks like there are several movies coming out in September 2023,
including The Kill Room, The Creator, Expend4bles, Bottoms,
PAW Patrol: The Mighty Movie, Dumb Money, A Haunting in Venice,
Teenage Mutant Ninja Turtles: Mutant Mayhem, Gran Turismo, Oppenheimer,
Paint, Chupa, How to Blow Up a Pipeline, Joyland, One True Loves, Showing Up,
Booked: First Day In, Botched, The Challenge: USA, The Dead Files,
The Wonderful Story of Henry Sugar, The Amazing Maurice, M3gan,
The Pale Blue Eye, Dog Gone, My Big Fat Greek Wedding 3, and The Nun II.
question = "Author David Chanoff has collaborated with a U.S. Navy admiral who served as the ambassador to the United Kingdom under which President?"
#智能体执行
react.run(question)
复制代码
2.4.2、文档搜索Agent返回答案全流程
> Entering new AgentExecutor chain...Thought: I need to search David Chanoff and the U.S. Navy admiral, find the ambassador to the United Kingdom, then find the President they served under.
Action: Search[David Chanoff]
Observation: David Chanoff is a noted author of non-fiction work. His work has typically involved collaborations with the principal protagonist of the work concerned. His collaborators have included; Augustus A. White, Joycelyn Elders, Đoàn Văn Toại, William J. Crowe, Ariel Sharon, Kenneth Good and Felix Zandman. He has also written about a wide range of subjects including literary history, education and foreign for The Washington Post, The New Republic and The New York Times Magazine. He has published more than twelve books.
Thought: David Chanoff has collaborated with a U.S. Navy admiral who served as the ambassador to the United Kingdom. I need to search U.S. Navy admiral and find the ambassador to the United Kingdom.
Action: Search[U.S. Navy admiral]
Observation: Admiral of the Navy was the highest-possible rank in the United States Navy, prior to the creation of fleet admiral in 1944. The rank is considered to be at least equivalent to that of a five-star admiral, with Admiral George Dewey being the only officer to be appointed to the rank.
Thought: The paragraph does not mention the ambassador to the United Kingdom. I need to search U.S. Navy admiral ambassador to the United Kingdom.
Action: Search[U.S. Navy admiral ambassador to the United Kingdom]
Observation: Could not find [U.S. Navy admiral ambassador to the United Kingdom]. Similar: ['United States Secretary of the Navy', 'List of United States Navy four-star admirals', 'Raymond A. Spruance', 'First Navy Jack', 'United Kingdom–United States relations', 'Prelude to the attack on Pearl Harbor', 'List of members of the Sons of the American Revolution', 'William J. Crowe', 'Kenneth Braithwaite', 'Distinguished Service Medal (U.S. Army)']
Thought: I can search William J. Crowe and find the ambassador to the United Kingdom.
Action: Search[William J. Crowe]
Observation: William James Crowe Jr. (January 2, 1925 – October 18, 2007) was a United States Navy admiral and diplomat who served as the 11th chairman of the Joint Chiefs of Staff under Presidents Ronald Reagan and George H. W. Bush, and as the ambassador to the United Kingdom and Chair of the Intelligence Oversight Board under President Bill Clinton.
Thought: William J. Crowe was the ambassador to the United Kingdom under President Bill Clinton, so the answer is Bill Clinton.
Action: Finish[Bill Clinton]
> Finished chain.
'
Bill Clinton
复制代码
用户问题:
作者大卫·查诺夫曾与一位美国海军上将合作,他曾在哪任总统的领导下担任驻英国大使?
智能体执行过程:
Step1:
我需要寻找大卫·查诺夫和美国海军上将,找到驻英国大使,然后找到他们所服务的总统。
Step2:
大卫·查诺夫 (David Chanoff) 是一位著名的非小说类作家。
他的作品通常涉及与相关作品的主要主角的合作。
他的合作者包括: Augustus A. White、Joycelyn Elders、
Đoàn Văn Toại、William J. Crowe、Ariel Sharon、Kenneth Good
和 Felix Zandman。 他还为《华盛顿邮报》、《新共和》和
《纽约时报杂志》撰写过有关文学史、教育和外国等广泛主题的文章。
他出版了十二本书以上。
Step3:
大卫·查诺夫曾与一位担任驻英国大使的美国海军上将合作。
我需要寻找美国海军上将并找到驻英国大使。
Step4:
在 1944 年设立舰队上将之前,海军上将是美国海军的最高军衔。
该军衔被认为至少相当于五星级海军上将,
其中乔治·杜威海军上将是 唯一被任命为军衔的军官。
Step5:
该段没有提及驻英国大使。 我需要寻找美国海军上将驻英国大使。
Step6:
找不到[美国 海军上将驻英国大使]。
类似:[“美国海军部长”、“美国海军四星上将名单”、
“雷蒙德·A·斯普鲁恩斯”、“第一海军杰克”、
“英美关系”、“ 珍珠港袭击”、“美国革命之子成员名单”、
“威廉·J·克罗”、“肯尼思·布雷斯韦特”、“杰出服务奖章(美国陆军)”]
Step7:
我可以搜索威廉·J·克罗并找到驻英国大使。
Step8:
小威廉·詹姆斯·克罗(William James Crowe Jr.,1925年1月2日-2007年10月18日)