Spaces:
Build error
Build error
Commit
•
bcb0bd1
1
Parent(s):
76e3959
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,22 @@ from transformers import pipeline
|
|
3 |
|
4 |
pipe = pipeline("text-generation", model="keyfan/grok-1-hf", trust_remote_code=True)
|
5 |
|
6 |
-
def chatbot_response(message, history):
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
iface = gr.ChatInterface(
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
pipe = pipeline("text-generation", model="keyfan/grok-1-hf", trust_remote_code=True)
|
5 |
|
6 |
+
def chatbot_response(message, history, max_tokens, temperature):
|
7 |
+
history.append(message)
|
8 |
+
inp = " ".join(history)
|
9 |
+
output = pipe(inp, max_length=max_tokens, temperature=temperature)[0]['generated_text']
|
10 |
+
history.append(output)
|
11 |
+
return output
|
12 |
|
13 |
+
iface = gr.ChatInterface(
|
14 |
+
fn=chatbot_response,
|
15 |
+
chatbot="Grok-1",
|
16 |
+
history=[],
|
17 |
+
title="Grok-1",
|
18 |
+
inputs=[
|
19 |
+
gr.Textbox(lines=1, placeholder="Enter your message"),
|
20 |
+
gr.Slider(minimum=1, maximum=8192, step=1, value=500, label="Max Tokens"),
|
21 |
+
gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.01, label="Temperature")
|
22 |
+
]
|
23 |
+
)
|
24 |
+
iface.launch()
|