Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -56,10 +56,16 @@ if st.button("Send") and user_input:
|
|
56 |
st.session_state["messages"].append(("user", user_input))
|
57 |
st.chat_message("user").write(user_input)
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
# Generate response
|
60 |
try:
|
61 |
response = st.session_state["model"].create_chat_completion(
|
62 |
-
messages=
|
63 |
max_tokens=1024, temperature=0.7, top_p=0.9
|
64 |
)
|
65 |
response_text = response["choices"][0]["message"]["content"].strip()
|
@@ -75,3 +81,4 @@ if st.button("Send") and user_input:
|
|
75 |
|
76 |
|
77 |
|
|
|
|
56 |
st.session_state["messages"].append(("user", user_input))
|
57 |
st.chat_message("user").write(user_input)
|
58 |
|
59 |
+
# ✅ Format messages using Phi-3 chat template
|
60 |
+
formatted_messages = [
|
61 |
+
{"role": "system", "content": "You are an AI assistant. Provide clear and concise answers."}
|
62 |
+
]
|
63 |
+
formatted_messages += [{"role": "user", "content": user_input}]
|
64 |
+
|
65 |
# Generate response
|
66 |
try:
|
67 |
response = st.session_state["model"].create_chat_completion(
|
68 |
+
messages=formatted_messages,
|
69 |
max_tokens=1024, temperature=0.7, top_p=0.9
|
70 |
)
|
71 |
response_text = response["choices"][0]["message"]["content"].strip()
|
|
|
81 |
|
82 |
|
83 |
|
84 |
+
|