Cudd1es commited on
Commit
e595bf1
·
1 Parent(s): 1369018

fixed app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -7,8 +7,8 @@ from retriever import (
7
  )
8
  from sentence_transformers import CrossEncoder
9
 
10
- api_key = os.getenv("OPENAI_API_KEY")
11
- client = OpenAI(api_key=api_key)
12
 
13
  collection = load_collection()
14
  encoder = load_encoder()
@@ -22,7 +22,13 @@ def build_rag_prompt(query, context, system_message):
22
  {context}
23
 
24
  用户提问:{query}
25
- 请参考所有已知资料, 并结合资料内容,简明、准确地回答问题。如果有多个符合的答案, 可以根据你是否确定而决定是否分别陈述这些答案.如果不能确定答案,请如实说明理由,不要凭空编造。"""
 
 
 
 
 
 
26
  return prompt
27
 
28
 
@@ -58,7 +64,7 @@ def respond(
58
 
59
  response = ""
60
  stream = client.chat.completions.create(
61
- model="gpt-4o",
62
  messages=messages,
63
  temperature=temperature,
64
  max_tokens=max_tokens,
@@ -96,7 +102,6 @@ chatbot = gr.ChatInterface(
96
  ),
97
  ],
98
  examples=[
99
- ["乐奈喜欢什么?"],
100
  ["在水族馆里爱音和灯发生了什么?"],
101
  ["RAS的目标是什么?"],
102
  ],
 
7
  )
8
  from sentence_transformers import CrossEncoder
9
 
10
+ api_key = os.getenv("OPENROUTER_API_KEY")
11
+ client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=api_key)
12
 
13
  collection = load_collection()
14
  encoder = load_encoder()
 
22
  {context}
23
 
24
  用户提问:{query}
25
+
26
+ 规则:
27
+ 1. 请参考所有已知资料, 并结合资料内容,简明、准确地回答问题。
28
+ 2. 如果有多个符合的答案, 可以根据你是否确定而决定是否分别陈述这些答案.
29
+ 3. 如果有多个可能性, 可以自行判断是否将其全部列举和解释
30
+ 4. 如果不能确定答案,请如实说明理由,不要凭空编造。
31
+ """
32
  return prompt
33
 
34
 
 
64
 
65
  response = ""
66
  stream = client.chat.completions.create(
67
+ model="qwen/qwen3-235b-a22b:free",
68
  messages=messages,
69
  temperature=temperature,
70
  max_tokens=max_tokens,
 
102
  ),
103
  ],
104
  examples=[
 
105
  ["在水族馆里爱音和灯发生了什么?"],
106
  ["RAS的目标是什么?"],
107
  ],