Git Product home page Git Product logo

chatgpt101's Introduction

ChatGPT101ChatGPT Code Fun Sample Porject

GPTLinebot

結合 OpenAI API 的 Linebot 範例,僅做為研究性質,程式碼並未做最佳化處理,用於生產環境時,請自行優化,此外串接 Line Platform 的部份,使用自行撰寫之 DotNetLineBotSDK,目前為alpha版本,支援回應文字、影音、圖卡等基本功能,發佈於Nuget https://www.nuget.org/packages/DotNetLineBotSDK

  • LinebotController 使用 text-davinci-003 模型,不具備上下文管理

  • LinebotController2 使用 text-davinci-003 模型,具備上下文管理,透過注入UserHistoryPrompt靜態物件記錄過往談話內容,做為示範,用於生產環境時,您應該考慮使用額外的儲存方式,例如redis等,此外您應該考慮處理Token數上限問題,text-davinci-003 模型上限是4000 Token數。

text-davinci-003 上下文管理是透過將過去的對話記錄回送,進而使text-davinci-003產生完整內容生成達到回應的效果,例如:

ME:句子1
AI:xxxxxxx
ME:句子2
AI:xxxxxxx
ME:句子3
AI:

此時下一輪時只要將上述內容做為Prompt送出,text-davinci-003就會補足後續內容。

  • LinebotController3 使用 gpt-3.5-turbo 模型,具備上下文管理,透過注入ChatGptRequestModel靜態物件記錄過往談話內容,做為示範,用於生產環境時,您應該考慮使用額外的儲存方式,例如redis等,此外您應該考慮處理Token數上限問題,gpt-3.5-turbo 模型上限是4096 Token數。

gpt-3.5-turbo 本身即做為一個以 chat 為應用的模型,因此比 text-davinci-003 模型更適合用於 chat 的情境,上下文管理與text-davinci-003 相同是透過將過去的對話記錄回送,不過格式並不同,請參考如下(取自OpenAI):

openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who won the world series in 2020?"},
        {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
        {"role": "user", "content": "Where was it played?"}
    ]
)

其中 messages 以陣列格式做為 API 參數,並納入 role 與 content 概念,可讓 gpt-3.5-turbo 模型明確識別對話的情境。

QuestionAnsweringLinebot

LineChatbot提供Q&A問答,結合Azure Cognitive for Language的Answer questions API,找出客戶問題的對應解答,接著把該解答交由PT-3.5 Turbo模型進行文字潤飾後,再以一個客服人員的角色進行自動回覆。

  • 2023/4/4 LinebotController 新增AOAI—GPT 4 範例,AOAI—GPT 4 在API 端點及Request、Response參數皆與GPT 3.5不同

chatgpt101's People

Contributors

ianede avatar iangithub avatar

Stargazers

 avatar  avatar Nick Chen avatar  avatar ChiBot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.