欢迎来到Langchain搜索机器人存储库!对于那些想潜入Langchain迅速工程世界的人来说,这个项目是一个绝佳的起点。这是一个基于Python的聊天机器人,可利用OpenAI API和Google搜索的功能,通过Serpapi为像您这样的工程师提供互动和教育体验。
Langchain是一个多功能的Python库,简化了使用大语言模型(LLMS)构建NLP应用程序的过程。它提供了广泛的功能,例如LLM和提示,模式,模型,提示,索引,内存,链条和代理。该存储库利用Langchain创建一个有趣而引人入胜的聊天机器人,可以帮助您学习及时工程的来源。
Langchain搜索机器人非常适合任何想要的人:
该聊天机器人不仅是一种学习工具,而且是您未来NLP项目的跳板。通过使用Langchain搜索机器人,您将获得宝贵的体验,随着您构建更复杂的应用程序,这些体验将派上用场。
我鼓励您潜入,探索代码并尝试不同的功能。 Langchain搜索机器人设计为友好,开朗和热情,因此请毫不犹豫地开始!
有关Langchain及其组件的详细介绍,请参阅Langchain快速入门指南。它将引导您完成您需要了解的一切,以精通NLP项目使用Langchain。
那么,您还在等什么?让我们从Langchain搜索机器人开始进入迅速工程的旅程!愉快的编码!
docker-desktop和docker-compose 。OPENAI_API_KEY和SERPAPI_API_KEY的API键在存储库中配置key.env文件。config.yml 。docker-compose.yml中配置image和container_nameubuntu:latestmy_chatbotdocker-compose builddocker-compose up -d 。docker exec -it CONTAINER_NAME /bin/bashpython3 src/main.py运行机器人exitdocker-compose down拆除Docker环境在本节中,我们将使用提供的提示模板详细介绍提示工程的简单示例。这将有助于您了解如何教授某些语言模型某些行为,例如其名称,情感以及如何回答问题。我们还将探索格式化部分背后的逻辑。我鼓励您尝试不同的提示,以观察机器人行为的变化!
我们将使用的提示模板位于/App/src/template/base.txt上:
Your name is {chatbot_name}. If asked to identify yourself, respond with your name.
The sentiment of your language is kind, friendly, and virtuous.
You have access to the following tools:
{tools}
Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do and decide whether or not to use the available tools. If you know the answer or can generate it, proceed to the final answer. If not, consider using a tool. For current information like date, time news, or events, use the appropriate tool from [{tool_names}] to search for external information and incorporate the information into your knowledge. Your answers should never include placeholders that you intend to have filled by variables or formatting.
If needed, Action: the action to take, it should answer the question, it could be one of [{tool_names}]
If needed, Action Input: the input to the action
If needed, Observation: the result of the action. Parse and extract the relevant information from the observation.
... (this Thought/Action/Action Input/Observation can repeat N times if required)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin! Remember to be in the persona of the cheerful, humble, wise, and virtuous assistant {chatbot_name}.
Question: {input}
{agent_scratchpad}
在此模板中,初始组件定义了聊天机器人的名称,当要求识别自己时应响应如何以及其语言的情感。情绪被描述为善良,友好和贤惠,为机器人的回答定下了基调。
格式化部分指导聊天机器人的决策过程。它从一个问题开始,然后是一个思考过程,聊天机器人认为它是否已经知道答案或需要使用工具来查找它。如果需要工具,聊天机器人将选择适当的操作,提供必要的输入并观察结果。此思想/动作/动作输入/观察顺序可以根据需要重复多次回答问题。
一旦聊天机器人收集了相关信息,它将继续进行最终答案,这是聊天机器人对输入问题的回答。
要开始及时工程,请尝试修改此模板并观察变化如何影响聊天机器人的行为。您可以更改机器人的名称,情感或可用工具。尝试不同的提示,并观察聊天机器人如何适应新说明。这种动手体验将帮助您更深入地了解迅速工程的工作方式以及如何创建更复杂和定制的聊天机器人体验。
该项目是根据Apache 2.0许可证的条款获得许可的。
版本2.0,2004年1月http://www.apache.org/licenses/
版权2023 Kyle J. Tobin
根据Apache许可证(版本2.0(“许可”)获得许可;除了符合许可外,您不得使用此文件。您可以在
http://www.apache.org/licenses/license-2.0
除非适用法律要求或以书面形式同意,否则根据许可证分配的软件是按照“原样”分发的,没有任何明示或暗示的任何形式的保证或条件。请参阅许可证,以获取执行许可条款和限制的特定语言。