PaddlePaddle / ERNIE-SDK

ERNIE Bot Agent is a Large Language Model (LLM) Agent Framework, powered by the advanced capabilities of ERNIE Bot and the platform resources of Baidu AI Studio.
http://ernie-bot-agent.readthedocs.io/
Apache License 2.0
328 stars 49 forks source link

README中关于提取语义向量部分,示例代码有误 #40

Closed SWHL closed 8 months ago

SWHL commented 9 months ago

运行环境

erniebot 0.3.1
python 3.10

运行代码

import erniebot

erniebot.api_type = 'aistudio'
erniebot.access_token = '<access-token-for-aistudio>'

response = erniebot.Embedding.create(
    model='ernie-text-embedding',
    input=[
        "我是百度公司开发的人工智能语言模型,我的中文名是文心一言,英文名是ERNIE-Bot,可以协助您完成范围广泛的任务并提供有关各种主题的信息,比如回答问题,提供定义和解释及建议。如果您有任何问题,请随时向我提问。",
        "2018年深圳市各区GDP"
        ])

print(response.get_result())

报错信息

(py310) ➜  ✗ python test_erniebot.py
Traceback (most recent call last):
  File "/Users/xxxx/opt/miniconda3/envs/py310/lib/python3.10/site-packages/erniebot/response.py", line 120, in __getattr__
    val = self.__dict[key]
KeyError: 'get_result'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/xxxx/projects/Knowledge-QA-LLM/test_erniebot.py", line 36, in <module>
    print(response.get_result())
  File "/Users/xxxx/opt/miniconda3/envs/py310/lib/python3.10/site-packages/erniebot/response.py", line 123, in __getattr__
    raise AttributeError
AttributeError
Bobholamovic commented 8 months ago

你好, get_result 是develop分支近期新增的功能,如果你使用的是pip源安装的release版本的话,应该还不支持这个功能。请查看release分支对应的文档

SWHL commented 8 months ago

OK,了解了。