Update space
Browse files
app.py
CHANGED
@@ -5,20 +5,22 @@ from huggingface_hub import InferenceClient
|
|
5 |
client = InferenceClient("emeses/lab2_model")
|
6 |
|
7 |
def respond(
|
8 |
-
message,
|
9 |
-
history:
|
10 |
-
system_message="You are a helpful assistant.",
|
11 |
-
max_tokens=512,
|
12 |
-
temperature=0.7,
|
13 |
-
top_p=0.95,
|
14 |
-
):
|
15 |
-
# Format conversation
|
16 |
conversation = system_message + "\n\n"
|
17 |
-
for
|
18 |
-
|
|
|
|
|
19 |
conversation += f"User: {message}\nAssistant: "
|
20 |
|
21 |
-
# Stream response
|
22 |
response = ""
|
23 |
try:
|
24 |
for token in client.text_generation(
|
|
|
5 |
client = InferenceClient("emeses/lab2_model")
|
6 |
|
7 |
def respond(
|
8 |
+
message: str,
|
9 |
+
history: List[Dict[str, str]],
|
10 |
+
system_message: str = "You are a helpful assistant.",
|
11 |
+
max_tokens: int = 512,
|
12 |
+
temperature: float = 0.7,
|
13 |
+
top_p: float = 0.95,
|
14 |
+
) -> str:
|
15 |
+
# Format conversation using new messages format
|
16 |
conversation = system_message + "\n\n"
|
17 |
+
for msg in history:
|
18 |
+
role = msg["role"]
|
19 |
+
content = msg["content"]
|
20 |
+
conversation += f"{role.capitalize()}: {content}\n"
|
21 |
conversation += f"User: {message}\nAssistant: "
|
22 |
|
23 |
+
# Stream response
|
24 |
response = ""
|
25 |
try:
|
26 |
for token in client.text_generation(
|