Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,12 +24,9 @@ def query_model(model_name: str, messages: List[Dict[str, str]]) -> Generator[st
|
|
24 |
# Build full conversation history for context
|
25 |
conversation = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
|
26 |
|
27 |
-
#
|
28 |
-
|
29 |
-
"Qwen2.5-72B-Instruct":
|
30 |
-
f"<|im_start|>system\nCollaborate with other experts. Previous discussion:\n{conversation}<|im_end|>\n"
|
31 |
-
"<|im_start|>assistant\nMy analysis:"
|
32 |
-
),
|
33 |
"Llama3.3-70B-Instruct": (
|
34 |
"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n"
|
35 |
f"Build upon this discussion:\n{conversation}<|eot_id|>\n"
|
@@ -44,11 +41,17 @@ def query_model(model_name: str, messages: List[Dict[str, str]]) -> Generator[st
|
|
44 |
client = InferenceClient(base_url=endpoint, token=HF_API_KEY)
|
45 |
|
46 |
try:
|
|
|
|
|
|
|
|
|
|
|
47 |
stream = client.chat.completions.create(
|
48 |
-
messages=
|
49 |
stream=True,
|
50 |
max_tokens=2048,
|
51 |
-
temperature=0.
|
|
|
52 |
)
|
53 |
|
54 |
for chunk in stream:
|
|
|
24 |
# Build full conversation history for context
|
25 |
conversation = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
|
26 |
|
27 |
+
# System prompt configuration
|
28 |
+
system_prompts = {
|
29 |
+
"Qwen2.5-72B-Instruct": "Collaborate with other experts. Previous discussion:\n{conversation}",
|
|
|
|
|
|
|
30 |
"Llama3.3-70B-Instruct": (
|
31 |
"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n"
|
32 |
f"Build upon this discussion:\n{conversation}<|eot_id|>\n"
|
|
|
41 |
client = InferenceClient(base_url=endpoint, token=HF_API_KEY)
|
42 |
|
43 |
try:
|
44 |
+
messages = [
|
45 |
+
{"role": "system", "content": system_prompts[model_name].format(conversation=conversation)},
|
46 |
+
{"role": "user", "content": "Continue the expert discussion"}
|
47 |
+
]
|
48 |
+
|
49 |
stream = client.chat.completions.create(
|
50 |
+
messages=messages,
|
51 |
stream=True,
|
52 |
max_tokens=2048,
|
53 |
+
temperature=0.5,
|
54 |
+
top_p=0.7
|
55 |
)
|
56 |
|
57 |
for chunk in stream:
|