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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -14
app.py CHANGED
@@ -5,6 +5,8 @@ import gradio as gr
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,7 +32,8 @@ class CreativeAgenticAI:
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,6 +161,7 @@ class CreativeAgenticAI:
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,6 +201,7 @@ def update_model(model: str) -> str:
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,7 +309,7 @@ def create_gradio_app():
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,6 +321,7 @@ def create_gradio_app():
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,15 +356,25 @@ def create_gradio_app():
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
 
364
  # API Key Section
@@ -499,12 +515,14 @@ def create_gradio_app():
499
  - **Creative Responses**: Optimized for engaging and helpful conversations
500
  - **Memory**: Maintains conversation context throughout the session
501
  - **Customizable**: Adjust temperature, tokens, and system prompts
 
502
 
503
  ### πŸ’‘ Tips for Best Results
504
  - Be specific in your questions for better responses
505
  - Use domain filtering for specialized research
506
  - Adjust temperature: higher for creativity, lower for precision
507
  - Try different system prompts for different conversation styles
 
508
  """)
509
 
510
  # Sample Examples Section
@@ -570,8 +588,8 @@ def create_gradio_app():
570
  with gr.Accordion("πŸš€ About This Tool", open=True, elem_id="neuroscope-accordion"):
571
  gr.Markdown("""
572
  A Creative Agentic AI Chat Tool leverages Groq's powerful compound models to provide intelligent,
573
- context-aware responses with web search capabilities. Perfect for research, programming help,
574
- creative writing, and complex problem-solving.
575
 
576
  **Features:**
577
  - πŸ” Web search with domain filtering
@@ -579,17 +597,15 @@ def create_gradio_app():
579
  - πŸ’¬ Conversational memory and context
580
  - βš™οΈ Customizable parameters and prompts
581
  - 🎨 Creative and analytical capabilities
 
 
582
  """)
583
 
584
  return app
585
 
586
- # Main execution with ZeroGPU
587
- @spaces.GPU
588
- def main():
589
  app = create_gradio_app()
590
  app.launch(
591
  share=True
592
- )
593
-
594
- if __name__ == "__main__":
595
- main()
 
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
  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
  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
  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
  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
  - πŸ” 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
 
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
  - **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
  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
  - πŸ’¬ 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
+ )