|
@@ -132,28 +132,30 @@ def get_article_gpt_pydantic(question, real_ip="localhost", demo_name="无", mod
|
|
|
|
|
|
check_result = check_fucn(str(answer))
|
|
|
if not check_result:
|
|
|
- logger.error(answer)
|
|
|
- raise Exception(f"忽略,第{num_count + 1}次共3次,GPT的校验没有通过,校验函数:{check_fucn.__name__}")
|
|
|
+ logger.warning(answer)
|
|
|
+ raise ValidationError(f"忽略,第{num_count + 1}次共3次,GPT的校验没有通过,校验函数:{check_fucn.__name__}")
|
|
|
|
|
|
|
|
|
simple_logger.info(f"问题日志task_id:{task_id},exercise_id:{exercise_id}\n回答日志:\n{r_json}")
|
|
|
return r_json
|
|
|
|
|
|
except ValidationError as e:
|
|
|
- logger.error(f"gpt回复校验失败task_id:{task_id},exercise_id:{exercise_id}:")
|
|
|
- logger.error(answer)
|
|
|
+ logger.warning(f"gpt回复校验失败task_id:{task_id},exercise_id:{exercise_id}:")
|
|
|
+ logger.warning(answer)
|
|
|
|
|
|
except requests.exceptions.RequestException as e:
|
|
|
- logger.error(f"HTTP请求错误task_id:{task_id},exercise_id:{exercise_id}: {str(e)}")
|
|
|
- time.sleep(1)
|
|
|
+ logger.warning(f"HTTP请求错误task_id:{task_id},exercise_id:{exercise_id}: {str(e)}")
|
|
|
+ time.sleep(3**num_count)
|
|
|
|
|
|
except json.decoder.JSONDecodeError as e:
|
|
|
if 'response' in locals() and response is not None:
|
|
|
- logger.error(f"json格式化错误task_id:{task_id},exercise_id:{exercise_id}:{response.text}")
|
|
|
+ logger.warning(f"json格式化错误task_id:{task_id},exercise_id:{exercise_id}:{response.text}")
|
|
|
|
|
|
except Exception as e:
|
|
|
log_err_e(e,f"其他错误task_id:{task_id},exercise_id:{exercise_id}")
|
|
|
|
|
|
+ logger.critical(f"严重错误,3次后未获得正确答案")
|
|
|
+
|
|
|
def get_annotation_gpt_pydantic(question, real_ip="localhost", demo_name="无", model="gpt-4.1", max_tokens=3500, temperature:float=0, n=1,
|
|
|
check_fucn=None, sys_prompt=None,task_id=0,exercise_id=0):
|
|
|
"""
|