Spaces:
Runtime error
Runtime error
Prathamesh1420
commited on
Commit
•
81a7e89
1
Parent(s):
255ea39
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,15 @@ from crewai import Agent, Task, Crew
|
|
3 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
4 |
from dotenv import load_dotenv
|
5 |
import os
|
|
|
6 |
|
7 |
# Load environment variables
|
8 |
load_dotenv()
|
9 |
|
|
|
|
|
|
|
|
|
10 |
# Initialize Google Gemini AI
|
11 |
llm = ChatGoogleGenerativeAI(
|
12 |
api_key=os.getenv('GOOGLE_API_KEY'),
|
@@ -92,7 +97,7 @@ def main():
|
|
92 |
if topic:
|
93 |
with st.spinner('Generating content...'):
|
94 |
try:
|
95 |
-
result = crew.kickoff(inputs={"topic": topic})
|
96 |
st.markdown(result)
|
97 |
except Exception as e:
|
98 |
st.error(f"An error occurred: {e}")
|
|
|
3 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
4 |
from dotenv import load_dotenv
|
5 |
import os
|
6 |
+
import asyncio
|
7 |
|
8 |
# Load environment variables
|
9 |
load_dotenv()
|
10 |
|
11 |
+
# Ensure an event loop is available
|
12 |
+
if not asyncio.get_event_loop_policy().get_event_loop():
|
13 |
+
asyncio.set_event_loop(asyncio.new_event_loop())
|
14 |
+
|
15 |
# Initialize Google Gemini AI
|
16 |
llm = ChatGoogleGenerativeAI(
|
17 |
api_key=os.getenv('GOOGLE_API_KEY'),
|
|
|
97 |
if topic:
|
98 |
with st.spinner('Generating content...'):
|
99 |
try:
|
100 |
+
result = asyncio.run(crew.kickoff(inputs={"topic": topic})) # Wrap the kickoff call
|
101 |
st.markdown(result)
|
102 |
except Exception as e:
|
103 |
st.error(f"An error occurred: {e}")
|