mistpe commited on
Commit
1e195f3
1 Parent(s): ea51a4f

Rename app (1).py to app.py

Browse files
Files changed (1) hide show
  1. app (1).py → app.py +0 -76
app (1).py → app.py RENAMED
@@ -101,82 +101,6 @@ def process_function_call(function_name, function_args):
101
  def index():
102
  return send_from_directory('.', 'index.html')
103
 
104
- # @app.route('/chat', methods=['POST'])
105
- # def chat():
106
- # data = request.json
107
- # question = data['question']
108
- # history = data.get('history', [])
109
- # messages = history + [{"role": "user", "content": question}]
110
-
111
- # status_log = []
112
-
113
- # # 次级模型1: 处理搜索相关函数
114
- # status_log.append("次级模型1:正在判断是否需要选调第一组函数")
115
- # sub_model_1_response = get_openai_response(messages, model="gpt-4o-mini", functions=FUNCTIONS_GROUP_1, function_call="auto")
116
-
117
- # # 次级模型2: 处理邮件发送相关函数
118
- # status_log.append("次级模型2:正在判断是否需要选调第二组函数")
119
- # sub_model_2_response = get_openai_response(messages, model="gpt-4o-mini", functions=FUNCTIONS_GROUP_2, function_call="auto")
120
-
121
- # function_call_1 = sub_model_1_response.function_call if sub_model_1_response and sub_model_1_response.function_call else None
122
- # function_call_2 = sub_model_2_response.function_call if sub_model_2_response and sub_model_2_response.function_call else None
123
-
124
- # final_function_call = None
125
- # response = None
126
- # if function_call_1 and function_call_2:
127
- # # 裁决模型: 决定使用哪个函数调用
128
- # status_log.append("裁决模型:正在决定使用哪个函数调用")
129
- # arbitration_messages = messages + [
130
- # {"role": "system", "content": "两个次级模型都建议使用函数。请决定使用哪个函数更合适。"},
131
- # {"role": "assistant", "content": f"次级模型1建议使用函数:{function_call_1.name}"},
132
- # {"role": "assistant", "content": f"次级模型2建议使用函数:{function_call_2.name}"}
133
- # ]
134
- # arbitration_response = get_openai_response(arbitration_messages, model="gpt-4o-mini")
135
- # if "模型1" in arbitration_response.content or function_call_1.name in arbitration_response.content:
136
- # final_function_call = function_call_1
137
- # status_log.append(f"裁决模型:决定使用函数 {function_call_1.name}")
138
- # else:
139
- # final_function_call = function_call_2
140
- # status_log.append(f"裁决模型:决定使用函数 {function_call_2.name}")
141
- # elif function_call_1:
142
- # final_function_call = function_call_1
143
- # status_log.append(f"次级模型1:决定使用函数 {function_call_1.name}")
144
- # elif function_call_2:
145
- # final_function_call = function_call_2
146
- # status_log.append(f"次级模型2:决定使用函数 {function_call_2.name}")
147
- # else:
148
- # status_log.append("次级模型:判断不需要进行搜索或发送邮件")
149
-
150
- # if final_function_call:
151
- # function_name = final_function_call.name
152
- # function_args = json.loads(final_function_call.arguments)
153
- # status_log.append(f"正在执行函数 {function_name}")
154
- # result = process_function_call(function_name, function_args)
155
- # status_log.append(f"函数 {function_name} 执行完成")
156
-
157
- # # 检查是否为邮件发送功能
158
- # result_dict = json.loads(result)
159
- # if result_dict.get("is_email", False):
160
- # response = f"邮件{'已成功' if result_dict['success'] else '未能成功'}发送到 {result_dict['to']}。\n\n主题:{result_dict['subject']}\n\n内容:\n{result_dict['content']}"
161
- # else:
162
- # messages.append({
163
- # "role": "function",
164
- # "name": function_name,
165
- # "content": result
166
- # })
167
-
168
- # # 只有在没有邮件发送结果时才调用主模型
169
- # if not response:
170
- # status_log.append("主模型:正在生成回答")
171
- # final_response = get_openai_response(messages, model="gpt-4o-mini")
172
- # response = final_response.content if final_response else "Error occurred"
173
- # status_log.append("主模型:回答生成完成")
174
-
175
- # return jsonify({
176
- # "response": response,
177
- # "status_log": status_log
178
- # })
179
-
180
  @app.route('/chat', methods=['POST'])
181
  def chat():
182
  data = request.json
 
101
  def index():
102
  return send_from_directory('.', 'index.html')
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  @app.route('/chat', methods=['POST'])
105
  def chat():
106
  data = request.json