Git Product home page Git Product logo

Comments (5)

upbit avatar upbit commented on August 28, 2024 1

+1。2.x设计上貌似更接近openai v2的设计了,stream=Truechoices/delta。目前有什么简单方式可以复用的吗?
比如LangChain的ChatZhipuAI就不能用了,还得自己从ChatOpenAI复制一份

另外,2.x的zhipuai依赖 pydantic==2.5.3,这个和大多数库(比如langchain)需求的1.x不兼容,遇到会非常难搞。。

from zhipuai-sdk-python.

upbit avatar upbit commented on August 28, 2024

+1。2.x设计上貌似更接近openai v2的设计了,stream=Truechoices/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.

shinjiyu avatar shinjiyu commented on August 28, 2024

官方文档的chatglm demo 还是基于1.X的。
我现在是pip install zhipuai==1.0.7 强制安装上一个版本。

from zhipuai-sdk-python.

luoling1993 avatar luoling1993 commented on August 28, 2024

其实好像修改下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.

Ikaros-521 avatar Ikaros-521 commented on August 28, 2024

插眼

from zhipuai-sdk-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.