HaveAI commited on
Commit
359afbc
·
verified ·
1 Parent(s): 66ddc8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -1,12 +1,18 @@
 
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- chat = pipeline("text-generation", model="meta-llama/Meta-Llama-3-8B-Instruct", device_map="auto")
5
- def respond(msg, history):
6
  history = history or []
7
- out = chat(history + [msg], max_new_tokens=256)
8
- reply = out[0]["generated_text"]
9
- history.append((msg, reply))
10
  return history, history
11
- iface = gr.ChatInterface(respond)
12
- iface.launch()
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
  import gradio as gr
 
3
 
4
+ def echo(message, history):
 
5
  history = history or []
6
+ reply = f"Ты написал: {message}"
7
+ history.append((message, reply))
 
8
  return history, history
9
+
10
+ demo = gr.ChatInterface(
11
+ fn=echo,
12
+ type="messages",
13
+ examples=["Привет", "Как дела?", "Расскажи шутку"],
14
+ title="Echo Bot на Gradio"
15
+ )
16
+
17
+ if __name__ == "__main__":
18
+ demo.launch()