shukdevdatta123 commited on
Commit
c57fad1
Β·
verified Β·
1 Parent(s): 6d85322

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -30
app.py CHANGED
@@ -5,8 +5,6 @@ import gradio as gr
5
  from datetime import datetime
6
  from typing import List, Dict, Any, Optional, Union
7
  import threading
8
-
9
- # Import ZeroGPU spaces
10
  import spaces
11
 
12
  # Import Groq
@@ -32,8 +30,7 @@ class CreativeAgenticAI:
32
  self.client = Groq(api_key=self.api_key)
33
  self.model = model
34
  self.conversation_history = []
35
-
36
- @spaces.GPU
37
  def chat(self, message: str,
38
  include_domains: List[str] = None,
39
  exclude_domains: List[str] = None,
@@ -161,7 +158,6 @@ class CreativeAgenticAI:
161
  ai_instance = None
162
  api_key_status = "Not Set"
163
 
164
- @spaces.GPU
165
  def validate_api_key(api_key: str, model: str) -> str:
166
  """Validate Groq API key and initialize AI instance"""
167
  global ai_instance, api_key_status
@@ -201,7 +197,6 @@ def update_model(model: str) -> str:
201
  else:
202
  return "⚠️ Please set your API key first"
203
 
204
- @spaces.GPU
205
  def chat_with_ai(message: str,
206
  include_domains: str,
207
  exclude_domains: str,
@@ -309,7 +304,7 @@ def create_gradio_app():
309
  gr.HTML("""
310
  <div class="header">
311
  <h1>πŸ€– NeuroScope-AI</h1>
312
- <p>Powered by Groq's Compound Models with Web Search & Agentic Capabilities | Enhanced with ZeroGPU</p>
313
  </div>
314
  """)
315
 
@@ -321,7 +316,6 @@ def create_gradio_app():
321
  - πŸ” Domain filtering (Scope)
322
  - πŸ€– AI capabilities (AI)
323
  - ⚑ Precision (Scope implies focused, targeted results)
324
- - πŸš€ Enhanced with ZeroGPU for optimized performance
325
  """)
326
  with gr.Group():
327
  with gr.Accordion("πŸ“š IMPORTANT !!!", open=False, elem_id="neuroscope-accordion"):
@@ -356,25 +350,14 @@ def create_gradio_app():
356
 
357
  ### 🎭 **Custom System Prompt Feature**
358
 
359
- Allows complete override of the AI's **default personality and behavior**.
360
  You can redefine the AI to act as:
361
 
362
  - A **professional business consultant**
363
  - A **coding mentor**
364
  - A **creative writer**
365
  - A **specific character or persona**
366
- - Provides full control to **reshape the AI's tone, expertise, and conversational style** with a single prompt.
367
-
368
- ---
369
-
370
- ### πŸš€ **ZeroGPU Integration**
371
-
372
- This application is enhanced with ZeroGPU for:
373
-
374
- - **Optimized GPU utilization** for AI inference
375
- - **Improved response times** and performance
376
- - **Efficient resource management** in cloud environments
377
- - **Better scalability** for multiple concurrent users
378
  """)
379
 
380
  # API Key Section
@@ -515,14 +498,12 @@ def create_gradio_app():
515
  - **Creative Responses**: Optimized for engaging and helpful conversations
516
  - **Memory**: Maintains conversation context throughout the session
517
  - **Customizable**: Adjust temperature, tokens, and system prompts
518
- - **ZeroGPU Enhanced**: Optimized performance with GPU acceleration
519
 
520
  ### πŸ’‘ Tips for Best Results
521
  - Be specific in your questions for better responses
522
  - Use domain filtering for specialized research
523
  - Adjust temperature: higher for creativity, lower for precision
524
  - Try different system prompts for different conversation styles
525
- - ZeroGPU ensures faster processing for complex queries
526
  """)
527
 
528
  # Sample Examples Section
@@ -588,8 +569,8 @@ def create_gradio_app():
588
  with gr.Accordion("πŸš€ About This Tool", open=True, elem_id="neuroscope-accordion"):
589
  gr.Markdown("""
590
  A Creative Agentic AI Chat Tool leverages Groq's powerful compound models to provide intelligent,
591
- context-aware responses with web search capabilities. Enhanced with ZeroGPU for optimal performance.
592
- Perfect for research, programming help, creative writing, and complex problem-solving.
593
 
594
  **Features:**
595
  - πŸ” Web search with domain filtering
@@ -597,15 +578,17 @@ def create_gradio_app():
597
  - πŸ’¬ Conversational memory and context
598
  - βš™οΈ Customizable parameters and prompts
599
  - 🎨 Creative and analytical capabilities
600
- - πŸš€ ZeroGPU acceleration for faster processing
601
- - ⚑ Optimized resource utilization
602
  """)
603
 
604
  return app
605
 
606
- # Main execution
607
- if __name__ == "__main__":
 
608
  app = create_gradio_app()
609
  app.launch(
610
  share=True
611
- )
 
 
 
 
5
  from datetime import datetime
6
  from typing import List, Dict, Any, Optional, Union
7
  import threading
 
 
8
  import spaces
9
 
10
  # Import Groq
 
30
  self.client = Groq(api_key=self.api_key)
31
  self.model = model
32
  self.conversation_history = []
33
+
 
34
  def chat(self, message: str,
35
  include_domains: List[str] = None,
36
  exclude_domains: List[str] = None,
 
158
  ai_instance = None
159
  api_key_status = "Not Set"
160
 
 
161
  def validate_api_key(api_key: str, model: str) -> str:
162
  """Validate Groq API key and initialize AI instance"""
163
  global ai_instance, api_key_status
 
197
  else:
198
  return "⚠️ Please set your API key first"
199
 
 
200
  def chat_with_ai(message: str,
201
  include_domains: str,
202
  exclude_domains: str,
 
304
  gr.HTML("""
305
  <div class="header">
306
  <h1>πŸ€– NeuroScope-AI</h1>
307
+ <p>Powered by Groq's Compound Models with Web Search & Agentic Capabilities</p>
308
  </div>
309
  """)
310
 
 
316
  - πŸ” Domain filtering (Scope)
317
  - πŸ€– AI capabilities (AI)
318
  - ⚑ Precision (Scope implies focused, targeted results)
 
319
  """)
