debisoft commited on
Commit
99689f6
·
1 Parent(s): 675467d
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -67,13 +67,8 @@ def extract_json(gen_text, response, n_shot_learning=0):
67
  start_index = gen_text.index("### Response:\n{") + 14
68
 
69
  end_index = gen_text.find("}\n\n### ")
70
- if(end_index == -1) :
71
- print("Start***No end index!!!")
72
- print(response.status_code)
73
- print(response.txt)
74
- print("End***No end index!!!")
75
-
76
- end_index = end_index + 1
77
 
78
  return gen_text[start_index:end_index]
79
 
@@ -96,7 +91,15 @@ def score_model(model_uri, databricks_token, prompt):
96
  response = requests.request(method='POST', headers=headers, url=model_uri, data=data_json)
97
  if response.status_code != 200:
98
  raise Exception(f"Request failed with status {response.status_code}, {response.text}")
99
- return response.json()
 
 
 
 
 
 
 
 
100
 
101
  def get_completion(prompt):
102
  return score_model(model_uri, databricks_token, prompt)
 
67
  start_index = gen_text.index("### Response:\n{") + 14
68
 
69
  end_index = gen_text.find("}\n\n### ")
70
+ if(end_index != -1) :
71
+ end_index = end_index + 1
 
 
 
 
 
72
 
73
  return gen_text[start_index:end_index]
74
 
 
91
  response = requests.request(method='POST', headers=headers, url=model_uri, data=data_json)
92
  if response.status_code != 200:
93
  raise Exception(f"Request failed with status {response.status_code}, {response.text}")
94
+
95
+ response_json = response.json()
96
+
97
+ if(response_json["choices"] == "")
98
+ print("Start***No choices!!!")
99
+ print(response.status_code)
100
+ print(response.txt)
101
+ print("End***No choices!!!")
102
+ return response_json
103
 
104
  def get_completion(prompt):
105
  return score_model(model_uri, databricks_token, prompt)