Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用官网Websocket API访问方式,报错issubclass() arg 1 must be a class,详情如下 #49

Open
Eyict opened this issue Aug 26, 2024 · 4 comments

Comments

@Eyict
Copy link

Eyict commented Aug 26, 2024

官网代码
from sparkai.llm.llm import ChatSparkLLM, ChunkPrintHandler
from sparkai.core.messages import ChatMessage

#星火认知大模型Spark Max的URL值,其他版本大模型URL值请前往文档(https://www.xfyun.cn/doc/spark/Web.html)查看
SPARKAI_URL = 'wss://spark-api.xf-yun.com/v3.5/chat'
#星火认知大模型调用秘钥信息,请前往讯飞开放平台控制台(https://console.xfyun.cn/services/bm35)查看
SPARKAI_APP_ID = ''
SPARKAI_API_SECRET = ''
SPARKAI_API_KEY = ''
#星火认知大模型Spark Max的domain值,其他版本大模型domain值请前往文档(https://www.xfyun.cn/doc/spark/Web.html)查看
SPARKAI_DOMAIN = 'generalv3.5'

if name == 'main':
spark = ChatSparkLLM(
spark_api_url=SPARKAI_URL,
spark_app_id=SPARKAI_APP_ID,
spark_api_key=SPARKAI_API_KEY,
spark_api_secret=SPARKAI_API_SECRET,
spark_llm_domain=SPARKAI_DOMAIN,
streaming=False,
)
messages = [ChatMessage(
role="user",
content='你好呀'
)]
handler = ChunkPrintHandler()
a = spark.generate([messages], callbacks=[handler])
print(a)
报错信息:
TypeError: issubclass() arg 1 must be a class
ERROR conda.cli.main_run:execute(124): conda run python /mnt/e/PycharmProjects/ToolBench/toolbench/inference/LLM/spark_websocket.py failed. (See above for error)

@Eyict
Copy link
Author

Eyict commented Aug 26, 2024

请问这个包具体是修复什么错误的?我这边系统将其识别为病毒,无法安装

@Eyict
Copy link
Author

Eyict commented Aug 26, 2024

好像确实是环境杂乱导致的,新建一个环境后就可以使用了

@Awyoeng
Copy link

Awyoeng commented Aug 27, 2024

可能是websocket的版本不对?
此项目的.toml配置文件指出,可支持1.7.0向上兼容(主版本1.X都可以?)实际上1.8.0都跑不了)
必须严格要求1.7.0
我试运行的脚本是:./test/llm_test.py
环境是通过poetry管理的
依赖1.8.0的时候报错如下:
Exception in thread Thread-1 (run):
Traceback (most recent call last):
File "C:\Users\yiouyang5\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\yiouyang5\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "D:\Projct\spark-ai-python-main\sparkai\llm\llm.py", line 526, in run
self.client.enableTrace(False)
AttributeError: module 'websocket' has no attribute 'enableTrace'

会发现这个错误指出 websocket 模块没有 enableTrace 这个方法。
能力有限我不知道这两个问题有没有联系

@whybeyoung
Copy link
Contributor

@Awyoeng 我在conda环境下测试并没有此问题, check下?用的 1.8.0版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@whybeyoung @Eyict @Awyoeng and others