hereoncollab commited on
Commit
faa579e
·
verified ·
1 Parent(s): 64e4ccf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize the text generation pipeline with the LLaMA model
5
+ pipe = pipeline("text-generation", model="mlabonne/Hermes-3-Llama-3.1-8B-lorablated")
6
+
7
+ # Define the function that generates a response
8
+ def generate_response(prompt):
9
+ # Generate text using the pipeline
10
+ responses = pipe(prompt, max_length=100, num_return_sequences=1)
11
+ # Extract and return the text from the generated responses
12
+ return responses[0]['generated_text']
13
+
14
+ # Create the Gradio interface
15
+ interface = gr.Interface(
16
+ fn=generate_response,
17
+ inputs="text",
18
+ outputs="text",
19
+ title="LLaMA Chatbot",
20
+ description="A simple chatbot using LLaMA for text generation. Enter a prompt and get a response."
21
+ )
22
+
23
+ # Launch the Gradio app
24
+ interface.launch()