setiyanikhil3 commited on
Commit
4012100
Β·
verified Β·
1 Parent(s): c4cd7dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -7,7 +7,7 @@ from datetime import datetime
7
  # Load environment variables
8
  load_dotenv()
9
 
10
- # Initialize Groq client
11
  client = Groq(api_key=os.getenv("GROQ_API_KEY"))
12
 
13
  def load_system_prompt():
@@ -25,9 +25,11 @@ def load_system_prompt():
25
  # Load system prompt once
26
  SYSTEM_PROMPT = load_system_prompt()
27
 
28
- def generate_ai_content(user_topic):
29
- """Generate AI content using Groq API based on user input."""
30
  try:
 
 
31
  chat_completion = client.chat.completions.create(
32
  messages=[
33
  {
@@ -36,7 +38,7 @@ def generate_ai_content(user_topic):
36
  },
37
  {
38
  "role": "user",
39
- "content": f"User has requested content about: '{user_topic}'. Please follow the verification and curation workflow to create platform-specific drafts."
40
  }
41
  ],
42
  model="llama3-70b-8192",
@@ -53,33 +55,28 @@ def generate_ai_content(user_topic):
53
  print("=== Groq API Error ===")
54
  print(traceback.format_exc())
55
  print("======================")
56
- return "⚠️ Oops! Could not generate AI content. Please try again later."
57
 
58
  # Gradio app
59
  with gr.Blocks(title="AI Content Curator") as demo:
60
  gr.Markdown("# πŸ“ˆ AI Content Curator")
61
- gr.Markdown("Provide a topic or idea, and the AI will curate verified, platform-optimized content drafts.")
62
 
63
  with gr.Row():
64
  with gr.Column():
65
- user_input = gr.Textbox(
66
- label="Enter your topic or idea",
67
- placeholder="e.g., OpenAI's GPT-5 launch, AI use in healthcare...",
68
- lines=2
69
- )
70
- submit_btn = gr.Button("πŸš€ Generate AI Content")
71
 
72
  with gr.Column():
73
  output = gr.Textbox(
74
- label="πŸ“‹ AI Curated Content Drafts",
75
- lines=30,
76
  interactive=False,
77
- placeholder="AI-generated content will appear here..."
78
  )
79
 
80
  submit_btn.click(
81
- fn=generate_ai_content,
82
- inputs=[user_input],
83
  outputs=output
84
  )
85
 
 
7
  # Load environment variables
8
  load_dotenv()
9
 
10
+ # Initialize Groq client properly
11
  client = Groq(api_key=os.getenv("GROQ_API_KEY"))
12
 
13
  def load_system_prompt():
 
25
  # Load system prompt once
26
  SYSTEM_PROMPT = load_system_prompt()
27
 
28
+ def generate_ai_updates():
29
+ """Generate AI updates using Groq API."""
30
  try:
31
+ current_date = datetime.now().strftime("%B %d, %Y")
32
+
33
  chat_completion = client.chat.completions.create(
34
  messages=[
35
  {
 
38
  },
39
  {
40
  "role": "user",
41
+ "content": f"Please analyze and provide the latest AI developments and trends for {current_date}. Follow the verification workflow and create content as specified."
42
  }
43
  ],
44
  model="llama3-70b-8192",
 
55
  print("=== Groq API Error ===")
56
  print(traceback.format_exc())
57
  print("======================")
58
+ return "⚠️ Oops! Could not generate AI updates. Please try again later."
59
 
60
  # Gradio app
61
  with gr.Blocks(title="AI Content Curator") as demo:
62
  gr.Markdown("# πŸ“ˆ AI Content Curator")
63
+ gr.Markdown("Click below to generate the latest AI developments and recommendations.")
64
 
65
  with gr.Row():
66
  with gr.Column():
67
+ submit_btn = gr.Button("πŸš€ Generate Latest AI Updates")
 
 
 
 
 
68
 
69
  with gr.Column():
70
  output = gr.Textbox(
71
+ label="πŸ”Ž AI Updates and Content Recommendations",
72
+ lines=20,
73
  interactive=False,
74
+ placeholder="Waiting for AI updates..."
75
  )
76
 
77
  submit_btn.click(
78
+ fn=generate_ai_updates,
79
+ inputs=[],
80
  outputs=output
81
  )
82