ndwdgda commited on
Commit
9c05e00
·
verified ·
1 Parent(s): 1c6d86c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -1,7 +1,19 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load the text generation pipeline
5
+ pipe = pipeline("text-generation", model="meta-llama/Meta-Llama-3-8B-Instruct")
6
 
7
+ # Define the chatbot function
8
+ def chatbot(user_input):
9
+ # Create a message with the user input
10
+ message = {"role": "user", "content": user_input}
11
+ # Generate a response using the pipeline
12
+ response = pipe([message])[0]["generated_text"]
13
+ return response
14
+
15
+ # Create a Gradio interface for the chatbot
16
+ demo = gr.Interface(fn=chatbot, inputs="text", outputs="text")
17
+
18
+ # Launch the Gradio app
19
+ demo.launch()