修改chat为openai
This commit is contained in:
parent
08acbdf45d
commit
002a1e038f
@ -8,14 +8,14 @@ from app.models.requirement import Requirement
|
||||
from app.utils.common_util import SuccessData
|
||||
from app.core.security import get_current_user
|
||||
|
||||
client = OpenAI(
|
||||
api_key="sk-P7bm1Ioe7eovIWkbabAbY8yEON2VFu4RcHqumAFCfoxDVDdi",
|
||||
base_url="https://api.lkeap.cloud.tencent.com/v1"
|
||||
)
|
||||
# client = OpenAI(
|
||||
# api_key="sk-56a83c7c71a5459ea181bc86f0a42af9",
|
||||
# base_url="https://api.deepseek.com/chat/completions"
|
||||
# api_key="sk-P7bm1Ioe7eovIWkbabAbY8yEON2VFu4RcHqumAFCfoxDVDdi",
|
||||
# base_url="https://api.lkeap.cloud.tencent.com/v1"
|
||||
# )
|
||||
client = OpenAI(
|
||||
api_key="sk-328795a17fdc4a75b993f7ca5445593a",
|
||||
base_url="https://api.deepseek.com"
|
||||
)
|
||||
|
||||
|
||||
class WorkScore(BaseModel):
|
||||
@ -56,7 +56,7 @@ async def work_chat(work_score: WorkScore,
|
||||
print(">>> prompt: \n%s" % prompt)
|
||||
messages = [{'role': 'user', 'content': prompt}]
|
||||
stream = client.chat.completions.create(
|
||||
model="deepseek-r1",
|
||||
model="deepseek-chat",
|
||||
messages=messages,
|
||||
stream=True
|
||||
)
|
||||
@ -65,6 +65,7 @@ async def work_chat(work_score: WorkScore,
|
||||
answer_content = "" # 定义完整回复
|
||||
is_answering = False # 判断是否结束思考过程并开始回复
|
||||
for chunk in stream:
|
||||
print(chunk)
|
||||
if not getattr(chunk, 'choices', None):
|
||||
print("\n" + "=" * 20 + "Token 使用情况" + "=" * 20 + "\n")
|
||||
print(chunk.usage)
|
||||
|
Loading…
Reference in New Issue
Block a user