Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,24 @@ import os
|
|
| 4 |
from datetime import datetime
|
| 5 |
import json
|
| 6 |
from crewai import Agent, Task, Crew
|
| 7 |
-
from langchain.tools import
|
| 8 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# Set up OpenAI API key from Streamlit secrets
|
| 11 |
def setup_api_keys():
|
| 12 |
"""Setup API keys from Hugging Face Spaces secrets"""
|
| 13 |
try:
|
|
@@ -21,13 +35,12 @@ def setup_api_keys():
|
|
| 21 |
st.error(f"Error setting up API keys: {str(e)}")
|
| 22 |
return False
|
| 23 |
|
| 24 |
-
# Initialize agents with API key check
|
| 25 |
def initialize_agents():
|
| 26 |
"""Initialize CrewAI agents with proper API key handling"""
|
| 27 |
if not os.environ.get('OPENAI_API_KEY'):
|
| 28 |
return None
|
| 29 |
|
| 30 |
-
search_tool =
|
| 31 |
llm = OpenAI(temperature=0.7)
|
| 32 |
|
| 33 |
quote_curator = Agent(
|
|
@@ -59,6 +72,8 @@ def initialize_agents():
|
|
| 59 |
|
| 60 |
return quote_curator, content_creator, content_validator
|
| 61 |
|
|
|
|
|
|
|
| 62 |
def main():
|
| 63 |
st.set_page_config(
|
| 64 |
page_title="Spiritual Content Generator",
|
|
|
|
| 4 |
from datetime import datetime
|
| 5 |
import json
|
| 6 |
from crewai import Agent, Task, Crew
|
| 7 |
+
from langchain.tools import BaseTool
|
| 8 |
+
from langchain_community.tools import DuckDuckGoSearchRun
|
| 9 |
+
from langchain_openai import OpenAI
|
| 10 |
+
|
| 11 |
+
class SearchTool(BaseTool):
|
| 12 |
+
name = "Search"
|
| 13 |
+
description = "Search the internet for information"
|
| 14 |
+
|
| 15 |
+
def __init__(self):
|
| 16 |
+
super().__init__()
|
| 17 |
+
self.search = DuckDuckGoSearchRun()
|
| 18 |
+
|
| 19 |
+
def _run(self, query: str) -> str:
|
| 20 |
+
return self.search.run(query)
|
| 21 |
+
|
| 22 |
+
def _arun(self, query: str) -> str:
|
| 23 |
+
raise NotImplementedError("Async not implemented")
|
| 24 |
|
|
|
|
| 25 |
def setup_api_keys():
|
| 26 |
"""Setup API keys from Hugging Face Spaces secrets"""
|
| 27 |
try:
|
|
|
|
| 35 |
st.error(f"Error setting up API keys: {str(e)}")
|
| 36 |
return False
|
| 37 |
|
|
|
|
| 38 |
def initialize_agents():
|
| 39 |
"""Initialize CrewAI agents with proper API key handling"""
|
| 40 |
if not os.environ.get('OPENAI_API_KEY'):
|
| 41 |
return None
|
| 42 |
|
| 43 |
+
search_tool = SearchTool()
|
| 44 |
llm = OpenAI(temperature=0.7)
|
| 45 |
|
| 46 |
quote_curator = Agent(
|
|
|
|
| 72 |
|
| 73 |
return quote_curator, content_creator, content_validator
|
| 74 |
|
| 75 |
+
|
| 76 |
+
|
| 77 |
def main():
|
| 78 |
st.set_page_config(
|
| 79 |
page_title="Spiritual Content Generator",
|