Comments (3)
随便给 OPENAI_API_KEY 赋值就行:
OPENAI_API_KEY=hello OPENAI_API_BASE=http://127.0.0.1:8000/v1 python openai_client.py --stream --prompt 你好
from chatglm.cpp.
openai 1.5.0 中,指定 OPENAI_API_KEY=hello 后 openai_client.py 超时
openai.APITimeoutError: Request timed out.
openai_client.py 执行了 openai migrate
做了升级:
diff --git a/examples/openai_client.py b/examples/openai_client.py
index 372a541..e1ddfa5 100644
--- a/examples/openai_client.py
+++ b/examples/openai_client.py
@@ -1,6 +1,8 @@
import argparse
-import openai
+from openai import OpenAI
+
+client = OpenAI()
parser = argparse.ArgumentParser()
parser.add_argument("--stream", action="store_true")
@@ -9,11 +11,11 @@ args = parser.parse_args()
messages = [{"role": "user", "content": args.prompt}]
if args.stream:
- response = openai.ChatCompletion.create(model="default-model", messages=messages, stream=True)
+ response = client.chat.completions.create(model="default-model", messages=messages, stream=True)
for chunk in response:
content = chunk["choices"][0]["delta"].get("content", "")
print(content, end="", flush=True)
print()
else:
- response = openai.ChatCompletion.create(model="default-model", messages=messages)
+ response = client.chat.completions.create(model="default-model", messages=messages)
print(response["choices"][0]["message"]["content"])
from chatglm.cpp.
补充一下,安装 0.28.1 是工作的
pip install openai==0.28.1
from chatglm.cpp.
Related Issues (20)
- 跟新cmke版本后出现问题 HOT 2
- 请问是否有将chatglm.cpp合并到llama.cpp的计划? HOT 7
- 能否提供对P100 GPU的支持 HOT 2
- opeai_api没有支持function call功能
- Failed to install python binding for Windows HOT 2
- Q4_0 + CPU转换避坑指南 HOT 9
- How to release an old loaded model file using Python.
- CodeGeeX2模型转换错误 HOT 2
- ChatGLM3 使用 examples/cli_demo.py 时报错 'TypeError: chat() got an unexpected keyword argument 'max_new_tokens'' HOT 1
- check failed (data != MAP_FAILED) Invalid argument HOT 1
- How to construct a ToolCallMessage?
- 更新后运行报错:No module named 'pydantic._internal' HOT 4
- 【已解决,附解决方法】无法运行 LangChain API ,执行命令后报错, 能否提供能成功运行此命令的 python版本号 和 使用的环境中安装的包的列表 HOT 3
- 显存使用增加
- 为什么4090显卡用不了,编译成功之后也是用的cpu推理 HOT 5
- mac m1 启动cli_demo.py时,抛出incompatible architecture异常 HOT 1
- 如何设置更长的上下文(context) HOT 5
- v0.3.0 "发布" 里的Python包中的C++程序是以什么配置构建的?
- Fix: Dockerfile Building Locally
- 量化后的ChatGlm3-6B使用open_api部署tools功能无法使用 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatglm.cpp.