mdh98 commited on
Commit
9308ac3
·
verified ·
1 Parent(s): cd6ca11

Upload inference_messages_32.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. inference_messages_32.py +3 -2
inference_messages_32.py CHANGED
@@ -44,7 +44,7 @@ def check_answer(response, answer):
44
  response = response.strip(char)
45
  response = " " + response.lower() + " " # 添加空格并将响应转换为小写,以避免大小写问题
46
 
47
-
48
  # 使用正则表达式提取 <answer>: 后面的第一个字母
49
  match = re.search(r'<answer>: (\w)', response) # \w 匹配字母或数字,这里主要提取字母
50
  if match:
@@ -105,10 +105,11 @@ def process_record(rec, args):
105
  api_key=args.api_key
106
  )
107
  try:
108
- response = client.messages.create.create(
109
  model=args.model_name,
110
  messages=messages,
111
  max_tokens=args.max_tokens,
 
112
  )
113
  prediction = response.choices[0].message.content.strip()
114
  except Exception as e:
 
44
  response = response.strip(char)
45
  response = " " + response.lower() + " " # 添加空格并将响应转换为小写,以避免大小写问题
46
 
47
+ import re
48
  # 使用正则表达式提取 <answer>: 后面的第一个字母
49
  match = re.search(r'<answer>: (\w)', response) # \w 匹配字母或数字,这里主要提取字母
50
  if match:
 
105
  api_key=args.api_key
106
  )
107
  try:
108
+ response = client.messages.create(
109
  model=args.model_name,
110
  messages=messages,
111
  max_tokens=args.max_tokens,
112
+ timeout=120 # 秒
113
  )
114
  prediction = response.choices[0].message.content.strip()
115
  except Exception as e: