Update app.py
Browse files
app.py
CHANGED
@@ -59,8 +59,9 @@ def chat_fn(message, history):
|
|
59 |
{
|
60 |
"role": "system",
|
61 |
"content": (
|
62 |
-
"You are a
|
63 |
-
"
|
|
|
64 |
"\n\nContext:\n" + context
|
65 |
)
|
66 |
}
|
@@ -70,12 +71,13 @@ def chat_fn(message, history):
|
|
70 |
messages.append({"role": "user", "content": user})
|
71 |
messages.append({"role": "assistant", "content": assistant})
|
72 |
|
73 |
-
|
|
|
74 |
|
75 |
payload = {
|
76 |
"model": MODEL,
|
77 |
"messages": messages,
|
78 |
-
"max_tokens":
|
79 |
}
|
80 |
|
81 |
try:
|
@@ -109,7 +111,7 @@ async def chat_api(request: Request):
|
|
109 |
demo = gr.ChatInterface(
|
110 |
fn=chat_fn,
|
111 |
title="💬 CODEX MIRXA KAMRAN",
|
112 |
-
description="Ask anything related to our knowledge base.
|
113 |
theme="soft"
|
114 |
)
|
115 |
|
|
|
59 |
{
|
60 |
"role": "system",
|
61 |
"content": (
|
62 |
+
"You are a precise, concise assistant. Use ONLY the provided context."
|
63 |
+
" Respond in 1–2 short sentences maximum. Do not explain unless asked."
|
64 |
+
" If unsure, say: 'I couldn’t find the answer based on available context.'"
|
65 |
"\n\nContext:\n" + context
|
66 |
)
|
67 |
}
|
|
|
71 |
messages.append({"role": "user", "content": user})
|
72 |
messages.append({"role": "assistant", "content": assistant})
|
73 |
|
74 |
+
# ✅ Encourage brevity in user input
|
75 |
+
messages.append({"role": "user", "content": message + "\n\nPlease answer briefly."})
|
76 |
|
77 |
payload = {
|
78 |
"model": MODEL,
|
79 |
"messages": messages,
|
80 |
+
"max_tokens": 150,
|
81 |
}
|
82 |
|
83 |
try:
|
|
|
111 |
demo = gr.ChatInterface(
|
112 |
fn=chat_fn,
|
113 |
title="💬 CODEX MIRXA KAMRAN",
|
114 |
+
description="Ask anything related to our knowledge base. Short, fast and precise answers!",
|
115 |
theme="soft"
|
116 |
)
|
117 |
|