- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 langchain 代理为软件工程师生成一个月的面试计划。期望代理应该询问用户几个问题并制定计划。
import os
from langchain.memory import ConversationBufferMemory
from langchain.chat_models import ChatOpenAI
from langchain.agents import load_tools, initialize_agent
from langchain.agents import AgentType
os.environ["OPENAI_API_KEY"] = "sk-"
def _handle_error(error) -> str:
return str(error)[:50]
if __name__ == '__main__':
llm = ChatOpenAI(temperature=0.0)
tools = load_tools(
["human"],
llm=llm,
)
memory = ConversationBufferMemory(memory_key="chat_history")
agent_chain = initialize_agent(
tools,
llm,
agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,
verbose=True,
memory=memory,
max_iterations=3,
handle_parsing_errors=_handle_error
)
agent_chain.run(
"I want you to create a one-month interview preparation plan with the help of OpenAI by understanding my current skill level. Ask questions to user and get the answers and use them to generate plan")
最佳答案
试试这个..
# agent_chain.run(
# "I want you to create a one-month interview preparation plan with the help of OpenAI by understanding my current skill level. Ask questions to user and get the answers and use them to generate plan")
try:
response= agent_chain.run("I want you to create a one-month interview preparation plan with the help of OpenAI by understanding my current skill level. Ask questions to user and get the answers and use them to generate plan")
except Exception as e:
response = str(e)
if response.startswith("Could not parse LLM output: `"):
response = response.removeprefix("Could not parse LLM output: `").removesuffix("`")
print(response)
关于openai-api - Langchain 使用人工工具抛出解析响应错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77039247/
尝试运行 langchain 的基本教程脚本时遇到此错误: ModuleNotFoundError: No module named 'langchain.llms'; 'langchain' is
尝试运行 langchain 的基本教程脚本时遇到此错误: ModuleNotFoundError: No module named 'langchain.llms'; 'langchain' is
目录 简介 好的prompt 什么是prompt template 在langchain中创建prompt temp
我想我不明白代理如何选择工具。我有一个矢量数据库(Chroma),其中嵌入了我希望代理首先查看的所有内部知识。然后,如果答案不在 Chroma 数据库中,它应该使用 OpenAI 用于训练的信息(外部
我正在尝试使用 langchain 代理为软件工程师生成一个月的面试计划。期望代理应该询问用户几个问题并制定计划。 import os from langchain.memory import Con
我用 langchain 库构建了一个分割器函数,可以分割一系列 python 文件。在代码中的另一点,我需要将这些文档转换回 python 代码。只是我不知道该怎么做 def index_repo(
我正在使用 Langchain 的 RecursiveCharacterTextSplitter 来分割 python 文件。这样做我会丢失哪个 block 属于哪个文件的信息。之后如何跟踪各个 bl
希望你做得很好。我根据以下 langchain 文档准备了一个聊天机器人: Langchain chatbot documentation 在上面的langchain文档中,提示模板有两个输入变量——
我在Python中使用带有Gradio接口(interface)的Langchain。我制作了一个对话代理,并尝试将其响应传输到 Gradio 聊天机器人界面。我查看了 Langchain 文档,但找
我正在尝试使用 Langchain 和特定 URL 作为源数据来整理一个简单的“带有来源的问答”。该 URL 由一个页面组成,其中包含大量信息。 问题是 RetrievalQAWithSourcesC
希望你做得很好。我根据以下 langchain 文档准备了一个聊天机器人: Langchain chatbot documentation 在上面的langchain文档中,提示模板有两个输入变量——
我在Python中使用带有Gradio接口(interface)的Langchain。我制作了一个对话代理,并尝试将其响应传输到 Gradio 聊天机器人界面。我查看了 Langchain 文档,但找
我正在尝试使用 Langchain 和特定 URL 作为源数据来整理一个简单的“带有来源的问答”。该 URL 由一个页面组成,其中包含大量信息。 问题是 RetrievalQAWithSourcesC
我想我不明白代理如何选择工具。我有一个矢量数据库(Chroma),其中嵌入了我希望代理首先查看的所有内部知识。然后,如果答案不在 Chroma 数据库中,它应该使用 OpenAI 用于训练的信息(外部
我正在尝试使用 langchain 代理为软件工程师生成一个月的面试计划。期望代理应该询问用户几个问题并制定计划。 import os from langchain.memory import Con
我用 langchain 库构建了一个分割器函数,可以分割一系列 python 文件。在代码中的另一点,我需要将这些文档转换回 python 代码。只是我不知道该怎么做 def index_repo(
我正在使用 Langchain 的 RecursiveCharacterTextSplitter 来分割 python 文件。这样做我会丢失哪个 block 属于哪个文件的信息。之后如何跟踪各个 bl
我正在开发一个使用 SvelteKit 和 Langchain 的项目。我想实现一个功能,我可以按下按钮并让 UI 在聊天流进入时显示它们的标记。但是,我当前使用表单操作的实现遇到了一些困难。 这是我
我正在关注langchain官方文档here中的本教程我是否尝试在使用时跟踪 token 的数量。但是,我想使用 gpt-3.5-turbo 而不是 text-davinci-003,因此我将使用的
我想创建一个自托管的 LLM 模型,该模型将能够拥有我自己的自定义数据的上下文(就此而言,Slack 对话)。 我听说 Vicuna 是 ChatGPT 的一个很好的替代品,所以我编写了以下代码: f
我是一名优秀的程序员,十分优秀!