THUDM / ChatGLM2-6B

ChatGLM2-6B: An Open Bilingual Chat LLM | 开源双语对话语言模型
Other
15.69k stars 1.85k forks source link

[BUG/Help] <title>openai_api.py Pydantic version issue #341

Open 7801943 opened 1 year ago

7801943 commented 1 year ago

Is there an existing issue for this?

Current Behavior

D:/PythonProjects/my_glm2-6b/ChatGLM2-6B/openai_api.py:173: PydanticDeprecatedSince20: The json method is deprecated; use model_dump_json instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.0.3/migration/ yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False)) ERROR: Exception in ASGI application

Expected Behavior

none

Steps To Reproduce

Name: pydantic Version: 2.0.3

Environment

- OS: windows10
- Python: 3.8
- Transformers: 4.30.2
- PyTorch: 1.13.0+cu116
- CUDA Support (`python -c "import torch; print(torch.cuda.is_available())"`) :

Anything else?

https://github.com/THUDM/ChatGLM2-6B/issues/308 don't work

replace yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False)) with json.dumps(chunk.model_dump(exclude_unset=True), ensure_ascii=False) works

lissettecarlr commented 1 year ago

yield "{}".format(chunk.model_dump_json(exclude_unset=True))