You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I copy the API key in the control panel bailian.console.alibabacloud.com
Paste it into *.py code
import urllib.parse
import json5
from qwen_agent.agents import Assistant
from qwen_agent.tools.base import BaseTool, register_tool
llm_cfg = {
# Use the model service provided by DashScope:
'model': 'qwen2.5-72b-instruct',
'model_server': 'dashscope',
'api_key': "sk-aec*******************7b1f01",
# (Optional) LLM hyperparameters for generation:
'generate_cfg': {
'top_p': 0.8
}
}
# Step 3: Create an agent. Here we use the `Assistant` agent as an example, which is capable of using tools and reading files.
...
Get an error message
λ python qwen.py
user query: test
Traceback (most recent call last):
File "C:\qwen\qwen.py", line 43, in <module>
for response in bot.run(messages=messages):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\agent.py", line 94, in run
for rsp in self._run(messages=new_messages, **kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\agents\assistant.py", line 99, in _run
new_messages = self._prepend_knowledge_prompt(messages=messages, lang=lang, knowledge=knowledge, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\agents\assistant.py", line 110, in _prepend_knowledge_prompt
*_, last = self.mem.run(messages=messages, lang=lang, **kwargs)
^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\agent.py", line 94, in run
for rsp in self._run(messages=new_messages, **kwargs):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\memory\memory.py", line 97, in _run
for last in response:
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\agent.py", line 94, in run
for rsp in self._run(messages=new_messages, **kwargs):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\llm\base.py", line 347, in _convert_messages_iterator_to_target_type
for messages in messages_iter:
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\llm\base.py", line 235, in _format_and_cache
for o in output:
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\llm\base.py", line 331, in _postprocess_messages_iterator
for pre_msg in messages:
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\llm\base.py", line 503, in retry_model_service_iterator
num_retries, delay = _raise_or_delay(e, num_retries, delay, max_retries)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\llm\base.py", line 517, in _raise_or_delay
raise e
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\llm\base.py", line 498, in retry_model_service_iterator
for rsp in it_fn():
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\qwen_agent\llm\qwen_dashscope.py", line 111, in _full_stream_output
raise ModelServiceError(code=chunk.code, message=chunk.message)
qwen_agent.llm.base.ModelServiceError:
Error code: InvalidApiKey. Error message: Invalid API-key provided.
What did i do wrong?
The text was updated successfully, but these errors were encountered:
instead of the "dashscope" you had to write the server URL
# Use the model service provided by DashScope:
'model': 'qwen2.5-72b-instruct',
'model_server': 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1',
'api_key': "sk-aec******************7b1f01",
# (Optional) LLM hyperparameters for generation:
'generate_cfg': {
'top_p': 0.8
}
}
What did i do wrong?
The text was updated successfully, but these errors were encountered: