Comments (5)
+1。2.x设计上貌似更接近openai v2的设计了,stream=True
和choices/delta
。目前有什么简单方式可以复用的吗?
比如LangChain的ChatZhipuAI就不能用了,还得自己从ChatOpenAI复制一份
另外,2.x的zhipuai依赖 pydantic==2.5.3
,这个和大多数库(比如langchain)需求的1.x不兼容,遇到会非常难搞。。
from zhipuai-sdk-python.
+1。2.x设计上貌似更接近openai v2的设计了,
stream=True
和choices/delta
。目前有什么简单方式可以复用的吗? 比如LangChain的ChatZhipuAI就不能用了,还得自己从ChatOpenAI复制一份另外,2.x的zhipuai依赖
pydantic==2.5.3
,这个和大多数库(比如langchain)需求的1.x不兼容,遇到会非常难搞。。
周末改了个支持 zhipuai v2.0.1 的 langchain 版本,目前流程是能通了(需要chat_zhipuai.py可以自取)。
希望能解决 pydantic v2 的依赖问题,不然都得学langchain去fork一份v1的代码放库里。
demo.mp4
from zhipuai-sdk-python.
官方文档的chatglm demo 还是基于1.X的。
我现在是pip install zhipuai==1.0.7 强制安装上一个版本。
from zhipuai-sdk-python.
其实好像修改下header的方式,用openai可以兼容了,不需要这个包了,将他的generate_token函数copy下就行了
def _init_client(self) -> None:
"""init internal client"""
if self._api_base == "https://open.bigmodel.cn/api/paas/v4":
# ZhipuAI兼容
from ._jwt_token import generate_token
client = OpenAI(
api_key=self.api_key,
base_url=self._api_base,
http_client=httpx.Client(proxies=self._proxy),
default_headers={"Authorization": generate_token(api_key=self._api_key)},
)
else:
client = OpenAI(
api_key=self._api_key,
base_url=self._api_base,
http_client=httpx.Client(proxies=self._proxy),
)
self._client = client
from zhipuai-sdk-python.
插眼
from zhipuai-sdk-python.
Related Issues (20)
- API有支持的Function Call的计划吗
- 劳烦给出异步调用后,如何接受真实的response HOT 3
- self._logger.debug("Dispatching %s...", event) HOT 1
- [1234][网络错误,错误id:8168867886816165954,请联系客服。]
- AttributeError: module 'zhipuai' has no attribute 'model_api' HOT 10
- 请问如何调用创建的应用? HOT 1
- 文件上传可否多元化?
- API 启动报错 401 HOT 1
- pydantic 依赖冲突 HOT 2
- zhipuai api 如何获取接口调用时间?
- 这个sdk已经废弃了吗
- zhipuai.core._errors.APITimeoutError: Request Timeout
- 是否需要OpenAI SDK的 ChatCompletion 包装?方便兼容其他LangChain等基于openai体系的应用? HOT 3
- 调用 ChatGLM-Pro API 接口进行多轮对话问题 HOT 2
- AttributeError: module 'zhipuai' has no attribute 'model_api' HOT 1
- 关于模型`prompt`参数列表长度为奇数的疑问。 HOT 3
- AttributeError: partially initialized module 'zhipuai' has no attribute 'model_api' (most likely due to a circular import)
- 希望用一个asyncio的API
- async_invoke输出如何获取content
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 zhipuai-sdk-python.