小智头像图片
AI教程 2025年01月16日
0 收藏 0 点赞 519 浏览 2921 个字
摘要 :

面向开发者的LLM入门课程-代理英文版(1): 1. 使用LangChain内置工具llm-math和wikipedia from langchain.agents import load_tools, initialize_agent from langchai……

哈喽!伙伴们,我是小智,你们的AI向导。欢迎来到每日的AI学习时间。今天,我们将一起深入AI的奇妙世界,探索“面向开发者的LLM入门课程-代理英文版(1)”,并学会本篇文章中所讲的全部知识点。还是那句话“不必远征未知,只需唤醒你的潜能!”跟着小智的步伐,我们终将学有所成,学以致用,并发现自身的更多可能性。话不多说,现在就让我们开始这场激发潜能的AI学习之旅吧。

面向开发者的LLM入门课程-代理英文版(1)

面向开发者的LLM入门课程-代理英文版(1):

1. 使用LangChain内置工具llm-math和wikipedia

from langchain.agents import load_tools, initialize_agent
from langchain.agents import AgentType
from langchain.python import PythonREPL
from langchain.chat_models import ChatOpenAI

llm = ChatOpenAI(temperature=0)
tools = load_tools(
[“llm-math”,”wikipedia”],
llm=llm
)

agent= initialize_agent(
tools,
llm,
agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
handle_parsing_errors=True,
verbose = True
)

agent(“What is the 25% of 300?”)

> Entering new AgentExecutor chain…
I can use the calculator tool to find the answer to this question.

Action:
“`json
{
“action”: “Calculator”,
“action_input”: “25% of 300”
}
“`
Observation: Answer: 75.0
Thought:The answer is 75.0.
Final Answer: 75.0

> Finished chain.

{‘input’: ‘What is the 25% of 300?’, ‘output’: ‘75.0’}

Tom M. Mitchell的书

from langchain.agents import load_tools, initialize_agent
from langchain.agents import AgentType
from langchain.python import PythonREPL
from langchain.chat_models import ChatOpenAI

llm = ChatOpenAI(temperature=0)
tools = load_tools(
[“llm-math”,”wikipedia”],
llm=llm
)

agent= initialize_agent(
tools,
llm,
agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
handle_parsing_errors=True,
verbose = True
)

question = “Tom M. Mitchell is an American computer scientist
and the Founders University Professor at Carnegie Mellon University (CMU)
what book did he write?”
agent(question)

> Entering new AgentExecutor chain…
Thought: I can use Wikipedia to find out what book Tom M. Mitchell wrote.
Action:
“`json
{
“action”: “Wikipedia”,
“action_input”: “Tom M. Mitchell”
}
“`
Observation: Page: Tom M. Mitchell
Summary: Tom Michael Mitchell (born August 9, 1951) is an American computer
scientist and the Founders University Professor at Carnegie Mellon University
(CMU). He is a founder and former Chair of the Machine Learning Department at
CMU. Mitchell is known for his contributions to the advancement of machine
learning, artificial intelligence, and cognitive neuroscience and is the author
of the textbook Machine Learning. He is a member of the United States National
Academy of Engineering since 2010. He is also a Fellow of the American Academy of
Arts and Sciences, the American Association for the Advancement of Science and a
Fellow and past President of the Association for the Advancement of Artificial
Intelligence. In October 2018, Mitchell was appointed as the Interim Dean of the
School of Computer Science at Carnegie Mellon.

Page: Tom Mitchell (Australian footballer)
Summary: Thomas Mitchell (born 31 May 1993) is a professional Australian rules
footballer playing for the Collingwood Football Club in the Australian Football
League (AFL). He previously played for the Adelaide Crows, Sydney Swans from 2012
to 2016, and the Hawthorn Football Club between 2017 and 2022. Mitchell won the
Brownlow Medal as the league’s best and fairest player in 2018 and set the record
for the most disposals in a VFL/AFL match, accruing 54 in a game against
Collingwood during that season.
Thought:The book that Tom M. Mitchell wrote is “Machine Learning”.
Final Answer: Machine Learning

> Finished chain.

{‘input’: ‘Tom M. Mitchell is an American computer scientist and the Founders
University Professor at Carnegie Mellon University (CMU)what book did he write?’,
‘output’: ‘Machine Learning’}

面向开发者的LLM入门课程-代理英文版(2)
面向开发者的LLM入门课程-代理英文版(2):2. 使用LangChain内置工具PythonREPLTool from langchain.agents.agent_toolkits imp...

嘿,伙伴们,今天我们的AI探索之旅已经圆满结束。关于“面向开发者的LLM入门课程-代理英文版(1)”的内容已经分享给大家了。感谢你们的陪伴,希望这次旅程让你对AI能够更了解、更喜欢。谨记,精准提问是解锁AI潜能的钥匙哦!如果有小伙伴想要了解学习更多的AI知识,请关注我们的官网“AI智研社”,保证让你收获满满呦!

微信打赏二维码 微信扫一扫

支付宝打赏二维码 支付宝扫一扫

版权: 转载请注明出处:https://www.ai-blog.cn/2742.html

相关推荐

AI写作-DeepSeek高阶提示词之自媒体爆款创作篇: 自媒体爆款创作篇 6.10W+标题生成器 “生成20个关…

小智头像图片
519

AI写作-DeepSeek高阶提示词之职场打工人必备篇: 职场打工人必备篇 1.会议纪要秒整理 “将以下会议…

小智头像图片
519

AI绘画-即梦3.0提示词示例之场景化种草型​: 场景化种草型​ 公式:产品+使用场景+氛围渲染+情感化…

小智头像图片
64

AI绘画-即梦3.0提示词示例之限时折扣型​: 限时折扣型​ 公式:产品+价格锚点+紧迫感元素+霓虹灯风…

小智头像图片
519

AI绘画-即梦3.0提示词示例之新品发布型: 新品发布型​ 公式:产品+核心卖点+高级质感+极简排版 ​ …

小智头像图片
519

AI绘画-即梦3.0提示词示例之节日促销型​: 节日促销型​ 公式:产品+节日主题+视觉元素+动态文字+风…

小智头像图片
519

AI绘画-即梦3.0提示词示例之暗黑哥特​: 暗黑哥特​ 提示词: 哥特体、烛光照明、高反差,荆棘十字…

小智头像图片
519

AI绘画-即梦3.0提示词示例之奶油治愈​: 奶油治愈​ 提示词: 奶乎乎、柔焦镜头、低对比,猫咪蜷缩…

小智头像图片
519
发表评论
暂无评论

还没有评论呢,快来抢沙发~

助力原创内容

快速提升站内名气成为大牛

扫描二维码

手机访问本站

二维码
vip弹窗图片