Fixing system promt ? - What wind.surf will do ?
Browse files
app.py
CHANGED
@@ -50,7 +50,10 @@ def respond(
|
|
50 |
if current_model is None or model_name not in str(current_model.model_path):
|
51 |
current_model = load_model(model_name)
|
52 |
|
53 |
-
|
|
|
|
|
|
|
54 |
|
55 |
# Convert history to messages format
|
56 |
for msg in history:
|
@@ -62,21 +65,22 @@ def respond(
|
|
62 |
else:
|
63 |
messages.append(msg)
|
64 |
|
|
|
65 |
messages.append({"role": "user", "content": message})
|
66 |
|
67 |
-
|
68 |
response = current_model.create_chat_completion(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
75 |
message_repl = ""
|
76 |
for chunk in response:
|
77 |
if len(chunk['choices'][0]["delta"]) != 0 and "content" in chunk['choices'][0]["delta"]:
|
78 |
-
message_repl = message_repl +
|
79 |
-
chunk['choices'][0]["delta"]["content"]
|
80 |
yield message_repl
|
81 |
|
82 |
def get_chat_title(model_name):
|
|
|
50 |
if current_model is None or model_name not in str(current_model.model_path):
|
51 |
current_model = load_model(model_name)
|
52 |
|
53 |
+
# Start with system message
|
54 |
+
messages = []
|
55 |
+
if system_message and system_message.strip():
|
56 |
+
messages.append({"role": "system", "content": system_message})
|
57 |
|
58 |
# Convert history to messages format
|
59 |
for msg in history:
|
|
|
65 |
else:
|
66 |
messages.append(msg)
|
67 |
|
68 |
+
# Add current message
|
69 |
messages.append({"role": "user", "content": message})
|
70 |
|
71 |
+
# Generate response
|
72 |
response = current_model.create_chat_completion(
|
73 |
+
messages=messages,
|
74 |
+
stream=True,
|
75 |
+
max_tokens=max_tokens,
|
76 |
+
temperature=temperature,
|
77 |
+
top_p=top_p
|
78 |
+
)
|
79 |
+
|
80 |
message_repl = ""
|
81 |
for chunk in response:
|
82 |
if len(chunk['choices'][0]["delta"]) != 0 and "content" in chunk['choices'][0]["delta"]:
|
83 |
+
message_repl = message_repl + chunk['choices'][0]["delta"]["content"]
|
|
|
84 |
yield message_repl
|
85 |
|
86 |
def get_chat_title(model_name):
|