Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
messages = [
|
| 9 |
{"role": "user", "content": f"Generate a professional email reply to the following email: {email_content}"}
|
| 10 |
]
|
| 11 |
-
|
| 12 |
-
reply
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
# Example usage
|
| 16 |
-
user_email = "Dear team, I hope this email finds you well. Could you provide an update on the project status?"
|
| 17 |
-
generated_reply = generate_reply(user_email)
|
| 18 |
-
print(f"Generated Reply: {generated_reply}")
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Title of the Streamlit app
|
| 5 |
+
st.title("Email Reply Generator")
|
| 6 |
|
| 7 |
+
# Set up the pipeline for text generation using the replycraft model
|
| 8 |
+
pipe = pipeline("text-generation", model="replycraft/replycraft", trust_remote_code=True)
|
| 9 |
+
|
| 10 |
+
# Get email content from the user
|
| 11 |
+
email_content = st.text_area("Enter the email content")
|
| 12 |
+
|
| 13 |
+
if email_content:
|
| 14 |
+
# Prepare the messages and get the generated reply
|
| 15 |
messages = [
|
| 16 |
{"role": "user", "content": f"Generate a professional email reply to the following email: {email_content}"}
|
| 17 |
]
|
| 18 |
+
|
| 19 |
+
# Generate the reply using the model
|
| 20 |
+
generated_reply = pipe(messages)
|
| 21 |
+
|
| 22 |
+
# Display the generated reply
|
| 23 |
+
st.json(generated_reply)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|