Skip to content

Commit 2cd960b

Browse files
committed
migration for openai v1.0
1 parent dd5def5 commit 2cd960b

14 files changed

+572
-680
lines changed

langchain/jupyter/agents/react.ipynb

+25-28
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@
8585
"\u001b[32;1m\u001b[1;3m I need to find out who Leonardo DiCaprio's girlfriend is and then calculate her age to the 0.43 power.\n",
8686
"Action: Search\n",
8787
"Action Input: \"Leonardo DiCaprio girlfriend\"\u001b[0m\n",
88-
"Observation: \u001b[36;1m\u001b[1;3m[{'title': 'Leo in Paris with nine ex-girlfriends', 'link': 'https://www.news.com.au/entertainment/celebrity-life/celebrity-photos/leonardo-dicaprios-nine-exgirlfriends-at-paris-fashion-week/news-story/bd07623139cbc42f9ad683c72ab8609a', 'source': 'News.com.au', 'date': '3 days ago', 'thumbnail': 'https://serpapi.com/searches/652119a3b5961e6fd63885e9/images/7db95bf161919ea5f1437993aeba4501fe9fba0acebd51c0.jpeg'}, {'title': \"Leonardo DiCaprio in Paris at same time as 'new girlfriend and nine other exes'\", 'link': 'https://www.dailystar.co.uk/showbiz/us-showbiz/leonardo-dicaprio-paris-same-time-31105443', 'source': 'The Daily Star', 'date': '2 days ago', 'thumbnail': 'https://serpapi.com/searches/652119a3b5961e6fd63885e9/images/7db95bf161919ea5cc24078b67e8880b2a2065d86299c6fa.jpeg'}, {'title': 'Leonardo DiCaprio and new girlfriend Vittoria Ceretti grab dinner with friends in Paris', 'link': 'https://pagesix.com/2023/09/27/leonardo-dicaprio-girlfriend-vittoria-ceretti-grab-dinner-in-paris/', 'source': 'Page Six', 'date': '1 week ago', 'thumbnail': 'https://serpapi.com/searches/652119a3b5961e6fd63885e9/images/7db95bf161919ea541824bea9924d255b388ee4b94430297.jpeg'}, {'title': 'EXCLUSIVE: Leonardo DiCaprio, 48, settles down with Italian model girlfriend Vittoria Ceretti, 25, as pals cla', 'link': 'https://www.dailymail.co.uk/tvshowbiz/article-12491855/Leonardo-DiCaprio-settles-Italian-model-Vittoria-Ceretti-25-besotted-new-flame.html', 'source': 'Daily Mail', 'date': '1 month ago', 'thumbnail': 'https://serpapi.com/searches/652119a3b5961e6fd63885e9/images/7db95bf161919ea53904a654108da52820108789c1eba021.jpeg'}]\u001b[0m\n",
89-
"Thought:\u001b[32;1m\u001b[1;3m Leonardo DiCaprio's girlfriend is Vittoria Ceretti.\n",
88+
"Observation: \u001b[36;1m\u001b[1;3mVittoria Ceretti: 2023 According to sources, Leo and Vittoria reportedly met during the Killers of the Flower Moon premiere at the 2023 Cannes Film Festival. (The actor stars in the Martin Scorsese–directed film opposite Lily Gladstone.)\u001b[0m\n",
89+
"Thought:\u001b[32;1m\u001b[1;3m I need to calculate Vittoria's age to the 0.43 power.\n",
9090
"Action: Calculator\n",
91-
"Action Input: 25^0.43\u001b[0m\n",
92-
"Observation: \u001b[33;1m\u001b[1;3mAnswer: 3.991298452658078\u001b[0m\n",
91+
"Action Input: 2023^0.43\u001b[0m\n",
92+
"Observation: \u001b[33;1m\u001b[1;3mAnswer: 26.39843795372203\u001b[0m\n",
9393
"Thought:\u001b[32;1m\u001b[1;3m I now know the final answer.\n",
94-
"Final Answer: Vittoria Ceretti的年龄的0.43次方是3.991298452658078\u001b[0m\n",
94+
"Final Answer: Vittoria Ceretti的年龄的0.43次方是26.39843795372203\u001b[0m\n",
9595
"\n",
9696
"\u001b[1m> Finished chain.\u001b[0m\n"
9797
]
9898
},
9999
{
100100
"data": {
101101
"text/plain": [
102-
"'Vittoria Ceretti的年龄的0.43次方是3.991298452658078。'"
102+
"'Vittoria Ceretti的年龄的0.43次方是26.39843795372203。'"
103103
]
104104
},
105105
"execution_count": 5,
@@ -132,43 +132,40 @@
132132
"\n",
133133
"\n",
134134
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
135-
"\u001b[32;1m\u001b[1;3mThought: This question has two parts. First, I need to find out who Leonardo DiCaprio's girlfriend is. Then, I need to find out her age and calculate her age to the power of 0.43. I will start by searching for Leonardo DiCaprio's girlfriend. \n",
135+
"\u001b[32;1m\u001b[1;3mQuestion: 谁是莱昂纳多·迪卡普里奥的女朋友?\n",
136+
"Thought: 首先,我需要找出莱昂纳多·迪卡普里奥当前的女朋友是谁。这是一个关于当前事件的问题,所以我将使用搜索工具来找到答案。\n",
136137
"Action:\n",
137-
"```\n",
138-
"{\n",
139-
" \"action\": \"Search\",\n",
140-
" \"action_input\": \"Leonardo DiCaprio's girlfriend\"\n",
141-
"}\n",
142-
"```\u001b[0m\n",
143-
"Observation: \u001b[36;1m\u001b[1;3mBut after years of canoodling with various much younger beautiful women, Leonardo DiCaprio has finally settled down - at the age of 48. The Mail can reveal that the Hollywood actor has been dating Italian model Vittoria Ceretti for at least two months after they were seen kissing in an Ibiza nightclub this week.\u001b[0m\n",
144-
"Thought:\u001b[32;1m\u001b[1;3mLeonardo DiCaprio's girlfriend is Vittoria Ceretti. Now I need to find out her age. \n",
145-
"Action:\n",
146-
"```\n",
138+
"```json\n",
147139
"{\n",
148140
" \"action\": \"Search\",\n",
149-
" \"action_input\": \"Vittoria Ceretti age\"\n",
141+
" \"action_input\": \"莱昂纳多·迪卡普里奥 当前女朋友\"\n",
150142
"}\n",
151143
"```\u001b[0m\n",
152-
"Observation: \u001b[36;1m\u001b[1;3m25 years\u001b[0m\n",
153-
"Thought:\u001b[32;1m\u001b[1;3mVittoria Ceretti is 25 years old. Now I need to calculate 25 to the power of 0.43.\n",
144+
"Observation: \u001b[36;1m\u001b[1;3m['刚和25岁超模女友卡米拉分手的小李子莱昂纳多·迪卡普里奥,被曝22岁新女友“火速上线”。 这位被换女友如换衣服的小李子“临幸”的妙龄女子就是乌克兰超模玛莉 ...', '8月31日,据外媒报道,47岁的莱昂纳多·迪卡普里奥与刚满25岁不久的模特女友卡米拉·莫罗在今年刚刚入夏的时候,以“顺其自然”的方式分手,5年感情画上 ...', '49岁的莱昂纳多·迪卡普里奥和25岁女友Vittoria Ceretti及其女友的家人现身伦敦。ps:大胆的预测一下,小李子不会要结婚了吧? \\u200b', '新浪娱乐讯据媒体报道,48岁的奥斯卡影帝——莱昂纳多·迪卡普里奥(Leonardo DiCaprio)上周被拍到和23岁的女演员维多利亚·拉马斯(Victoria Lamas) ...', '莱昂纳多·迪卡普里奥(Leonardo DiCaprio) 和梅根·罗奇(Meghan Roche) 在看到豪华游艇后,否认“不,我们没有订婚”。', '8月31日,据外媒报道,“小李子”莱昂纳多·迪卡普里奥最近又双叒叕分手了,正式与辣妹模特卡米拉·莫罗尼结束近5年恋情。圈内有一种传闻,“小李子”的女友不会 ...', '现任女友是阿根廷模特和女演员卡米拉·莫朗(Camila Morrone),今年刚满22岁,她的年龄竟然与电影《泰坦尼克号》相同,她的男友小李在1997年凭借这部电影 ...', '演艺经历 1979年,5岁时,莱昂纳多·迪卡普里奥迎来了他的电视银幕处女秀,在教育片《游戏屋》中扮演一个角色。1988年,14岁时,他出现在他的第一部商业广告之中,那是为 ...', '莱昂纳多·迪卡普里奥再度分手,又一个没超过25岁的女友 ... 两人从2018年开始交往,至今已经交往了4年多。然而,今年5月被偷拍的狗仔队却发现两人关系出现 ...']\u001b[0m\n",
145+
"Thought:\u001b[32;1m\u001b[1;3m根据搜索结果,莱昂纳多·迪卡普里奥最近的女朋友是22岁的乌克兰超模玛莉。现在我需要计算22岁的0.43次方是多少。\n",
146+
"\n",
154147
"Action:\n",
155-
"```\n",
148+
"```json\n",
156149
"{\n",
157150
" \"action\": \"Calculator\",\n",
158-
" \"action_input\": \"25**0.43\"\n",
151+
" \"action_input\": {\n",
152+
" \"expression\": \"22^0.43\"\n",
153+
" }\n",
159154
"}\n",
160-
"```\u001b[0m\n",
161-
"Observation: \u001b[33;1m\u001b[1;3mAnswer: 3.991298452658078\u001b[0m\n",
162-
"Thought:\u001b[32;1m\u001b[1;3mThe age of Vittoria Ceretti to the power of 0.43 is approximately 3.99.\n",
163-
"Final Answer: 莱昂纳多·迪卡普里奥的女朋友是Vittoria Ceretti,她的年龄的0.43次方是3.99。\u001b[0m\n",
155+
"```\n",
156+
"\u001b[0m\n",
157+
"Observation: \u001b[33;1m\u001b[1;3mAnswer: 3.777824273683966\u001b[0m\n",
158+
"Thought:\u001b[32;1m\u001b[1;3mI now know the final answer to the original input question.\n",
159+
"\n",
160+
"Final Answer: 莱昂纳多·迪卡普里奥的女朋友是22岁的乌克兰超模玛莉,她现在年龄的0.43次方是大约3.78。\u001b[0m\n",
164161
"\n",
165162
"\u001b[1m> Finished chain.\u001b[0m\n"
166163
]
167164
},
168165
{
169166
"data": {
170167
"text/plain": [
171-
"'莱昂纳多·迪卡普里奥的女朋友是Vittoria Ceretti,她的年龄的0.43次方是3.99。'"
168+
"'莱昂纳多·迪卡普里奥的女朋友是22岁的乌克兰超模玛莉,她现在年龄的0.43次方是大约3.78。'"
172169
]
173170
},
174171
"execution_count": 6,
@@ -179,7 +176,7 @@
179176
"source": [
180177
"from langchain.chat_models import ChatOpenAI\n",
181178
"\n",
182-
"chat_model = ChatOpenAI(model=\"gpt-4\", temperature=0)\n",
179+
"chat_model = ChatOpenAI(model=\"gpt-4-1106-preview\", temperature=0)\n",
183180
"agent = initialize_agent(tools, chat_model, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True)\n",
184181
"agent.run(\"谁是莱昂纳多·迪卡普里奥的女朋友?她现在年龄的0.43次方是多少?\")"
185182
]

langchain/jupyter/agents/self_ask_with_search.ipynb

+21-17
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
},
118118
{
119119
"cell_type": "code",
120-
"execution_count": 10,
120+
"execution_count": 6,
121121
"id": "5fe1f2de-f982-4953-9e8e-7f99a8289975",
122122
"metadata": {},
123123
"outputs": [
@@ -130,22 +130,22 @@
130130
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
131131
"\u001b[32;1m\u001b[1;3m Yes.\n",
132132
"Follow up: 什么是2023年大运会?\u001b[0m\n",
133-
"Intermediate answer: \u001b[36;1m\u001b[1;3m['The 2023 FISU Summer World University Games, officially known as the 2023 Summer Universiade or the XXXII Summer World University Games, and commonly known as Yekaterinburg 2023 or Ekaterinburg 2023, ...', '2023 Summer World University Games (2023年夏季世界大学生运动会) type: Aug 8, 2023 – Aug 19, 2023.', '2023 Summer World University Games (2023年夏季世界大学生运动会) main_tab_text: Overview.', '2023 Summer World University Games (2023年夏季世界大学生运动会) kgmid: /g/11hzkdc1v8.', '2023 Summer World University Games (2023年夏季世界大学生运动会) dates: Aug 8, 2023 – Aug 19, 2023.', '2023 Summer World University Games (2023年夏季世界大学生运动会) location: Yekaterinburg.', '2023 Summer World University Games (2023年夏季世界大学生运动会) main_venue: Ekaterinburg Arena (opening/closing ceremonies).', '2023 Summer World University Games (2023年夏季世界大学生运动会) motto: For You.', '2023 Summer World University Games (2023年夏季世界大学生运动会) opening: 8 August (cancelled).', '2023 Summer World University Games (2023年夏季世界大学生运动会) sport: 18.', '2023年夏季世界大学生运动会(英语:XXXII 2023 Summer World University Games)简称为叶卡捷琳堡大运会,是第32届夏季世界大学生运动会。原定于2023年8月8日至19日在 ...']\u001b[0m\n",
133+
"Intermediate answer: \u001b[36;1m\u001b[1;3m['The 2023 FISU Summer World University Games, officially known as the 2023 Summer Universiade or the XXXII Summer World University Games, and commonly known as Yekaterinburg 2023 or Ekaterinburg 2023, ...', '2023 Summer World University Games (2023年夏季世界大学生运动会) type: Aug 8, 2023 – Aug 19, 2023.', '2023 Summer World University Games (2023年夏季世界大学生运动会) main_tab_text: Overview.', '2023 Summer World University Games (2023年夏季世界大学生运动会) kgmid: /g/11hzkdc1v8.', '2023 Summer World University Games (2023年夏季世界大学生运动会) dates: Aug 8, 2023 – Aug 19, 2023.', '2023 Summer World University Games (2023年夏季世界大学生运动会) location: Yekaterinburg.', '2023 Summer World University Games (2023年夏季世界大学生运动会) main_venue: Ekaterinburg Arena (opening/closing ceremonies).', '2023 Summer World University Games (2023年夏季世界大学生运动会) motto: For You.', '2023 Summer World University Games (2023年夏季世界大学生运动会) opening: 8 August (cancelled).', '2023 Summer World University Games (2023年夏季世界大学生运动会) sport: 18.', '2023年夏季世界大学生运动会(英语:XXXII 2023 Summer World University Games)简称为叶卡捷琳堡大运会,是第32届夏季世界大学生运动会。原定于2023年8月8日至19日在 ...', '成都第31届世界大学生夏季运动会(Chengdu 2021 FISU World University Games),简称“成都大运会”,将于2023年7月28日至8月8日在中国成都举办。', '2023年冬季世界大学生运动会(英语:2023 FISU Winter World University Games),正式名称为第31届冬季世界大学生运动会,也被称为2023年普莱西德湖大冬会或者2023年世界大冬会,于2023年1月12-22日在美国纽约州埃塞克斯县的普莱西德湖举行,是大学生参与的冬季体育项目世界 ...', '中新社成都6月25日电据国际大学生体育联合会消息,原定于今年6月在四川成都举行的第31届世界大学生夏季运动会(简称成都大运会)延期到2023年7月28日至8月8日举行。 同时,年龄限制和参赛资格将进行调整,以便符合2021和2022年(延期)参赛资格的学生参加。', '世界大学生夏季运动会,叶卡捷琳堡2023. 2019年7月2日,在国际大学生体育联合会(FISU)执行委员会会议上,决定委托叶卡捷琳堡主办2023年第三十二届世界大学生夏季运动会。 执行委员会的所有23名成员都支持叶卡捷琳堡的申请,叶卡捷琳堡是2023年世界大学生运动会的唯一申请者。 ...', '成都大运会是新冠疫情发生以来我国首个以开放形式举办的大型国际体育综合赛事,承载着党中央、国务院的关怀与重托,同时也备受国内国际社会高度关注,是一次重要的国际性体育赛事和文化盛会,也是促进世界青年大学生交流融合的重要平台。 我想用三句话介绍本届大运会的重要意义。 首先,这是一次来之不易的 ...', '... 2023年7月28日至8月8日在四川成都举行。大运会是面向全球大学生、规模仅次于奥林匹克运动会的世界综合性运动会,是全世界大学生运动员同台竞技的赛场 ...', '2023年7月28日,成都第31届世界大学生夏季运动会(以下简称:成都大运会)就将在东安湖体育公园盛大开幕,届时成都将向世界奉献一场独具魅力、别样精彩的青春盛会。', '成都大运会作为我国后疫情时代的首场国际体育赛事和2023年重大国家主场外交活动,是促进世界青年大学生交流发展的重要平台,是展现中国形象、讲好中国故事 ...', '世界大学生运动会自诞生以来,就一直是青春的盛会、团结的盛会、友谊的盛会。 ——我们要携手世界青年,以青春的活力促进世界和平与发展。国之交在于民相亲 ...']\u001b[0m\n",
134134
"\u001b[32;1m\u001b[1;3mFollow up: 2023年大运会举办地在哪里?\u001b[0m\n",
135-
"Intermediate answer: \u001b[36;1m\u001b[1;3m2018年3月5日正式宣布普莱西德湖成为2023年冬季大运会的主办城市,国际大体联官员称这是大运会申办历史上最强有力的一次。 由于2021年冬季世界大学生运动会因2019冠状病毒病疫情而取消,将大运会会旗正式移交给普莱西德湖的仪式改在2022年1月于都灵举行\u001b[0m\n",
135+
"Intermediate answer: \u001b[36;1m\u001b[1;3m第31届世界大学生夏季运动会,也就是成都大运会将于7月28日至8月8日举行。 今天(7月13日),成都大运会主媒体中心在东安湖体育公园开始试运行\u001b[0m\n",
136136
"\u001b[32;1m\u001b[1;3m\n",
137-
"So the final answer is: Yekaterinburg\u001b[0m\n",
137+
"So the final answer is: 成都\u001b[0m\n",
138138
"\n",
139139
"\u001b[1m> Finished chain.\u001b[0m\n"
140140
]
141141
},
142142
{
143143
"data": {
144144
"text/plain": [
145-
"'Yekaterinburg'"
145+
"'成都'"
146146
]
147147
},
148-
"execution_count": 10,
148+
"execution_count": 6,
149149
"metadata": {},
150150
"output_type": "execute_result"
151151
}
@@ -159,7 +159,7 @@
159159
},
160160
{
161161
"cell_type": "code",
162-
"execution_count": 8,
162+
"execution_count": 7,
163163
"id": "e1cf918e-a58a-4790-a4c4-2109f23dd064",
164164
"metadata": {},
165165
"outputs": [
@@ -180,7 +180,7 @@
180180
},
181181
{
182182
"cell_type": "code",
183-
"execution_count": 9,
183+
"execution_count": 8,
184184
"id": "32021fdf-2597-4dde-a425-13650904671f",
185185
"metadata": {},
186186
"outputs": [
@@ -209,19 +209,19 @@
209209
},
210210
{
211211
"cell_type": "code",
212-
"execution_count": 11,
212+
"execution_count": 9,
213213
"id": "d98ba940-a6e8-477e-83a9-2e20115ff51d",
214214
"metadata": {},
215215
"outputs": [],
216216
"source": [
217217
"from langchain.chat_models import ChatOpenAI\n",
218218
"\n",
219-
"chat_model = ChatOpenAI(model=\"gpt-4\", temperature=0)"
219+
"chat_model = ChatOpenAI(model=\"gpt-4-1106-preview\", temperature=0)"
220220
]
221221
},
222222
{
223223
"cell_type": "code",
224-
"execution_count": null,
224+
"execution_count": 10,
225225
"id": "fc4347f2-4a16-4406-92c7-d2156478bb56",
226226
"metadata": {},
227227
"outputs": [],
@@ -233,7 +233,7 @@
233233
},
234234
{
235235
"cell_type": "code",
236-
"execution_count": 12,
236+
"execution_count": 11,
237237
"id": "25978771-8e69-41f2-b9e8-b287d846e1cd",
238238
"metadata": {},
239239
"outputs": [
@@ -245,20 +245,24 @@
245245
"\n",
246246
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
247247
"\u001b[32;1m\u001b[1;3mYes.\n",
248-
"Follow up: 2023年大运会是哪个国家举办的?\u001b[0m\n",
249-
"Intermediate answer: \u001b[36;1m\u001b[1;3m2023年冬季世界大学生运动会(英语:2023 FISU Winter World University Games),正式名称为第31届冬季世界大学生运动会,也被称为2023年普莱西德湖大冬会或者2023年世界大冬会,于2023年1月12-22日在美国纽约州埃塞克斯县的普莱西德湖举行,是大学生参与的冬季体育项目世界 ...\u001b[0m\n",
250-
"\u001b[32;1m\u001b[1;3mSo the final answer is: 美国纽约州埃塞克斯县的普莱西德湖\u001b[0m\n",
248+
"Follow up: What is the English translation of \"2023年大运会\"?\u001b[0m\n",
249+
"Intermediate answer: \u001b[36;1m\u001b[1;3mNo good search result found\u001b[0m\n",
250+
"\u001b[32;1m\u001b[1;3mThe phrase \"2023年大运会\" translates to \"2023 Universiade\" in English. The Universiade is an international multi-sport event, organized for university athletes by the International University Sports Federation (FISU).\n",
251+
"\n",
252+
"Follow up: Where is the 2023 Universiade being held?\u001b[0m\n",
253+
"Intermediate answer: \u001b[36;1m\u001b[1;3mLake Placid 2023 FISU World University Games Winter, 12-22 January. Welcome back to legendary Lake Placid, where many Universiade and Olympic Legends were born.\u001b[0m\n",
254+
"\u001b[32;1m\u001b[1;3mSo the final answer is: Lake Placid, New York, United States\u001b[0m\n",
251255
"\n",
252256
"\u001b[1m> Finished chain.\u001b[0m\n"
253257
]
254258
},
255259
{
256260
"data": {
257261
"text/plain": [
258-
"'美国纽约州埃塞克斯县的普莱西德湖'"
262+
"'Lake Placid, New York, United States'"
259263
]
260264
},
261-
"execution_count": 12,
265+
"execution_count": 11,
262266
"metadata": {},
263267
"output_type": "execute_result"
264268
}

0 commit comments

Comments
 (0)