Vitrous commited on
Commit
c67a47b
·
verified ·
1 Parent(s): 2f8f3d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -91,10 +91,11 @@ def generate_prompt_response(persona_prompt: str, prompt: str) -> dict:
91
  )
92
  generated_text = pipe(persona_prompt + user_prompt)[0]['generated_text']
93
 
94
- # Extract only the assistant's response from the generated text
95
- assistant_response = generated_text.split(user_prompt)[-1].strip()
96
-
97
- return {"user": prompt,"assistant": assistant_response}
 
98
 
99
  except Exception as e:
100
  # Handle any exceptions and return an error message
 
91
  )
92
  generated_text = pipe(persona_prompt + user_prompt)[0]['generated_text']
93
 
94
+ # Remove the "ASSISTANT:" prefix from the generated text
95
+ assistant_response = generated_text.replace("ASSISTANT:", "").strip()
96
+
97
+ # Return the user prompt and assistant's response as a dictionary
98
+ return {"user": prompt, "assistant": assistant_response}
99
 
100
  except Exception as e:
101
  # Handle any exceptions and return an error message