Git Product home page Git Product logo

gpt-bridge-demo's Introduction

gpt-bridge-demo

项目概要

桥接openai提供的开放api,封装自己的ai服务

主要功能

  • 服务端
  1. 提供一个chat接口,传入id和content字段,id作为一次连续对话的id,content是单次发送的文本,以流的形式返回对话结果
  2. 提供clear接口,传入id,情况一次连续对话的内容
  • 客户端
  1. 模仿gpt的页面,输入文本,调用chat接口,读取返回流向对话区域持续添加响应的文本,实现持续对话的效果

技术栈

  • Koa
  • 使用openai官方提供的库openai来调用gpt-3.5-turbo模型
  • 向客户端响应Readable对象,实现数据流式传输

安装

如果您要运行这个demo,您需要

  1. 申请一个openai的API keys,地址:https://platform.openai.com/api-keys
  2. 用你的API key替换packages/gpt-server/.env中的OPENAI_API_KEY字段
  3. 准备一个流量转发服务以保证你的流量可以到达openai的服务器,或者你的网络环境可以直达openai的服务器
  4. 将你的转发服务地址替换掉.env文件中的SOCKS_PROXY_AGENT字段
  5. pnpm install
  6. cd packages/gpt-server
  7. npm run dev
  8. 客户端直接打开index.html文件即可

gpt-bridge-demo's People

Contributors

spuerzjj 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.