egillf commited on
Commit
4c75b3b
·
verified ·
1 Parent(s): 01cd34f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the model
5
+ pipe = pipeline("text-generation", model="defog/llama-3-sqlcoder-8b")
6
+
7
+ # Define a function that will take user input and generate text
8
+ def generate_response(user_input):
9
+ messages = [{"role": "user", "content": user_input}]
10
+ result = pipe(messages)
11
+ return result[0]['generated_text']
12
+
13
+ # Create a Gradio interface
14
+ iface = gr.Interface(
15
+ fn=generate_response, # The function to call for generating responses
16
+ inputs="text", # The type of input: a text box
17
+ outputs="text", # The type of output: a text box
18
+ title="Text Generation with LLaMA-3",
19
+ description="Ask anything!"
20
+ )
21
+
22
+ # Launch the app
23
+ iface.launch()