Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,8 @@ try:
|
|
31 |
model_path=MODEL_PATH,
|
32 |
n_ctx=512, # β
Lower memory usage, speeds up responses
|
33 |
n_threads=2, # Matches available vCPUs
|
34 |
-
numa=True
|
|
|
35 |
)
|
36 |
st.write("β
Model loaded successfully!")
|
37 |
except Exception as e:
|
@@ -64,24 +65,27 @@ if st.button("Send") and user_input:
|
|
64 |
# β
Use a minimal prompt format (no system message)
|
65 |
formatted_messages = [{"role": "user", "content": user_input}]
|
66 |
|
67 |
-
# β
|
68 |
response_data = st.session_state["model"].create_chat_completion(
|
69 |
messages=formatted_messages,
|
70 |
-
max_tokens=
|
71 |
-
stream=
|
72 |
)
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
|
86 |
|
87 |
|
|
|
31 |
model_path=MODEL_PATH,
|
32 |
n_ctx=512, # β
Lower memory usage, speeds up responses
|
33 |
n_threads=2, # Matches available vCPUs
|
34 |
+
numa=True,
|
35 |
+
n_batch=32 # β
Faster token processing
|
36 |
)
|
37 |
st.write("β
Model loaded successfully!")
|
38 |
except Exception as e:
|
|
|
65 |
# β
Use a minimal prompt format (no system message)
|
66 |
formatted_messages = [{"role": "user", "content": user_input}]
|
67 |
|
68 |
+
# β
Disable streaming for debugging
|
69 |
response_data = st.session_state["model"].create_chat_completion(
|
70 |
messages=formatted_messages,
|
71 |
+
max_tokens=128, temperature=0.7, top_p=0.9,
|
72 |
+
stream=False # β Disabled streaming for debugging
|
73 |
)
|
74 |
|
75 |
+
# β
Debugging output
|
76 |
+
st.write("π Debug: Raw Model Response:", response_data)
|
77 |
+
|
78 |
+
if "choices" in response_data and len(response_data["choices"]) > 0:
|
79 |
+
choice = response_data["choices"][0]
|
80 |
+
if "message" in choice and "content" in choice["message"]:
|
81 |
+
response_text = choice["message"]["content"].strip()
|
82 |
+
st.session_state["messages"].append(("assistant", response_text))
|
83 |
+
st.chat_message("assistant").write(response_text)
|
84 |
+
else:
|
85 |
+
st.error("β οΈ No valid response content found.")
|
86 |
+
else:
|
87 |
+
st.error("β οΈ Model did not return any choices.")
|
88 |
+
|
89 |
|
90 |
|
91 |
|