Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,38 +13,7 @@ def respond(
|
|
13 |
temperature,
|
14 |
top_p,
|
15 |
):
|
16 |
-
|
17 |
-
|
18 |
-
for val in history:
|
19 |
-
if val[0]:
|
20 |
-
messages.append({"role": "user", "content": val[0]})
|
21 |
-
if val[1]:
|
22 |
-
messages.append({"role": "assistant", "content": val[1]})
|
23 |
-
|
24 |
-
messages.append({"role": "user", "content": message})
|
25 |
-
|
26 |
-
response = ""
|
27 |
-
|
28 |
-
for message in client.chat_completion(
|
29 |
-
messages,
|
30 |
-
max_tokens=max_tokens,
|
31 |
-
stream=True,
|
32 |
-
temperature=temperature,
|
33 |
-
top_p=top_p,
|
34 |
-
):
|
35 |
-
token = message.choices[0].delta.content
|
36 |
-
|
37 |
-
response += token
|
38 |
-
yield response
|
39 |
-
|
40 |
-
# Create a custom theme for the chat interface
|
41 |
-
theme = gr.Theme(
|
42 |
-
primary_color="#3498db",
|
43 |
-
secondary_color="#f1c40f",
|
44 |
-
background_color="#f9f9f9",
|
45 |
-
text_color="#333",
|
46 |
-
font="Open Sans",
|
47 |
-
)
|
48 |
|
49 |
# Create the chat interface
|
50 |
demo = gr.ChatInterface(
|
@@ -63,8 +32,44 @@ demo = gr.ChatInterface(
|
|
63 |
label="Top-p (nucleus sampling)",
|
64 |
),
|
65 |
],
|
66 |
-
theme=theme,
|
67 |
)
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
if __name__ == "__main__":
|
70 |
demo.launch()
|
|
|
13 |
temperature,
|
14 |
top_p,
|
15 |
):
|
16 |
+
#... (rest of the code remains the same)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Create the chat interface
|
19 |
demo = gr.ChatInterface(
|
|
|
32 |
label="Top-p (nucleus sampling)",
|
33 |
),
|
34 |
],
|
|
|
35 |
)
|
36 |
|
37 |
+
# Add custom CSS to customize the theme
|
38 |
+
css = """
|
39 |
+
body {
|
40 |
+
background-color: #f9f9f9;
|
41 |
+
}
|
42 |
+
|
43 |
+
.gradio-container {
|
44 |
+
max-width: 800px;
|
45 |
+
margin: 40px auto;
|
46 |
+
padding: 20px;
|
47 |
+
border: 1px solid #ddd;
|
48 |
+
border-radius: 10px;
|
49 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
50 |
+
}
|
51 |
+
|
52 |
+
.gradio-input {
|
53 |
+
background-color: #fff;
|
54 |
+
border: 1px solid #ccc;
|
55 |
+
padding: 10px;
|
56 |
+
border-radius: 10px;
|
57 |
+
}
|
58 |
+
|
59 |
+
.gradio-button {
|
60 |
+
background-color: #3498db;
|
61 |
+
color: #fff;
|
62 |
+
border: none;
|
63 |
+
padding: 10px 20px;
|
64 |
+
border-radius: 10px;
|
65 |
+
cursor: pointer;
|
66 |
+
}
|
67 |
+
|
68 |
+
.gradio-button:hover {
|
69 |
+
background-color: #2980b9;
|
70 |
+
}
|
71 |
+
"""
|
72 |
+
demo.css(css)
|
73 |
+
|
74 |
if __name__ == "__main__":
|
75 |
demo.launch()
|