Spaces:
Sleeping
Sleeping
convert everything to string
Browse files
app.py
CHANGED
@@ -22,8 +22,12 @@ def authenticate_and_generate(token, message, history, system_message, max_token
|
|
22 |
# Initialize the text-generation pipeline with the provided token
|
23 |
text_generator = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", use_auth_token=hf_token, trust_remote_code=True)
|
24 |
|
|
|
|
|
|
|
25 |
# Construct the prompt with system message, history, and user input
|
26 |
-
|
|
|
27 |
prompt += f"\nUser: {message}\nAssistant:"
|
28 |
|
29 |
# Generate a response using the model
|
|
|
22 |
# Initialize the text-generation pipeline with the provided token
|
23 |
text_generator = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", use_auth_token=hf_token, trust_remote_code=True)
|
24 |
|
25 |
+
# Ensure that system_message is a string
|
26 |
+
system_message = str(system_message)
|
27 |
+
|
28 |
# Construct the prompt with system message, history, and user input
|
29 |
+
history_str = "\n".join([f"User: {str(msg[0])}\nAssistant: {str(msg[1])}" for msg in history if str(msg[0]) and str(msg[1])])
|
30 |
+
prompt = system_message + "\n" + history_str
|
31 |
prompt += f"\nUser: {message}\nAssistant:"
|
32 |
|
33 |
# Generate a response using the model
|