jonathanagustin commited on
Commit
bcb0bd1
1 Parent(s): 76e3959

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
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
- history.append(message)
8
- inp = " ".join(history)
9
- output = pipe(inp, max_length=100, temperature=0.01)[0]['generated_text'] # Access generated text
10
- history.append(output)
11
- return output
12
 
13
- iface = gr.ChatInterface(fn=chatbot_response, chatbot="Grok-1", history=[], title="Grok-1")
14
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
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()