Skip to content

Commit

Permalink
Merge pull request #12 from VishwamAI/feature/llm-ollama-integration
Browse files Browse the repository at this point in the history
Integrate ollama API into response generation module
  • Loading branch information
kasinadhsarma authored Aug 2, 2024
2 parents 727d50b + 17b3cdd commit a7beaf8
Show file tree
Hide file tree
Showing 5 changed files with 332 additions and 20 deletions.
44 changes: 38 additions & 6 deletions modules/response_generation.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
import os
import requests
from routellm import RouteLLMController

class ResponseGenerator:
def __init__(self):
# Placeholder for future implementation
pass
# Initialize RouteLLM controller
self.controller = RouteLLMController(
router="gpt-3.5-turbo",
models=["gpt-3.5-turbo", "gpt-4"],
api_key=os.environ.get('ROUTELLM_API_KEY')
)
# Initialize ollama API endpoint
self.ollama_api_url = "http://localhost:11434/api/generate"

def generate_response(self, threat_level):
# Generate a response based on the threat level
# Generate a response based on the threat level using RouteLLM
prompt = self._create_prompt(threat_level)
response = self.controller.chat.completions.create(
model="router:0.01", # Use router with 0.01 cost threshold
messages=[{"role": "system", "content": "You are an AI assistant for threat assessment and response generation."},
{"role": "user", "content": prompt}]
)
return response.choices[0].message.content

def generate_response_ollama(self, threat_level):
# Generate a response based on the threat level using ollama
prompt = self._create_prompt(threat_level)
payload = {
"model": "llama3.1",
"prompt": prompt
}
response = requests.post(self.ollama_api_url, json=payload)
if response.status_code == 200:
return response.json()['response']
else:
return f"Error: Unable to generate response. Status code: {response.status_code}"

def _create_prompt(self, threat_level):
if threat_level < 0.3:
return "No significant threat detected. Continue monitoring."
return "Generate a response for a low threat level situation."
elif threat_level < 0.7:
return "Moderate threat detected. Increase vigilance and prepare countermeasures."
return "Generate a response for a moderate threat level situation."
else:
return "High threat detected. Activate all defense systems and initiate containment protocols."
return "Generate a response for a high threat level situation."
14 changes: 0 additions & 14 deletions src/llama_response_generator.py

This file was deleted.

143 changes: 143 additions & 0 deletions website/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/* Global Styles */
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
line-height: 1.6;
color: #24292e;
margin: 0;
padding: 0;
background-color: #f6f8fa;
}

.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
display: flex;
}

/* Header Styles */
header {
background-color: #ffffff;
color: #24292e;
padding: 20px 0;
border-bottom: 1px solid #e1e4e8;
}

header h1 {
margin: 0;
font-size: 2em;
font-weight: 600;
}

nav {
background-color: #f6f8fa;
padding: 20px;
width: 250px;
height: calc(100vh - 60px);
position: fixed;
overflow-y: auto;
}

nav ul {
list-style-type: none;
padding: 0;
}

nav ul li {
margin-bottom: 10px;
}

nav ul li a {
color: #0366d6;
text-decoration: none;
font-weight: 500;
display: block;
padding: 5px 0;
}

nav ul li a:hover {
color: #0246a2;
}

/* Main Content Styles */
main {
flex-grow: 1;
padding: 40px;
margin-left: 250px;
background-color: #ffffff;
min-height: calc(100vh - 60px);
}

section {
margin-bottom: 40px;
}

h2 {
color: #24292e;
border-bottom: 1px solid #e1e4e8;
padding-bottom: 10px;
font-weight: 600;
}

h3 {
color: #24292e;
font-weight: 600;
}

ul {
padding-left: 20px;
}

/* Footer Styles */
footer {
background-color: #ffffff;
color: #586069;
padding: 20px 0;
text-align: center;
border-top: 1px solid #e1e4e8;
}

footer a {
color: #0366d6;
text-decoration: none;
}

/* Responsive Design */
@media (max-width: 768px) {
.container {
flex-direction: column;
}

nav {
width: 100%;
height: auto;
position: static;
padding: 10px;
}

main {
margin-left: 0;
padding: 20px;
}

header h1 {
font-size: 1.5em;
}
}

/* Accessibility */
a:focus, button:focus {
outline: 2px solid #0366d6;
}

.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
Empty file added website/favicon.ico
Empty file.
151 changes: 151 additions & 0 deletions website/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PikasuBirdAi Project Documentation</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<header>
<h1>PikasuBirdAi Project</h1>
<nav>
<ul>
<li><a href="#hardware-requirements">Hardware Requirements</a></li>
<li><a href="#technical-specifications">Technical Specifications</a></li>
<li><a href="#integration-plans">Integration Plans</a></li>
<li><a href="#future-considerations">Future Considerations</a></li>
</ul>
</nav>
</header>

<main>
<section id="hardware-requirements">
<h2>Hardware Requirements</h2>
<p>The PikasuBirdAi project requires specialized hardware components to ensure optimal performance in bird detection, identification, and analysis. The following key hardware components are essential:</p>
<h3>1. High-Performance Server Processing</h3>
<ul>
<li><strong>Nvidia A100 Tensor Core GPU:</strong> Recommended for state-of-the-art AI and HPC workloads, ideal for server-based processing of complex bird detection algorithms.</li>
<li><strong>AMD Instinct MI250X:</strong> Suitable for high-performance AI and scientific computing, perfect for training and running sophisticated bird analysis models.</li>
</ul>
<h3>2. On-Device Processing</h3>
<ul>
<li><strong>Apple Neural Engine (in A16 Bionic):</strong> Ideal for iOS-based mobile applications for field bird identification.</li>
<li><strong>Qualcomm Snapdragon 8 Gen 2 AI Engine:</strong> Recommended for Android-based mobile applications and field-deployable units.</li>
</ul>
<h3>3. Cloud-Based Processing</h3>
<ul>
<li><strong>AWS Trainium:</strong> Excellent for scalable processing of large datasets and complex model training in cloud environments.</li>
</ul>
<h3>4. Balanced Performance and Efficiency</h3>
<ul>
<li><strong>Intel Habana Gaudi2:</strong> Suitable for efficient training and deployment of bird detection models, offering a balance between performance and power efficiency.</li>
</ul>
<p>These hardware components are crucial for handling complex computations, reducing latency, and improving overall system performance in real-time bird monitoring and identification tasks.</p>
</section>

<section id="technical-specifications">
<h2>Technical Specifications</h2>
<p>The following are detailed technical specifications of the key hardware components used in the PikasuBirdAi project:</p>

<h3>1. Nvidia A100 Tensor Core GPU</h3>
<ul>
<li>Architecture: NVIDIA Ampere</li>
<li>CUDA Cores: 6912</li>
<li>Tensor Cores: 432 (3rd generation)</li>
<li>Memory: 40GB or 80GB HBM2e</li>
<li>Memory Bandwidth: Up to 2,039 GB/s</li>
<li>FP32 Performance: 19.5 TFLOPS</li>
<li>Tensor Float 32 (TF32) Performance: 156 TFLOPS</li>
<li>Power Consumption: 400W (SXM4)</li>
</ul>

<h3>2. AMD Instinct MI250X</h3>
<ul>
<li>Architecture: CDNA 2</li>
<li>Stream Processors: 14,080</li>
<li>Memory: 128GB HBM2e</li>
<li>Memory Bandwidth: 3.2 TB/s</li>
<li>FP32 Performance: 47.9 TFLOPS</li>
<li>FP16 Performance: 383 TFLOPS</li>
<li>Power Consumption: 560W</li>
</ul>

<h3>3. Apple Neural Engine (A16 Bionic)</h3>
<ul>
<li>Architecture: 16-core design</li>
<li>Performance: Up to 17 trillion operations per second</li>
<li>Process Node: 4nm</li>
<li>CPU: 6-core (2 performance + 4 efficiency)</li>
<li>GPU: 5-core</li>
<li>Memory: Integrated with system memory (varies by device)</li>
</ul>

<h3>4. Qualcomm Snapdragon 8 Gen 2</h3>
<ul>
<li>CPU: Octa-core Kryo (1x3.2 GHz Cortex-X3 + 2x2.8 GHz Cortex-A715 + 2x2.8 GHz Cortex-A710 + 3x2.0 GHz Cortex-A510)</li>
<li>GPU: Adreno 740</li>
<li>AI Engine: 4.35x AI performance improvement over previous gen</li>
<li>Process Node: 4nm</li>
<li>Memory: Support for LPDDR5X RAM</li>
</ul>

<h3>5. AWS Trainium</h3>
<ul>
<li>Performance: Up to 40% better price-performance vs GPU-based EC2 instances</li>
<li>Optimized for: PyTorch and TensorFlow</li>
<li>Integration: Seamless with AWS AI services</li>
<li>Scalability: Designed for large-scale distributed training</li>
</ul>

<h3>6. Intel Habana Gaudi2</h3>
<ul>
<li>Process Node: 7nm</li>
<li>Memory: 96GB HBM2e</li>
<li>Connectivity: 24x 100GbE RoCE v2 ports</li>
<li>AI Performance: Up to 5.6x faster than 1st gen Gaudi</li>
<li>Power Efficiency: Improved performance per watt compared to GPUs</li>
</ul>
</section>

<section id="integration-plans">
<h2>Integration Plans</h2>
<p>Overview of how different hardware components will be integrated into the PikasuBirdAi system.</p>
<!-- Add more detailed content here -->
</section>

<section id="future-considerations">
<h2>Future Considerations</h2>
<p>Discussion on future hardware upgrades, scalability, and energy efficiency improvements.</p>
<!-- Add more detailed content here -->
</section>

<section id="flying-mechanism">
<h2>Flying Mechanism</h2>
<p>The PikasuBirdAi project employs advanced flying mechanisms to achieve bird-like flight:</p>
<ul>
<li><strong>Cycloidal Drives:</strong> Used for wing actuation, providing compact and precise control over wing movements.</li>
<li><strong>Heat-Resistant Materials:</strong> Crucial for withstanding operational stresses and heat generated during flight.</li>
<li><strong>Wing Design:</strong> Focuses on rigidity to prevent excessive floppiness during flapping motion, ensuring efficient flight dynamics.</li>
</ul>
<!-- Add diagrams or images of the flying mechanism here -->
</section>

<section id="internal-memory">
<h2>Internal Memory</h2>
<p>The internal memory system is vital for the PikasuBirdAi's flight control and navigation:</p>
<ul>
<li><strong>Role in Flight Control:</strong> Enables real-time processing of sensor data and execution of flight algorithms.</li>
<li><strong>Navigation Support:</strong> Stores and processes map data and flight paths for autonomous navigation.</li>
<li><strong>Specifications:</strong> Utilizes high-speed, low-latency memory systems optimized for rapid data access and processing.</li>
</ul>
<!-- Add visual representation of the memory system architecture here -->
</section>
</main>

<footer>
<p>&copy; 2024 PikasuBirdAi Project. All rights reserved.</p>
<p>Contact: <a href="mailto:[email protected]">[email protected]</a></p>
</footer>
</body>
</html>

0 comments on commit a7beaf8

Please sign in to comment.