https://github.com/fzdwx/jacksapi
Jack's ChatGpt API client, simulate the official response of ChatGPT
https://github.com/fzdwx/jacksapi
chatgpt command openai simulate
Last synced: about 1 year ago
JSON representation
Jack's ChatGpt API client, simulate the official response of ChatGPT
- Host: GitHub
- URL: https://github.com/fzdwx/jacksapi
- Owner: fzdwx
- License: mit
- Created: 2023-05-29T11:09:14.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-27T12:38:07.000Z (over 2 years ago)
- Last Synced: 2025-02-08T19:47:08.019Z (about 1 year ago)
- Topics: chatgpt, command, openai, simulate
- Language: Go
- Homepage:
- Size: 415 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Jack's ChatGpt api client
It's a simple client for the https://chat-one.emmmm.dev/ .

## Usage
### lib
```shell
go get github.com/fzdwx/jacksapi@latest
```
code:
```go
var (
content = strings.Join(os.Args[1:], " ")
accessCode = os.Getenv("EMM_API_KEY")
)
jacksapi.NewClient(accessCode).
ChatStream(
[]jacksapi.ChatMessage{
{Role: "user", Content: content},
}).
DoWithCallback(jacksapi.Output)
```
### cli
```shell
go install github.com/fzdwx/jacksapi/cmd/ask@latest
```
command:
```shell
# ask chatgpt how are you
ask how are you
# start api server
ask server 1333
curl -X POST -H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"how are you"}]}' \
http://localhost:1333
# simulate the API of ChatGPT.
curl 'http://localhost:1333/v1/chat/completions' \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36' \
--data-raw '{"model":"gpt-3.5-turbo","temperature":0,"max_tokens":1000,"top_p":1,"frequency_penalty":1,"presence_penalty":1,"stream":true,"messages":[{"role":"system","content":"你是一个翻译引擎,请翻译给出的文本,只需要翻译不需要解释。当且仅当文本只有一个单词时,请给出单词原始形态(如果有)、单词的语种、对应的音标或转写、所有含义(含词性)、双语示例,至少三条例句,请严格按照下面格式给到翻译结果:\n <单词>\n [<语种>] · / \n [<词性缩写>] <中文含义>]\n 例句:\n <序号><例句>(例句翻译)\n 词源:\n <词源>"},{"role":"user","content":"好的,我明白了,请给我这个单词。"},{"role":"user","content":"单词是:hello"}]}' \
--compressed
```