Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,14 @@ body {
|
|
9 |
background-position: center;
|
10 |
background-repeat: no-repeat;
|
11 |
}
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
#custom-title {
|
14 |
color: #d63384;
|
15 |
font-family: 'Playfair Display', serif;
|
@@ -31,22 +38,44 @@ body {
|
|
31 |
box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
|
32 |
overflow-y: auto;
|
33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
"""
|
35 |
|
36 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
37 |
|
38 |
-
def respond(
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
for val in history:
|
41 |
if val[0]:
|
42 |
messages.append({"role": "user", "content": val[0]})
|
43 |
if val[1]:
|
44 |
messages.append({"role": "assistant", "content": val[1]})
|
|
|
45 |
messages.append({"role": "user", "content": message})
|
|
|
46 |
response = ""
|
|
|
47 |
for message in client.chat_completion(
|
48 |
messages,
|
|
|
49 |
stream=True,
|
|
|
|
|
50 |
):
|
51 |
token = message.choices[0].delta.content
|
52 |
response += token
|
|
|
9 |
background-position: center;
|
10 |
background-repeat: no-repeat;
|
11 |
}
|
12 |
+
.gradio-container {
|
13 |
+
display: flex;
|
14 |
+
flex-direction: column;
|
15 |
+
justify-content: center;
|
16 |
+
min-height: 100vh;
|
17 |
+
padding-top: 2rem;
|
18 |
+
padding-bottom: 2rem;
|
19 |
+
}
|
20 |
#custom-title {
|
21 |
color: #d63384;
|
22 |
font-family: 'Playfair Display', serif;
|
|
|
38 |
box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
|
39 |
overflow-y: auto;
|
40 |
}
|
41 |
+
.gradio-container .chatbot h1 {
|
42 |
+
color: var(--custom-title-color) !important;
|
43 |
+
font-family: 'Playfair Display', serif !important;
|
44 |
+
font-size: 1.8rem !important;
|
45 |
+
font-weight: bold !important;
|
46 |
+
text-align: center !important;
|
47 |
+
margin-bottom: 1rem !important
|
48 |
+
}
|
49 |
"""
|
50 |
|
51 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
52 |
|
53 |
+
def respond(
|
54 |
+
message,
|
55 |
+
history: list[tuple[str, str]],
|
56 |
+
system_message,
|
57 |
+
max_tokens,
|
58 |
+
temperature,
|
59 |
+
top_p,
|
60 |
+
):
|
61 |
+
|
62 |
+
messages = [{"role": "system", "content": system_message}]
|
63 |
for val in history:
|
64 |
if val[0]:
|
65 |
messages.append({"role": "user", "content": val[0]})
|
66 |
if val[1]:
|
67 |
messages.append({"role": "assistant", "content": val[1]})
|
68 |
+
|
69 |
messages.append({"role": "user", "content": message})
|
70 |
+
|
71 |
response = ""
|
72 |
+
|
73 |
for message in client.chat_completion(
|
74 |
messages,
|
75 |
+
max_tokens=max_tokens,
|
76 |
stream=True,
|
77 |
+
temperature=temperature,
|
78 |
+
top_p=top_p,
|
79 |
):
|
80 |
token = message.choices[0].delta.content
|
81 |
response += token
|