6个版本
0.1.6 | 2024年4月21日 |
---|---|
0.1.5 | 2024年4月20日 |
200 在 Web编程
每月33 次下载
46KB
1K SLoC
一个免费的反向代理和CLI工具,用于OpenAI GPT-3.5-turbo
它允许您无需注册API密钥或付费即可使用GPT-3.5 API。
OpenAI GPT-3.5-turbo免费使用,无需任何账户或API密钥,**仅限个人使用/测试**,**不要在生产环境中使用**
特性
- REPL模式,您可以交互式地输入问题和获取答案
- 反向代理模式,您可以使用本地服务器使用OpenAI OpenAPI
- CLI模式,带有shell管道、文件输入、代码输出等
- 支持https代理和socks5代理
下载预编译的二进制文件
如何使用
# To get answers from GPT-3.5
fgpt "How to get a domain's MX record on linux shell?"
# Output plain code -c/--code
fgpt -c "Write python code to reverse a string"
# With pipe
git diff | fgpt "Write a git commit bief with follow diff"
# With stdin
fgpt "Convert the follow csv data to json, without any description" < contacts.csv
# With file -f/--file
fgpt -f contacts.csv "Convert the follow csv data to json, without any description"
# REPL mode
fgpt
>> Write a javascript code to reverse a string
...
使用http代理
如果您无法连接,您可以尝试使用代理。支持HTTP和SOCKS5代理。例如
# 1. pass the proxy address by -p/--proxy
fgpt -p 'socks5://127.0.0.1:9080' "Linux command to list files in a directory"
# 2. pass the proxy address by environment variable
export HTTPS_PROXY='socks5://127.0.0.1:9080'
fgpt "Linux command to list files in a directory"
# 3. use alias to set the proxy address
alias fgpt='fgpt -p "socks5://127.0.0.1:9080"'
fgpt "Linux command to list files in a directory"
统计信息输出
fgpt --stats "Linux command to list files in a directory"
通过docker使用
docker run -it --rm shenjinti/fgpt "Linux command to list files in a directory"
如何使用反向代理
提供免费的自托管API访问ChatGPT。如果您想使用OpenAI API而不需要注册API密钥,这将非常有用。
1. 启动服务器
fgpt -s 127.0.0.1:4090
您的本地服务器现在正在运行,并可通过以下地址访问:http://127.0.0.1:4090/v1/chat/completions
2. 使用OpenAI库的示例用法
import openai
openai.api_key = 'nothing'
openai.base_url = "http://127.0.0.1:4090/v1/"
completion = openai.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Write a javascript simple code"},
],
)
print(completion.choices[0].message.content)
或使用curl测试
curl -X POST -H "Content-Type: application/json" -d '{"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"Write a javascript simple code"}], "stream":true}' http://127.0.0.1:4090/v1/chat/completions
curl -X POST -H "Content-Type: application/json" -d '{"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"Write a javascript simple code"}]}' http://127.0.0.1:4090/v1/chat/completions
依赖关系
~24–38MB
~677K SLoC