歡迎來到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
除非適用法律要求或以書面形式同意,否則根據許可證分配的軟件是按照“原樣”分發的,沒有任何明示或暗示的任何形式的保證或條件。請參閱許可證,以獲取執行許可條款和限制的特定語言。