Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,55 @@ import textwrap
|
|
18 |
# Load environment variables
|
19 |
load_dotenv()
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Get API key from environment variable
|
22 |
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
|
23 |
if not OPENROUTER_API_KEY:
|
|
|
18 |
# Load environment variables
|
19 |
load_dotenv()
|
20 |
|
21 |
+
# Get API key from environment variable
|
22 |
+
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
|
23 |
+
if not OPENROUTER_API_KEY:
|
24 |
+
raise ValueError("OPENROUTER_API_KEY environment variable is not set")
|
25 |
+
|
26 |
+
# OpenRouter API configuration
|
27 |
+
MODEL_NAME = "meta-llama/llama-3.3-8b-instruct:free" # You can also use more powerful models like "anthropic/claude-3-opus-20240229"
|
28 |
+
SITE_URL = "https://requirements-generator.io" # Replace with your actual site URL
|
29 |
+
SITE_NAME = "Technical Requirements Generator" # Replace with your actual site name
|
30 |
+
|
31 |
+
# Process the input and generate everything
|
32 |
+
def process_input(description, project_type):
|
33 |
+
"""Process the input and generate both proposal, PDF and slides"""
|
34 |
+
try:
|
35 |
+
# Check if input is too short
|
36 |
+
if len(description.strip()) < 10:
|
37 |
+
return "Please provide a more detailed project description (at least 10 characters).", None, None
|
38 |
+
|
39 |
+
# Map project type to specific type value
|
40 |
+
type_value = None
|
41 |
+
if project_type == "SaaS Performance Platform":
|
42 |
+
type_value = "saas_performance"
|
43 |
+
|
44 |
+
# Generate the proposal
|
45 |
+
proposal = generate_proposal(description, type_value)
|
46 |
+
|
47 |
+
# Create the PDF
|
48 |
+
try:
|
49 |
+
pdf_path = create_pdf(proposal)
|
50 |
+
except Exception as pdf_error:
|
51 |
+
print(f"Error creating PDF: {pdf_error}")
|
52 |
+
pdf_path = None
|
53 |
+
|
54 |
+
# Create the slides
|
55 |
+
try:
|
56 |
+
ppt_path = create_slides(proposal)
|
57 |
+
except Exception as ppt_error:
|
58 |
+
print(f"Error creating slides: {ppt_error}")
|
59 |
+
ppt_path = None
|
60 |
+
|
61 |
+
return proposal, pdf_path, ppt_path
|
62 |
+
except Exception as e:
|
63 |
+
error_message = f"An error occurred: {str(e)}\nPlease try again with a different project description."
|
64 |
+
print(f"Error in process_input: {e}")
|
65 |
+
return error_message, None, None
|
66 |
+
|
67 |
+
# Load environment variables
|
68 |
+
load_dotenv()
|
69 |
+
|
70 |
# Get API key from environment variable
|
71 |
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
|
72 |
if not OPENROUTER_API_KEY:
|