Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions server/llm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
from openai import OpenAI


model_name = "qwen2.5-72b-instruct" # qwen-plus, 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
url = "https://dashscope.aliyuncs.com/compatible-mode/v1"
api_key = "" # 阿里云 API Key
model_name = "gemini-1.5-flash" # gemini model; 更多参考:https://ai.google.dev/gemini-api/docs/models/gemini-v2?hl=zh-cn
api_key = "" # Gemini API Key
url = "https://generativelanguage.googleapis.com/v1beta/"
# model_name = "qwen2.5-72b-instruct" # qwen-plus, 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
# url = "https://dashscope.aliyuncs.com/compatible-mode/v1"
# api_key = "" # 阿里云 API Key


class LLMClient(object):
Expand All @@ -17,7 +20,7 @@ def get_response_by_api(
prompt: str,
) -> str:
messages = [
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
{"role": "system", "content": "You are Gemini, created by Google. You are a helpful assistant."},
{"role": "user", "content": prompt}
]
client = OpenAI(
Expand Down Expand Up @@ -53,4 +56,4 @@ def walk_to_random_item(

if __name__ == "__main__":
res = LLMClient.get_response_by_api("你好")
print(res)
print(res)