Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from agents import get_agents_and_tasks
|
| 2 |
+
from crewai import Crew
|
| 3 |
+
from utils import send_email_with_company_details, post_image_and_text
|
| 4 |
+
import streamlit as st
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
+
|
| 7 |
+
load_dotenv()
|
| 8 |
+
|
| 9 |
+
# groq_api_key = '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'
|
| 10 |
+
|
| 11 |
+
def generate_bolg_and_video(title, url, token):
|
| 12 |
+
|
| 13 |
+
if token is not None:
|
| 14 |
+
agents, tasks = get_agents_and_tasks(is_token=True)
|
| 15 |
+
else:
|
| 16 |
+
agents, tasks = get_agents_and_tasks(is_token=False)
|
| 17 |
+
|
| 18 |
+
print(agents, '\n', tasks)
|
| 19 |
+
|
| 20 |
+
crew = Crew(
|
| 21 |
+
agents=agents,
|
| 22 |
+
tasks= tasks,
|
| 23 |
+
verbose = 2,
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
pairs = crew.kickoff(inputs={'topic':title, 'website':url, 'token':token})
|
| 27 |
+
print(1)
|
| 28 |
+
|
| 29 |
+
return 'video.mp4'
|
| 30 |
+
|
| 31 |
+
st.title("Blog and Video Generator")
|
| 32 |
+
|
| 33 |
+
title = st.text_input("Title")
|
| 34 |
+
url = st.text_input("Website URL")
|
| 35 |
+
email = st.text_input("Email ID")
|
| 36 |
+
|
| 37 |
+
# token = 'AQXZFWxVIyE0IJ3vopgzsuG0t4uSg9lUnVwLOTLOkEOKIU9hhswEYXOpEzEveBFCZdcRP4B3vN8gd_HI920LTH5LFbO9TVkHbtn8P2qE_GcwBq_1LzGw-HwatIY3zU7auWhxCMVYAXsklAJx6FAa_Sx_MUtaVcnA42K1vhYxSS7s0ecQq0Thsdod1KrK2_nA0YjMc1lSnQQy1WDiK0HGN2-2jbDt13NpJTkmZqEWm6G9BRplTkUSeSSqGNuLEGpuY0hd50GcRovkcqpz9ZfvqkeiKhAYPPDTAGDX7HO5VjtHTui3ZCFEXvEbAHzng116xDfNnBE8-fsig7c9HP6c06UmmN6evA'
|
| 38 |
+
|
| 39 |
+
token = None
|
| 40 |
+
if st.checkbox(label='post on linkedIn'):
|
| 41 |
+
token = st.text_input('Enter you LinkedIn access token')
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
if st.button("Generate"):
|
| 46 |
+
if title and url and email:
|
| 47 |
+
|
| 48 |
+
st.success("Blog and Video will be sent to your email.")
|
| 49 |
+
video_path = generate_bolg_and_video(title, url, token)
|
| 50 |
+
# st.write(video_path)
|
| 51 |
+
|
| 52 |
+
# with open('blog_post.md', 'r', encoding='latin-1') as f:
|
| 53 |
+
# blog = f.read()
|
| 54 |
+
# st.markdown(blog)
|
| 55 |
+
# st.video(video_path)
|
| 56 |
+
|
| 57 |
+
send_email_with_company_details(email, 'DIGIOTAI SOLUTIONS', title)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
else:
|
| 61 |
+
st.error("Please provide all inputs.")
|