Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GPTをLINEで使えるようにして布教した

 GPTをLINEで使えるようにして布教した

OpenAIのGPT APIをLINEから使えるようにAWSを構築したショートトークです。

https://github.com/ground0state/chat-with-agent

Masafumi Abeta

June 23, 2023
Tweet

More Decks by Masafumi Abeta

Other Decks in Programming

Transcript

  1. © 2023 Masafumi Abeta 8 AWS Cloud Mobile client Amazon

    API Gateway AWS Lambda Amazon DynamoDB AWS CloudFormation AWS Cloud Development Kit (AWS CDK) Developer GPT-3.5-turbo LINE Developers Massaging API サクッと構築 Good Framework
  2. © 2023 Masafumi Abeta 14 LangChainとは LLMを他の計算ソースや知識に組み合わせることを⽬指したライブラリ • 特定の⽂書に対する質疑応答 •

    柔軟な検索 • チャットボット • 記憶をもたせる機能 • ⾳声⼊⼒ / ⾳声回答 • エージェント • ユーザー⼊⼒に応じて使⽤するツールを⾃動で判断し実⾏する • アクションエージェント:逐次ツールを実⾏ • 前もってアクションの全シーケンスを決定し、プランを更新することなく全てを実⾏ 次のメインユースケースの実装を容易化する
  3. © 2023 Masafumi Abeta 15 LangChainとは LLMを他の計算ソースや知識に組み合わせることを⽬指したライブラリ • 特定の⽂書に対する質疑応答 •

    柔軟な検索 • チャットボット • 記憶をもたせる機能 • ⾳声⼊⼒ / ⾳声回答 • エージェント • ユーザー⼊⼒に応じて使⽤するツールを⾃動で判断し実⾏する • アクションエージェント:逐次ツールを実⾏ • 前もってアクションの全シーケンスを決定し、プランを更新することなく全てを実⾏ 次のメインユースケースの実装を容易化する
  4. © 2023 Masafumi Abeta 17 langchain.agents.conversational.prompt PREFIX = """Assistant is

    a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand. Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics. Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. TOOLS: ------ Assistant has access to the following tools:""" FORMAT_INSTRUCTIONS = """To use a tool, please use the following format: ``` Thought: Do I need to use a tool? Yes Action: the action to take, should be one of [{tool_names}] Action Input: the input to the action Observation: the result of the action ``` When you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format: ``` Thought: Do I need to use a tool? No {ai_prefix}: [your response here] ```""" SUFFIX = """Begin! Previous conversation history: {chat_history} New input: {input} {agent_scratchpad}""" v0.0.208 MIT License GPTモデルにツールを 使うべきか聞く
  5. © 2023 Masafumi Abeta 18 AWS Cloud Mobile client Amazon

    API Gateway AWS Lambda Amazon DynamoDB AWS CloudFormation AWS Cloud Development Kit (AWS CDK) Developer GPT-3.5-turbo Custom Search JSON API LINE Developers Massaging API Good Framework Google検索を追加
  6. © 2023 Masafumi Abeta 21 よくあるリクエスト ⾃分のAIを育てたい • 超⻑期記憶 •

    キャラクター崩壊防⽌ • ⾔語以外の⼊⼒ • ⾃分の⽣活、友達の情報の⼊⼒