Files
dsProject/dsLightRag/Test/TestCode.py
2025-08-14 15:45:08 +08:00

29 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
from openai import OpenAI
from Config.Config import ALY_LLM_API_KEY
client = OpenAI(
api_key=ALY_LLM_API_KEY,
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
content="""
1. 开发一个html5的页面代码
2. 左侧实时仿真实验区:可拖拽改变物体密度、液体密度,参数可以实时改变物体浮沉状态;物体用小方块来模拟即可。
3. 右侧动态受力图:用箭头实时显示重力与浮力大小关系;
4. 生活案例切换:潜水艇、热气球、死海漂浮,一键切换并自动带入对应参数;
5. 公式与结论区:根据实时数据高亮对应的浮沉条件;
6. 纯前端实现HTML5 + ES6无需任何外部库复制即用。
"""
completion = client.chat.completions.create(
model="qwen3-coder-plus",
messages=[
{'role': 'system', 'content': 'You are a helpful assistant.'},
{'role': 'user', 'content': content}],
)
print("="*20+"回复内容"+"="*20)
print(completion.choices[0].message.content)
print("="*20+"Token消耗"+"="*20)
print(completion.usage)