zhipuai-sdk-python's Introduction
zhipuai-sdk-python's People
Forkers
knowlimit flowerbling gunhouwong wulin-challenge pluswave assassindesign ym19961210 zmxxmz0713 czs100 cybershang frank-ay cylonspace bigguy2333 wangxuguozhipuai-sdk-python's Issues
async_invoke输出如何获取content
async_invoke获取的输出不像invoke一样有content,请问我该如何获取模型返回内容?输出为:
{'code': 200, 'msg': '操作成功', 'data': {'request_id': '8037945188998056719', 'task_id': '16903673447268037945188998056721', 'task_status': 'PROCESSING'}, 'success': True}
def async_invoke_example():
response = zhipuai.model_api.async_invoke(
model="chatglm_pro",
prompt=[{"role": "user", "content": "人工智能"}],
top_p=0.7,
temperature=0.9,
)
print(response)
async_invoke_example()
调用 ChatGLM-Pro API 接口进行多轮对话问题
fail to install python sdk on debian env
in debian 9 with Python3.6 and Python3.10 both fail to run due to this error .AttributeError: module 'typing' has no attribute '_ClassVar'
关于模型`prompt`参数列表长度为奇数的疑问。
是否需要OpenAI SDK的 ChatCompletion 包装?方便兼容其他LangChain等基于openai体系的应用?
是否需要OpenAI SDK的 ChatCompletion 包装?类似本地LLM那样通过替换api_base/api_key
完成智普API的访问?
之前通过自己包装zhipuai的SDK还比较方便,但想利用一些其他库时会比较困难。目前设想的是实现类似下面的bridge,对相关请求进行统一包装翻译:
# import openai
import zhipuai.openai_bridge as openai
openai.api_key = "zhipu token"
completion = openai.ChatCompletion.create(
model="chatglm_pro",
messages=[{"role": "user", "content": "你好,请自我介绍并说明你能给我提供的帮助"}]
)
print(completion.choices[0].message.content)
实现方式类似 one-api 里的映射方式:
https://github.com/songquanpeng/one-api/blob/f0d5e102a3dc22289e00860f63ebd0f125531641/controller/relay-text.go#L252
文件上传可否多元化?
现在只能传输josn的训练文件
AttributeError: module 'zhipuai' has no attribute 'model_api'
env:
python 3.7.3
zhipuai 1.0.7
when using
response = zhipuai.model_api.invoke()
it return:
AttributeError: module 'zhipuai' has no attribute 'model_api'
API有支持的Function Call的计划吗
如题。
关注到ChatGLM3-6B的开源模型已经支持了function call。请问像是ChatGLM-130B这类模型的API有支持的Function Call的计划吗?
[1234][网络错误,错误id:8168867886816165954,请联系客服。]
太垃圾了,连system message都不支持???
self._logger.debug("Dispatching %s...", event)
这里的event不是str类型,导致TypeError了
zhipuai api 如何获取接口调用时间?
有没有类似openai的 client.chat.completions.with_raw_response.create?
response = client.chat.completions.with_raw_response.create()
duration_in_ms = response.elapsed.total_seconds() * 1000
请问如何调用创建的应用?
自己创建了 知识库应用,如何调用?
API 启动报错 401
我在尝试使用 OpenAI 风格的 API 接入智谱AI,但遇到了一些问题。使用 Python 包可以成功地访问智谱AI,然而,当我尝试集成到其他项目中时,遇到了鉴权失败的问题。
具体地,我尝试了以下 Python 代码:
from llama_index.llms import OpenAI
chat = OpenAI(api_key=api_key, api_base="https://open.bigmodel.cn/api/paas/v4")
chat.complete("hello")
API 文档提供了 Python 包的调用方法,没有给出 curl
的示例。尽管使用 zhipuai
能够正常访问,但不好做扩展迁移。
提问题前,我用 APIfox 做了调试,但仍存在 401 鉴权错误。以下是我尝试的 curl
命令:
curl --location --request POST 'https://open.bigmodel.cn/api/paas/v4/chat/completions' \
--header 'Authorization: Bearer <真实密钥>' \
--header 'Content-Type: application/json; charset=UTF-8' \
--header 'Accept: */*' \
--header 'Host: open.bigmodel.cn' \
--header 'Connection: keep-alive' \
--data-raw '{"model": "glm-3-turbo", "messages": [{"role": "system", "content": "say hi"}]}'
感谢读到这里!希望能提供更详细 API 示例的文档!或者能否兼容 OpenAI 的模式。
官网和github开源的sdk版本差距有点大
官网上,从pypi上安装的zhipu sdk已经是2.0.1版本了,源代码安装还是1.0.8版本,好几个模型不支持
这个sdk已经废弃了吗
pydantic 依赖冲突
安装pypi官方zhipuai-sdk后,会默认安装pydantic v2导致原有的v1应用发生问题。
劳烦给出异步调用后,如何接受真实的response
response = zhipuai.model_api.async_invoke。。。。。。
print(response)
async_invoke 返回值结构如下:
{'code': 200, 'msg': '操作成功', 'data': {'request_id': '8107267232470178304', 'task_id': '113516996052348378107267232470178305', 'task_status': 'PROCESSING'}, 'success': True}
怎么接受具体的返回值呢?劳烦给出具体的代码示例。
AttributeError: partially initialized module 'zhipuai' has no attribute 'model_api' (most likely due to a circular import)
在执行官方示例时,报这个错误
import zhipuai
zhipuai.api_key = "my key"
response = zhipuai.model_api.sse_invoke(
model="chatglm_lite",
prompt=[
{"role": "user", "content": "你好"},
{"role": "assistant", "content": "我是人工智能助手"},
{"role": "user", "content": "你叫什么名字"},
{"role": "assistant", "content": "我叫chatGLM"},
{"role": "user", "content": "你都可以做些什么事"},
]
)
报错信息:
Traceback (most recent call last):
File "/mnt/e/Projects/pythonProject/langchain-app/zhipuai.py", line 1, in <module>
import zhipuai
File "/mnt/e/Projects/pythonProject/langchain-app/zhipuai.py", line 4, in <module>
response = zhipuai.model_api.sse_invoke(
AttributeError: partially initialized module 'zhipuai' has no attribute 'model_api' (most likely due to a circular import)
依赖:
zhipuai = 1.0.7
希望用一个asyncio的API
就类似 OPENAI那样
async def create_chat_completion():
chat_completion_resp = await openai.ChatCompletion.acreate(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hello world"}])
zhipuai.core._errors.APITimeoutError: Request Timeout
zhipuai.core._errors.APITimeoutError: Request Timeout这个错误是为什么产生的?代码并没有变化,时隔几天再次调用的时候就报错了。请问一下有什么解决办法吗?还是类似openai通过设置代理来进行解决?
AttributeError: module 'zhipuai' has no attribute 'model_api'
import zhipuai
response = zhipuai.model_api.invoke(
model=model,
messages=messages,
temperature=0.5,
top_p=0.7,
incremental=True
)
IDE:
pycharm
error:
AttributeError: module 'zhipuai' has no attribute 'model_api'
已看:
Successfully installed zhipuai-1.0.7
pip list里面也是zhipuai-1.0.7
不知道为什么显示没有model_api???
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.