File size: 541 Bytes
b170fd8
 
 
 
2ac55b7
b170fd8
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from transformers import AutoModelForCausalLM

# Load the Llama-2-7b-chat model
model = AutoModelForCausalLM.from_pretrained("google/llama-2-7b-chat")

# Define a function to generate text using the model
def generate_text(prompt):
  # Generate text using the model
  generated_text = model.generate(prompt, max_length=4000)

  # Return the generated text
  return generated_text

# Create a Gradio app
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")

# Launch the Gradio app
interface.launch()