Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import gradio as gr
|
| 3 |
-
import groq
|
| 4 |
-
from dotenv import load_dotenv
|
| 5 |
-
from datetime import datetime
|
| 6 |
-
|
| 7 |
-
# Load environment variables
|
| 8 |
-
load_dotenv()
|
| 9 |
-
|
| 10 |
-
# Set API Key for Groq globally
|
| 11 |
-
groq.api_key = os.getenv("GROQ_API_KEY")
|
| 12 |
-
|
| 13 |
-
def load_system_prompt():
|
| 14 |
-
try:
|
| 15 |
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 16 |
-
config_path = os.path.join(current_dir, "config", "system_prompt.txt")
|
| 17 |
-
with open(config_path, 'r') as file:
|
| 18 |
-
return file.read().strip()
|
| 19 |
-
except Exception as e:
|
| 20 |
-
print(f"Error loading system prompt: {str(e)}")
|
| 21 |
-
return "You are a helpful social media research assistant."
|
| 22 |
-
|
| 23 |
-
SYSTEM_PROMPT = load_system_prompt()
|
| 24 |
-
|
| 25 |
def generate_ai_updates():
|
| 26 |
"""Generate AI updates using Groq API"""
|
| 27 |
try:
|
|
@@ -50,33 +26,7 @@ def generate_ai_updates():
|
|
| 50 |
|
| 51 |
except Exception as e:
|
| 52 |
import traceback
|
| 53 |
-
print("
|
| 54 |
-
print(traceback.format_exc())
|
| 55 |
-
print("
|
| 56 |
-
return "⚠️ Oops! Could not generate AI updates.
|
| 57 |
-
|
| 58 |
-
# Gradio app setup same as before
|
| 59 |
-
with gr.Blocks(title="AI Content Curator") as demo:
|
| 60 |
-
gr.Markdown("# 📈 AI Content Curator")
|
| 61 |
-
gr.Markdown("Click to generate the latest AI developments and trends.")
|
| 62 |
-
|
| 63 |
-
with gr.Row():
|
| 64 |
-
with gr.Column():
|
| 65 |
-
submit_btn = gr.Button("🚀 Generate Latest AI Updates")
|
| 66 |
-
|
| 67 |
-
with gr.Column():
|
| 68 |
-
output = gr.Textbox(
|
| 69 |
-
label="🔎 AI Updates and Content Recommendations",
|
| 70 |
-
lines=20,
|
| 71 |
-
interactive=False,
|
| 72 |
-
placeholder="Waiting for the latest AI trends..."
|
| 73 |
-
)
|
| 74 |
-
|
| 75 |
-
submit_btn.click(
|
| 76 |
-
fn=generate_ai_updates,
|
| 77 |
-
inputs=[],
|
| 78 |
-
outputs=output
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
if __name__ == "__main__":
|
| 82 |
-
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def generate_ai_updates():
|
| 2 |
"""Generate AI updates using Groq API"""
|
| 3 |
try:
|
|
|
|
| 26 |
|
| 27 |
except Exception as e:
|
| 28 |
import traceback
|
| 29 |
+
print("====== Exception Traceback ======")
|
| 30 |
+
print(traceback.format_exc()) # <-- FULL traceback to Huggingface logs
|
| 31 |
+
print("==================================")
|
| 32 |
+
return f"⚠️ Oops! Could not generate AI updates. ({str(e)})"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|