320
  with gr.Group():
321
  with gr.Accordion("πŸ“š IMPORTANT !!!", open=False, elem_id="neuroscope-accordion"):
 
350
 
351
  ### 🎭 **Custom System Prompt Feature**
352
 
353
+ Allows complete override of the AI’s **default personality and behavior**.
354
  You can redefine the AI to act as:
355
 
356
  - A **professional business consultant**
357
  - A **coding mentor**
358
  - A **creative writer**
359
  - A **specific character or persona**
360
+ - Provides full control to **reshape the AI’s tone, expertise, and conversational style** with a single prompt.
 
 
 
 
 
 
 
 
 
 
 
361
  """)
362
 
363
  # API Key Section
 
498
  - **Creative Responses**: Optimized for engaging and helpful conversations
499
  - **Memory**: Maintains conversation context throughout the session
500
  - **Customizable**: Adjust temperature, tokens, and system prompts
 
501
 
502
  ### πŸ’‘ Tips for Best Results
503
  - Be specific in your questions for better responses
504
  - Use domain filtering for specialized research
505
  - Adjust temperature: higher for creativity, lower for precision
506
  - Try different system prompts for different conversation styles
 
507
  """)
508
 
509
  # Sample Examples Section
 
569
  with gr.Accordion("πŸš€ About This Tool", open=True, elem_id="neuroscope-accordion"):
570
  gr.Markdown("""
571
  A Creative Agentic AI Chat Tool leverages Groq's powerful compound models to provide intelligent,
572
+ context-aware responses with web search capabilities. Perfect for research, programming help,
573
+ creative writing, and complex problem-solving.
574
 
575
  **Features:**
576
  - πŸ” Web search with domain filtering
 
578
  - πŸ’¬ Conversational memory and context
579
  - βš™οΈ Customizable parameters and prompts
580
  - 🎨 Creative and analytical capabilities
 
 
581
  """)
582
 
583
  return app
584
 
585
+ # Main execution with ZeroGPU
586
+ @spaces.GPU
587
+ def main():
588
  app = create_gradio_app()
589
  app.launch(
590
  share=True
591
+ )
592
+
593
+ if __name__ == "__main__":
594
+ main()