Skip to content

使用 gin 实现的 chatgpt server,支持流式调用

Notifications You must be signed in to change notification settings

nullxjx/chatgpt-server-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chatgpt-server-go

介绍

使用 Gin and Go OpenAI 实现的 chatgpt server,支持流式调用和非流式调用,兼容openai接口。流式调用支持context cancel。

项目采用 golang 标准目录布局

使用指南

启动server

cd cmd/chatgpt
go run main.go

启动好服务之后,使用下面的命令测试

curl localhost:8080/v1/completions \
  -H "Content-Type: application/json" \
  -d '{
        "model": "codewise-7b",
        "prompt": "如何使用nginx进行负载均衡?",
        "max_tokens": 256,
        "temperature": 0.2,
        "stream": true
    }'

curl localhost:8080/v1/chat/completions \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "model": "codewise-7b",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "如何使用nginx进行负载均衡?"}
    ],
    "max_tokens": 256,
    "temperature": 1,
    "stream": true,
    "skip_special_tokens": false
  }'

About

使用 gin 实现的 chatgpt server,支持流式调用

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages