cleaned app.py
Browse files
app.py
CHANGED
@@ -1,70 +1,10 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
import os
|
4 |
-
import getpass
|
5 |
-
import sys
|
6 |
-
from graph import create_blog_generator_workflow
|
7 |
-
from ui import display_workflow, display_blog, launch_ui
|
8 |
-
from core import generate_ai_news_blog
|
9 |
|
10 |
def main():
|
11 |
-
"""Main entry point for the application"""
|
12 |
-
parser = argparse.ArgumentParser(description="AI News Blog Generator")
|
13 |
-
parser.add_argument("--ui", action="store_true", help="Launch the web UI")
|
14 |
-
parser.add_argument("--date", type=str, help="Date to search for news (YYYY-MM-DD format)")
|
15 |
-
parser.add_argument("--groq-key", type=str, help="Groq API key")
|
16 |
-
parser.add_argument("--tavily-key", type=str, help="Tavily API key")
|
17 |
-
parser.add_argument("--output", type=str, help="Output file path")
|
18 |
-
|
19 |
-
args = parser.parse_args()
|
20 |
-
|
21 |
-
# Launch the web UI if requested
|
22 |
-
# if args.ui:
|
23 |
print("Launching web UI...")
|
24 |
launch_ui()
|
25 |
-
|
26 |
-
|
27 |
-
# Otherwise, run the CLI version
|
28 |
-
# try:
|
29 |
-
# # Get API keys if not provided
|
30 |
-
# groq_key = args.groq_key
|
31 |
-
# if not groq_key and not os.environ.get("GROQ_API_KEY"):
|
32 |
-
# groq_key = getpass.getpass("Enter the Groq API key: ")
|
33 |
-
|
34 |
-
# tavily_key = args.tavily_key
|
35 |
-
# if not tavily_key and not os.environ.get("TAVILY_API_KEY"):
|
36 |
-
# tavily_key = getpass.getpass("Enter the Tavily API key: ")
|
37 |
-
|
38 |
-
# # Display the workflow graph
|
39 |
-
# print("Generating AI News Blog...")
|
40 |
-
|
41 |
-
# # Generate the blog
|
42 |
-
# blog_content = generate_ai_news_blog(groq_key, tavily_key, args.date)
|
43 |
-
|
44 |
-
# # Save to file if output path provided
|
45 |
-
# if args.output:
|
46 |
-
# with open(args.output, "w") as f:
|
47 |
-
# f.write(blog_content)
|
48 |
-
# print(f"Blog saved to {args.output}")
|
49 |
-
# else:
|
50 |
-
# # Otherwise, save to default file
|
51 |
-
# output_file = f"ai_news_blog_{datetime.now().strftime('%Y-%m-%d')}.md"
|
52 |
-
# with open(output_file, "w") as f:
|
53 |
-
# f.write(blog_content)
|
54 |
-
# print(f"Blog saved to {output_file}")
|
55 |
-
|
56 |
-
# # Try to display the blog if running in a notebook
|
57 |
-
# try:
|
58 |
-
# display_blog(blog_content)
|
59 |
-
# except:
|
60 |
-
# print("Blog generated successfully.")
|
61 |
-
|
62 |
-
# except KeyboardInterrupt:
|
63 |
-
# print("\nOperation cancelled by user.")
|
64 |
-
# sys.exit(0)
|
65 |
-
# except Exception as e:
|
66 |
-
# print(f"Error running the pipeline: {str(e)}")
|
67 |
-
# sys.exit(1)
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
main()
|
|
|
1 |
+
from ui import launch_ui
|
2 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
print("Launching web UI...")
|
6 |
launch_ui()
|
7 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
if __name__ == "__main__":
|
10 |
main()
|