ysharma HF staff commited on
Commit
4e54cd8
·
1 Parent(s): 1b8cd19
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -34,7 +34,7 @@ A: Let’s think step by step.
34
 
35
  def text_generate(prompt, generated_txt): #, input_prompt_sql ): #, input_prompt_dalle2):
36
 
37
- print(f"*****Inside poem_generate - Prompt is :{prompt}")
38
  #if input_prompt_sql != '':
39
  # prompt = input_prompt_sql #"Instruction: Given an input question, respond with syntactically correct PostgreSQL\nInput: " +input_prompt_sql + "\nPostgreSQL query: "
40
  #elif input_prompt_dalle2 !='':
@@ -56,10 +56,10 @@ def text_generate(prompt, generated_txt): #, input_prompt_sql ): #, input_prompt
56
  response = requests.post(API_URL, headers=headers, json=json_)
57
  print(f"Response is : {response}")
58
  output = response.json()
59
- print(f"output is : {output}") #{output}")
60
  output_tmp = output[0]['generated_text']
61
  print(f"output_tmp is: {output_tmp}")
62
- solution = output_tmp.split("\nQ:")[0] #output[0]['generated_text'].split("Q:")[0] # +"."
63
  print(f"Final response after splits is: {solution}")
64
  if '\nOutput:' in solution:
65
  final_solution = solution.split("\nOutput:")[0]
@@ -88,6 +88,17 @@ def text_generate(prompt, generated_txt): #, input_prompt_sql ): #, input_prompt
88
  new_prompt = final_solution[len(prompt):]
89
  print(f"new prompt for next cycle is : {new_prompt}")
90
  print(f"display_output for printing on screen is : {display_output}")
 
 
 
 
 
 
 
 
 
 
 
91
  return display_output, new_prompt #generated_txt+prompt #final_solution
92
 
93
 
 
34
 
35
  def text_generate(prompt, generated_txt): #, input_prompt_sql ): #, input_prompt_dalle2):
36
 
37
+ print(f"*****Inside text_generate - Prompt is :{prompt}")
38
  #if input_prompt_sql != '':
39
  # prompt = input_prompt_sql #"Instruction: Given an input question, respond with syntactically correct PostgreSQL\nInput: " +input_prompt_sql + "\nPostgreSQL query: "
40
  #elif input_prompt_dalle2 !='':
 
56
  response = requests.post(API_URL, headers=headers, json=json_)
57
  print(f"Response is : {response}")
58
  output = response.json()
59
+ print(f"output is : {output}")
60
  output_tmp = output[0]['generated_text']
61
  print(f"output_tmp is: {output_tmp}")
62
+ solution = output_tmp.split("\nQ:")[0]
63
  print(f"Final response after splits is: {solution}")
64
  if '\nOutput:' in solution:
65
  final_solution = solution.split("\nOutput:")[0]
 
88
  new_prompt = final_solution[len(prompt):]
89
  print(f"new prompt for next cycle is : {new_prompt}")
90
  print(f"display_output for printing on screen is : {display_output}")
91
+ if len(new_prompt) == 0:
92
+ temp_text = display_output[::-1]
93
+ if temp_text[0] == '.':
94
+ first_period_loc = temp_text[1:].find('.')
95
+ new_prompt = display_output[:-first_period_loc]
96
+ print(f"Not sending blank as prompt so new prompt for next cycle is : {new_prompt}")
97
+ else:
98
+ first_period_loc = temp_text.find('.')
99
+ new_prompt = display_output[:-first_period_loc]
100
+ print(f"Not sending blank as prompt so new prompt for next cycle is : {new_prompt}")
101
+
102
  return display_output, new_prompt #generated_txt+prompt #final_solution
103
 
104