rishiraj commited on
Commit
a1375ca
1 Parent(s): 16defe0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -42,11 +42,10 @@ def search(url):
42
 
43
  def format_prompt(message, history, cust_p):
44
  prompt = ""
45
- if history:
46
- for user_prompt, bot_response in history:
47
- prompt += f"<start_of_turn>user{user_prompt}<end_of_turn>"
48
- prompt += f"<start_of_turn>model{bot_response}<end_of_turn>"
49
- prompt+=cust_p.replace("USER_INPUT",message)
50
  return prompt
51
 
52
  def generate(
@@ -73,13 +72,13 @@ def generate(
73
  prompt = prompt.replace(image, image_description)
74
  print(prompt)
75
  formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history, custom_prompt)
76
- stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=True)
77
  output = ""
 
78
  for response in stream:
79
  output += response.token.text
80
- yield [(prompt,output)]
81
- history.append((prompt,output))
82
- yield history
83
 
84
 
85
  additional_inputs=[
 
42
 
43
  def format_prompt(message, history, cust_p):
44
  prompt = ""
45
+ for user_prompt, bot_response in history:
46
+ prompt += f"<start_of_turn>user{user_prompt}<end_of_turn>"
47
+ prompt += f"<start_of_turn>model{bot_response}<end_of_turn>"
48
+ prompt += cust_p.replace("USER_INPUT",message)
 
49
  return prompt
50
 
51
  def generate(
 
72
  prompt = prompt.replace(image, image_description)
73
  print(prompt)
74
  formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history, custom_prompt)
75
+ stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
76
  output = ""
77
+
78
  for response in stream:
79
  output += response.token.text
80
+ yield output
81
+ return output
 
82
 
83
 
84
  additional_inputs=[