Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,4 @@
|
|
1 |
-
"""
|
2 |
-
app.py
|
3 |
-
"""
|
4 |
import os
|
5 |
-
|
6 |
import gradio as gr
|
7 |
from groq import Groq
|
8 |
|
@@ -12,18 +8,14 @@ def autocomplete(text):
|
|
12 |
if text != "":
|
13 |
response = client.chat.completions.create(
|
14 |
model='gemma-7b-it',
|
15 |
-
messages=[
|
16 |
-
{
|
17 |
-
"role": "user",
|
18 |
-
"content": text
|
19 |
-
}],
|
20 |
stream=True
|
21 |
-
|
22 |
-
|
23 |
partial_message = ""
|
24 |
for chunk in response:
|
25 |
if chunk.choices[0].delta.content is not None:
|
26 |
-
partial_message
|
27 |
yield partial_message
|
28 |
|
29 |
css = """
|
@@ -31,19 +23,37 @@ css = """
|
|
31 |
display: none
|
32 |
}
|
33 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
# Create the Gradio interface with live updates
|
35 |
iface = gr.Interface(
|
36 |
fn=autocomplete,
|
37 |
-
inputs=gr.Textbox(lines=2,
|
38 |
-
placeholder="Hello 👋",
|
39 |
-
label="Input Sentence"),
|
40 |
outputs=gr.Markdown(),
|
41 |
-
title="
|
42 |
-
description="Powered by Groq
|
43 |
-
live=True,
|
44 |
-
allow_flagging="never",
|
45 |
-
css=css
|
|
|
46 |
)
|
|
|
47 |
iface.dependencies[0]['show_progress'] = "hidden"
|
48 |
iface.dependencies[2]['show_progress'] = "hidden"
|
49 |
|
|
|
|
|
|
|
|
|
1 |
import os
|
|
|
2 |
import gradio as gr
|
3 |
from groq import Groq
|
4 |
|
|
|
8 |
if text != "":
|
9 |
response = client.chat.completions.create(
|
10 |
model='gemma-7b-it',
|
11 |
+
messages=[{"role": "user", "content": text}],
|
|
|
|
|
|
|
|
|
12 |
stream=True
|
13 |
+
)
|
14 |
+
|
15 |
partial_message = ""
|
16 |
for chunk in response:
|
17 |
if chunk.choices[0].delta.content is not None:
|
18 |
+
partial_message += chunk.choices[0].delta.content
|
19 |
yield partial_message
|
20 |
|
21 |
css = """
|
|
|
23 |
display: none
|
24 |
}
|
25 |
"""
|
26 |
+
|
27 |
+
# Theme Definition
|
28 |
+
theme = gr.themes.Default(
|
29 |
+
primary_hue="neutral",
|
30 |
+
secondary_hue=gr.themes.Color(
|
31 |
+
secondary_100="#f1f5f9", secondary_200="#e2e8f0", secondary_300="#cbd5e1",
|
32 |
+
secondary_400="#94adb8", secondary_50="#f8fafc", secondary_500="#65858b",
|
33 |
+
secondary_600="#48626a", secondary_700="#345456", secondary_800="#1d343a",
|
34 |
+
secondary_900="#0f2029", secondary_950="#0a1b1f"
|
35 |
+
),
|
36 |
+
neutral_hue=gr.themes.Color(
|
37 |
+
neutral_100="#f3f4f6", neutral_200="#e5e7eb", neutral_300="#d4d9dd",
|
38 |
+
neutral_400="#9ca9b0", neutral_50="#f9fafb", neutral_500="#6b7780",
|
39 |
+
neutral_600="#034054", neutral_700="#14161a", neutral_800="#0a0a0a",
|
40 |
+
neutral_900="#19191a", neutral_950="#050505"
|
41 |
+
)
|
42 |
+
)
|
43 |
+
|
44 |
# Create the Gradio interface with live updates
|
45 |
iface = gr.Interface(
|
46 |
fn=autocomplete,
|
47 |
+
inputs=gr.Textbox(lines=2, placeholder="Hello 👋", label="Input Sentence"),
|
|
|
|
|
48 |
outputs=gr.Markdown(),
|
49 |
+
title="Frag mich einfach!",
|
50 |
+
description="Powered by Groq",
|
51 |
+
live=True,
|
52 |
+
allow_flagging="never",
|
53 |
+
css=css,
|
54 |
+
theme=theme # Add the theme to your interface
|
55 |
)
|
56 |
+
|
57 |
iface.dependencies[0]['show_progress'] = "hidden"
|
58 |
iface.dependencies[2]['show_progress'] = "hidden"
|
59 |
|