abhlash commited on
Commit
30af1b3
·
1 Parent(s): 4a2be46

upadte the app

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+ from huggingface_hub import login
4
+
5
+ # Login to Hugging Face (you'll need to set HUGGINGFACE_TOKEN in your Secrets)
6
+ login()
7
+
8
+ # Load model and tokenizer
9
+ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-70B")
10
+ model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-70B")
11
+
12
+ def generate_email(context):
13
+ prompt = f"Generate a professional email based on the following context: {context}"
14
+ inputs = tokenizer(prompt, return_tensors="pt")
15
+ outputs = model.generate(**inputs, max_length=300)
16
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
17
+
18
+ # Create Gradio interface
19
+ iface = gr.Interface(
20
+ fn=generate_email,
21
+ inputs=gr.Textbox(lines=5, label="Context"),
22
+ outputs=gr.Textbox(label="Generated Email"),
23
+ title="Email Generator",
24
+ description="Enter the context, and the app will generate an email using Llama 3.1 70B."
25
+ )
26
+
27
+ # Launch the app
28
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch
4
+ huggingface_hub