Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,42 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from inference_script import generate_outreach_message
|
| 3 |
-
import
|
|
|
|
|
|
|
| 4 |
|
| 5 |
try:
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
def predict_message(industry, company, prospect, designation, client_info, my_info):
|
|
|
|
|
|
|
|
|
|
| 12 |
message = generate_outreach_message(industry, company, prospect, designation, client_info, my_info)
|
| 13 |
return message
|
| 14 |
|
| 15 |
iface = gr.Interface(
|
| 16 |
fn=predict_message,
|
| 17 |
inputs=[
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
|
| 30 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from inference_script import generate_outreach_message, load_model_and_tokenizer
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 6 |
|
| 7 |
try:
|
| 8 |
+
model, tokenizer, device = load_model_and_tokenizer(
|
| 9 |
+
"KirubaLS/Outreach_model_6",
|
| 10 |
+
"google/gemma-2b",
|
| 11 |
+
hf_token=HF_TOKEN
|
| 12 |
+
)
|
| 13 |
+
except Exception as e:
|
| 14 |
+
print(f"Error loading model and tokenizer: {e}")
|
| 15 |
+
model = None
|
| 16 |
+
tokenizer = None
|
| 17 |
+
device = None
|
| 18 |
|
| 19 |
|
| 20 |
def predict_message(industry, company, prospect, designation, client_info, my_info):
|
| 21 |
+
if model is None or tokenizer is None:
|
| 22 |
+
return "Error: Model not loaded. Please check the application logs."
|
| 23 |
+
|
| 24 |
message = generate_outreach_message(industry, company, prospect, designation, client_info, my_info)
|
| 25 |
return message
|
| 26 |
|
| 27 |
iface = gr.Interface(
|
| 28 |
fn=predict_message,
|
| 29 |
inputs=[
|
| 30 |
+
gr.Textbox(label="Industry"),
|
| 31 |
+
gr.Textbox(label="Company"),
|
| 32 |
+
gr.Textbox(label="Prospect Name"),
|
| 33 |
+
gr.Textbox(label="Designation"),
|
| 34 |
+
gr.Textbox(label="Client Info"),
|
| 35 |
+
gr.Textbox(label="My Info"),
|
| 36 |
+
],
|
| 37 |
+
outputs=gr.Textbox(label="Generated Outreach Message"),
|
| 38 |
+
title="Gemma Outreach Message Generator",
|
| 39 |
+
description="Generate personalized first-level outreach messages using a fine-tuned Gemma model."
|
| 40 |
+
)
|
| 41 |
|
| 42 |
iface.launch()
|