Friday, 21 February 2025

Deep Seek in colab

 Sure! Here’s your blog post in a funny and engaging style. 🎉


🔥 DeepSeek in Google Colab – The Ultimate Hacker’s Guide! 🔥

"Because why use your own GPU when you can borrow Google's for free?"

So, you wanna run DeepSeek on Google Colab without breaking the bank (or your laptop)? Buckle up, genius, because we’re about to hack—uh, I mean, legally use—Google’s free tier like absolute legends. 🚀


🛠 Step 1: Summon the Colab Genie

  • Log in to Google Colab like you own the place.
  • Name your notebook something fancy. I recommend First.ipynb because, you know, creativity.

🔧 Step 2: Summon a Terminal

A true hacker doesn't just click buttons—we type commands in a black box like it’s magic. 🧙‍♂️

Run this spell:

!pip install colab-xterm
%load_ext colabxterm
%xterm

💡 Pro Tip: If your screen suddenly goes black with green letters, congratulations! You’ve unlocked "Elite Hacker Mode." (Just kidding, it's just Colab being dramatic.)


📡 Step 3: Downloading Ollama (Because We’re That Cool)

Once your XTerm (a.k.a. secret hacking window) opens, whisper these words:

curl https://ollama.ai/install.sh | sh

Boom! You just installed Ollama. Take a sip of coffee and feel powerful. ☕😎

Next, summon it like a digital demon:

!ollama serve &

If Colab starts whispering to you, don’t worry. That’s just the AI waking up.


🧠 Step 4: Grab DeepSeek Like a Boss

!ollama pull deepseek-r1:1.5b

You just downloaded a 1.5B parameter AI model onto Google’s dime. Congrats! Jeff Bezos might be watching now. 👀


💡 Step 5: Making DeepSeek Do Our Homework

Now, let’s make this AI actually work for us. 🛠

Install the secret sauce:

%pip install -U langchain-ollama

Then, whisper some ancient Python magic:

from langchain_core.prompts import ChatPromptTemplate
from langchain_ollama.llms import OllamaLLM

template = """Question: {question}
Answer: Let's think step by step."""

prompt = ChatPromptTemplate.from_template(template)
model = OllamaLLM(model="deepseek-r1:1.5b")
chain = prompt | model

chain.invoke({"question": "What is MoE in AI?"})

💥 BAM! Now you have DeepSeek thinking like an AI philosopher about Mixture of Experts (MoE).


🤖 What Did DeepSeek Say?

DeepSeek: "Hmm, let me think… MoE could be Mixture of Experts, but what if it’s a top-secret AI term only known to five people on Earth? Maybe it’s a typo. Maybe I should just ask ChatGPT instead. Wait, I am the AI. OH NO, EXISTENTIAL CRISIS."



 

TL;DR? DeepSeek thinks way too much.


🛑 Final Words: Did We Just Hack the AI Matrix?

  • Google’s GPU? Borrowed.
  • DeepSeek? Running.
  • Our brains? Slightly confused but feeling powerful.

Now go forth, AI wizard. May your Colab instances last forever (or at least until Google shuts you down). ⚡💻


🚀 Share this with your hacker friends before Google finds out! 😆

Thursday, 20 February 2025

Angular Material Typography

🎨 Angular Material Typography: Make Your App Look Fancy!

What is Typography? 🤔

Typography is just a fancy way of saying, “Let’s make text look cool!” It’s all about making words readable, stylish, and visually appealing. Angular Material uses Material Design typography rules to keep things neat and consistent.


👣 Step 1: Start a New Angular Project

Open your terminal (or pretend you’re hacking into a mainframe 💻) and type:

ng new my-ang-type --style=scss --defaults
cd my-ang-type

Boom! You just created a fresh Angular project. 🎉


📦 Step 2: Install Angular Material

We need Angular Material to get those pro-level fonts. Run:

ng add @angular/material

Think of this as adding a fashionable wardrobe for your text. 😎


📝 Step 3: Edit app.component.html

Delete everything inside src/app.component.html. Let’s give it a fresh new look:

<h1>Angular Material Typography</h1> <br><br>
<h2>Jackdaws love my big sphinx of quartz.</h2><br><br>
<h3>The quick brown fox jumps over the lazy dog</h3><br><br>
<h4>The quick brown fox jumps over the lazy dog</h4><br><br>
<h5>The quick brown fox jumps over the lazy dog</h5><br><br>
<router-outlet />

Why these sentences? Because they contain every letter in the English alphabet! 🧐


🔎 Step 4: Pick a Fancy Font

Go to Google Fonts and grab something stylish like:
Roboto (default)
Poppins (for extra elegance ✨)
Coiny (for a fun, playful look 😆)
Karla Tamil Upright (because why not?)


🎨 Step 5: Update styles.css

Now, let’s dress up our app by changing the default font in src/styles.css:

html, body { height: 100%; }
body { margin: 0; font-family: 'Poppins', sans-serif; }

Want a different style? Just swap 'Poppins' with another font name.


🚀 Step 6: Run Your App

Time to check out your Typography masterpiece! Run:

ng serve

Go to http://localhost:4200 and admire your stylish text!


💡 Bonus: Showcasing All HTML5 Tags

Want a cool HTML5 reference page? Ask ChatGPT to:

"Create a sample HTML file to showcase all tags in HTML5"

You may get as below:

<!-- <h1>Angular Material Typography</h1> <br><br>
<h2>Jackdaws love my big sphinx of quartz.</h2><br><br>
<h3>The quick brown fox jumps over the lazy dog</h3><br><br>
<h4>The quick brown fox jumps over the lazy dog</h4><br><br>
<h5>The quick brown fox jumps over the lazy dog</h5><br><br>
<router-outlet /> -->


<!DOCTYPE html>
<html lang="en">
<!-- <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML5 Showcase</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 20px;
            padding: 20px;
            background: #f4f4f4;
        }
        header, nav, section, article, aside, footer {
            padding: 15px;
            margin-bottom: 10px;
            background: white;
            border-radius: 5px;
            box-shadow: 2px 2px 10px rgba(0,0,0,0.1);
        }
        table, th, td { border: 1px solid black; border-collapse: collapse; padding: 8px; }
        progress { width: 100%; }
    </style>
</head> -->
<body>

    <header>
        <h1>Welcome to HTML5 Showcase</h1>
        <p>Demonstrating various HTML5 elements in one page!</p>
    </header>

    <nav>
        <ul>
            <li><a href="#forms">Forms</a></li>
            <li><a href="#multimedia">Multimedia</a></li>
            <li><a href="#tables">Tables</a></li>
            <li><a href="#lists">Lists</a></li>
        </ul>
    </nav>

    <section>
        <h2>Semantic Elements</h2>
        <article>
            <h3>Article Section</h3>
            <p>This is an example of an article. It can contain multiple paragraphs and sections.</p>
        </article>

        <aside>
            <h3>Aside Section</h3>
            <p>Side content like related links, ads, or information.</p>
        </aside>
    </section>

    <section id="forms">
        <h2>Forms & Inputs</h2>
        <form>
            <label for="name">Name:</label>
            <input type="text" id="name" placeholder="Enter your name" required><br><br>

            <label for="email">Email:</label>
            <input type="email" id="email" placeholder="Enter your email"><br><br>

            <label for="password">Password:</label>
            <input type="password" id="password"><br><br>

            <label for="dob">Date of Birth:</label>
            <input type="date" id="dob"><br><br>

            <label for="color">Favorite Color:</label>
            <input type="color" id="color"><br><br>

            <label for="range">Range:</label>
            <input type="range" id="range" min="1" max="100"><br><br>

            <input type="checkbox" id="agree">
            <label for="agree">I agree to the terms</label><br><br>

            <button type="submit">Submit</button>
        </form>
    </section>

    <section id="multimedia">
        <h2>Multimedia Elements</h2>

        <h3>Audio</h3>
        <audio controls>
            <source src="sample.mp3" type="audio/mpeg">
            Your browser does not support the audio element.
        </audio>

        <h3>Video</h3>
        <video width="320" height="240" controls>
            <source src="sample.mp4" type="video/mp4">
            Your browser does not support the video tag.
        </video>

        <h3>Canvas Drawing</h3>
        <canvas id="myCanvas" width="200" height="100" style="border:1px solid #000;"></canvas>
        <script>
            let c = document.getElementById("myCanvas");
            let ctx = c.getContext("2d");
            ctx.fillStyle = "red";
            ctx.fillRect(10, 10, 150, 80);
        </script>
    </section>

    <section id="tables">
        <h2>Tables</h2>
        <table>
            <tr>
                <th>Name</th>
                <th>Age</th>
                <th>Country</th>
            </tr>
            <tr>
                <td>Alice</td>
                <td>25</td>
                <td>USA</td>
            </tr>
            <tr>
                <td>Bob</td>
                <td>30</td>
                <td>Canada</td>
            </tr>
        </table>
    </section>

    <section id="lists">
        <h2>Lists</h2>
        <h3>Ordered List</h3>
        <ol>
            <li>First Item</li>
            <li>Second Item</li>
            <li>Third Item</li>
        </ol>

        <h3>Unordered List</h3>
        <ul>
            <li>Item A</li>
            <li>Item B</li>
            <li>Item C</li>
        </ul>

        <h3>Description List</h3>
        <dl>
            <dt>HTML</dt>
            <dd>HyperText Markup Language</dd>
            <dt>CSS</dt>
            <dd>Cascading Style Sheets</dd>
        </dl>
    </section>

    <section>
        <h2>Interactive Elements</h2>
        <details>
            <summary>Click to expand details</summary>
            <p>This is additional hidden content.</p>
        </details>

        <h3>Progress Bar</h3>
        <progress value="70" max="100"></progress>

        <h3>Meter (Fuel Level)</h3>
        <meter value="60" min="0" max="100">60%</meter>
    </section>

    <footer>
        <p>&copy; 2025 HTML5 Showcase. All Rights Reserved.</p>
    </footer>

</body>
</html>


Copy the generated HTML file, and paste in to app.component.html file [keeping only body contents] now you have a super reference page for future projects! 🚀


🎉 And That’s It for Basics!

Congratulations! You just leveled up your typography game in Angular Material. Now, your app won’t just function well—it’ll look amazing too! 🏆

Happy Coding! 😃🚀

Angular Material Theming color

🎨 Angular Material Theming - A Step-by-Step Guide

Hey there, coding wizards! 🧙‍♂️ Ready to add some serious style to your Angular app? Let’s explore Angular Material Theming step by step and make your UI stunning! ✨


📌 Start Here: Learn the Basics

Before we begin, check out these essential resources on Angular Material:

1️⃣ Components Overview 👉 Material Components
2️⃣ Theming Basics 👉 Material Theming
3️⃣ In-Depth Theming Guide 👉 Complete Theming Guide


⚙️ Hands-on: Create an Angular Project with Material

Follow these quick steps to set up your Angular app with Material theming! 🚀

🛠️ Step 1: Create a New Angular App

Run this command in your terminal:

ng new my-app --style=scss --defaults

👉 This will set up an Angular app with SCSS as the default styling.


🎨 Step 2: Add Angular Material

Install Angular Material with this command:

ng add @angular/material

✔️ Select CUSTOM for the theme.
✔️ Choose Yes (Y) for typography.
✔️ Choose Yes (Y) for animations.


🌈 Step 3: Generate a Custom Theme

💡 Create a custom Material theme with:

ng g @angular/material:theme-color

✔️ Choose colors:

  • Primary color: #00796B (A cool teal shade 🌿).
  • Secondary, Tertiary, Neutral colors: Pick anything you like!
    ✔️ Set the directory: src/app/theme/greentheme
    ✔️ Skip SCSS file: We want a CSS file instead.

🎯 Step 4: Apply Your Theme

Modify styles.scss

1️⃣ Comment out the default Material theme import

// @use "@angular/material" as mat;

2️⃣ Add your custom theme import:

@import "./app/theme/greentheme.css";

📌 Step 5: Update Your UI with Themed Components

Modify app.component.html

Replace the contents of app.component.html with:

<h1>Angular Material Color Theme Demo</h1>

<section>
  <div class="example-label">Basic</div>
  <div class="example-button-row">
    <button mat-button>Basic</button>
    <button mat-button disabled>Disabled</button>
    <a mat-button href="https://www.google.com/" target="_blank">Link</a>
  </div>
</section>

<section>
  <div class="example-label">Raised</div>
  <div class="example-button-row">
    <button mat-raised-button>Basic</button>
    <button mat-raised-button disabled>Disabled</button>
    <a mat-raised-button href="https://www.google.com/" target="_blank">Link</a>
  </div>
</section>

<section>
  <div class="example-label">Stroked</div>
  <div class="example-button-row">
    <button mat-stroked-button>Basic</button>
    <button mat-stroked-button disabled>Disabled</button>
    <a mat-stroked-button href="https://www.google.com/" target="_blank">Link</a>
  </div>
</section>

🔥 Now, your app will have styled buttons using your custom theme!


⚡ Step 6: Update app.component.ts

Modify the contents of app.component.ts to import the required Material modules:

import { RouterOutlet } from '@angular/router';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { Component } from '@angular/core';
import { MatDividerModule } from '@angular/material/divider';

@Component({
  selector: 'app-root',
  imports: [RouterOutlet, MatButtonModule, MatIconModule, MatDividerModule],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent {
  title = 'my-app';
}

🚀 Step 7: Run and Enjoy Your Themed App!

Once everything is set, launch your app:

ng serve -o

🔥 This opens the app in your browser with your custom Material theme applied! 🎨


🎉 Wrapping Up

Congrats! 🎉 You’ve successfully:
✅ Created an Angular app with Material.
✅ Installed Material and customized a theme.
✅ Applied the theme to buttons and UI elements.

👨‍🎨 Next Steps?
🔹 Try changing the theme colors.
🔹 Explore Material Typography and Density.
🔹 Add more Material components (cards, toolbars, forms).

🚀 Go ahead, make your app look amazing! ✨ Happy coding! 🎨🔥

Monday, 17 February 2025

Temp Angular for IMMSS

Step 1

 ng new directive-demo

cd directive-demo

Step 2:

Open app.component.ts file and puth the contents as below:


import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { NgFor, NgClass, NgIf } from '@angular/common';


@Component({

  selector: 'app-root',
  imports: [CommonModule,NgFor, NgIf, NgClass],
  templateUrl: './app.component.html',
  styleUrl: './app.component.css'
})
export class AppComponent {
  title = 'directive-demo';
  movies = [
    'Amaran',
    'Coolie',
    'Vikram',
    'Pushpa',
    'Animal'
  ]
}

---------------------------------------------------------------------------------------------------------------

Open app.component.html and put the contents as follows:

li<h1>
  ngFor Example
</h1>
<ul>
  <li *ngFor="let movie of movies">{{movie}}</li>
</ul>


<!-- index -->
<h3> index Example</h3>
<ul>
  <li *ngFor="let movie of movies; let i = index">
   {{i+1}}-{{movie}}</li>
</ul>

<!-- First and Last  -->
 <h3> First and Last Example</h3>
<ul>
  <li *ngFor="let movie of movies; let isFirst=first; let isLast=last">
  <strong *ngIf="isFirst">First:</strong>
  <strong *ngIf="isLast">Last:</strong>
    {{movie}}
  </li>
</ul>


<!-- Odd & Event  -->
<h3>
    ngFor ODD & even Example
</h3>
<ul>
  <li *ngFor="let movie of movies; let isEven= even; let isOdd=odd;"
      [ngClass]="{'even-item': isEven, 'odd-item': isOdd}"
  >
         {{movie}}
  </li>
</ul>

---------------------------------------------------------------------------------------------------------------

Open the file app.component.css and the make the contents as shown:

.even-item {
    background-color: rgb(139, 216, 139);
}
.odd-item {
    background-color: rgb(235, 238, 241);
}

---------------------------------------------------------------------------------------------------------------

ng serve to see the browser similar to as shown below


Friday, 14 February 2025

Temp Teaching Agents


Converting the UI to Angular Material for Angular 17+

Since Angular 17+ introduced Standalone Components and Signal-Based State Management, we'll build the company website using Angular Material with the latest best practices.


Step 1: Create a New Angular Project

Ensure you have Angular 17+ installed. If not, update your CLI:

npm install -g @angular/cli

Create a new Angular project:

ng new company-website --standalone

Navigate into the project folder:

cd company-website

Step 2: Install Angular Material

Run the following command:

ng add @angular/material
  • Choose a theme (e.g., Indigo/Pink).
  • Enable global typography and animations.

Step 3: Set Up Routing

Since the website has multiple pages, enable routing during project creation. If skipped, add it manually:

Edit app.config.ts:

import { ApplicationConfig } from '@angular/core';
import { provideRouter, Routes } from '@angular/router';
import { importProvidersFrom } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';

import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { ServicesComponent } from './services/services.component';
import { ContactComponent } from './contact/contact.component';

const routes: Routes = [
  { path: '', component: HomeComponent },
  { path: 'about', component: AboutComponent },
  { path: 'services', component: ServicesComponent },
  { path: 'contact', component: ContactComponent },
];

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),
    provideAnimations(),
  ],
};

Step 4: Create Standalone Components

Run the following commands:

ng g component home --standalone
ng g component about --standalone
ng g component services --standalone
ng g component contact --standalone
ng g component navbar --standalone
ng g component footer --standalone

Each component will be created as a Standalone Component.


Step 5: Create Navigation (Header & Footer)

5.1: Navbar using Angular Material

Modify navbar.component.ts:

import { Component } from '@angular/core';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatButtonModule } from '@angular/material/button';
import { RouterModule } from '@angular/router';

@Component({
  selector: 'app-navbar',
  standalone: true,
  imports: [MatToolbarModule, MatButtonModule, RouterModule],
  templateUrl: './navbar.component.html',
  styleUrls: ['./navbar.component.css']
})
export class NavbarComponent {}

Modify navbar.component.html:

<mat-toolbar color="primary">
  <span>Company Name</span>
  <span class="spacer"></span>
  <a mat-button routerLink="/">Home</a>
  <a mat-button routerLink="/about">About</a>
  <a mat-button routerLink="/services">Services</a>
  <a mat-button routerLink="/contact">Contact</a>
</mat-toolbar>

Modify navbar.component.css:

.spacer {
  flex: 1;
}

Include <app-navbar></app-navbar> in app.component.html.


5.2: Footer with Social Media Links

Modify footer.component.ts:

import { Component } from '@angular/core';
import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon';

@Component({
  selector: 'app-footer',
  standalone: true,
  imports: [MatDividerModule, MatIconModule],
  templateUrl: './footer.component.html',
  styleUrls: ['./footer.component.css']
})
export class FooterComponent {}

Modify footer.component.html:

<footer>
  <mat-divider></mat-divider>
  <p>© 2025 Company Name</p>
  <div class="social-links">
    <a href="https://www.facebook.com" target="_blank">
      <mat-icon>facebook</mat-icon>
    </a>
    <a href="https://wa.me/yourwhatsappnumber" target="_blank">
      <mat-icon>chat</mat-icon>
    </a>
    <a href="https://www.instagram.com" target="_blank">
      <mat-icon>photo_camera</mat-icon>
    </a>
    <a href="https://twitter.com" target="_blank">
      <mat-icon>public</mat-icon>
    </a>
  </div>
</footer>

Modify footer.component.css:

footer {
  text-align: center;
  padding: 10px;
  background: #3f51b5;
  color: white;
}
.social-links a {
  color: white;
  text-decoration: none;
  margin: 0 10px;
  padding: 0 5px;
}

Include <app-footer></app-footer> in app.component.html.


Step 6: Build the Home Page with a Stunning Hero Section

Modify home.component.ts:

import { Component } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';

@Component({
  selector: 'app-home',
  standalone: true,
  imports: [MatButtonModule, MatCardModule],
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent {}

Modify home.component.html:

<mat-card class="hero">
  <div class="hero-content">
    <h1>Welcome to Our Company</h1>
    <p>Your success starts here.</p>
    <button mat-raised-button color="accent" routerLink="/services">Our Services</button>
  </div>
</mat-card>

Modify home.component.css:

.hero {
  height: 80vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: url('https://source.unsplash.com/1600x900/?business,technology') no-repeat center center/cover;
  color: white;
}

.hero-content {
  background: rgba(0, 0, 0, 0.5);
  padding: 20px;
  border-radius: 10px;
}

Step 7: Develop Other Pages

Modify about.component.html, services.component.html, and contact.component.html using MatCard for content presentation.

Example for about.component.html:

<mat-card>
  <mat-card-title>About Us</mat-card-title>
  <mat-card-content>
    <p>We are a leading company in...</p>
  </mat-card-content>
</mat-card>

Step 8: Run & Test the Application

Start the Angular development server:

ng serve
  • Open http://localhost:4200/ in your browser.
  • Navigate through pages and test the UI.

Step 9: Deploy the Website

To deploy the website using GitHub Pages, run:

ng build --output-path docs --base-href /company-website/

Commit and push changes, then enable GitHub Pages in the repository settings.


Final Notes

✅ You have successfully built a stunning Angular 17+ Material company website! 🚀
Let me know if you need further enhancements! 🎉

________________________________________________________________________

 Creating a Teaching Agent using Pydantic-based RAG for Probability and Statistics involves multiple steps:

  • Loading a textbook (PDF).
  • Extracting key concepts.
  • Generating structured lectures.
  • Using RAG for answering queries.

📌 Lecture Schedule for "Probability and Statistics"

(Assumption: Using a standard Probability & Statistics textbook in PDF format.)

⏳ 3-Hour Lecture Plan

Time Topic Key Concepts
Hour 1 Introduction to Probability & Statistics Definitions, Importance, Applications
Hour 1.5 Probability Basics Sample Spaces, Events, Probability Axioms
Hour 2 Random Variables & Distributions Discrete vs. Continuous, PMF, PDF, CDF
Hour 2.5 Statistical Measures Mean, Variance, Standard Deviation
Hour 3 Inferential Statistics & Hypothesis Testing Confidence Intervals, p-values

📌 Python Code for Teaching Agent Using Pydantic RAG

Here’s a step-by-step implementation of a RAG-based teaching assistant using Pydantic and ChromaDB.

1️⃣ Load and Extract Knowledge from PDF

from PyPDF2 import PdfReader
from pydantic import BaseModel
import chromadb

# Define a structured format for storing extracted content
class LectureContent(BaseModel):
    title: str
    text: str

# Load and extract content from a PDF
def extract_text_from_pdf(pdf_path):
    reader = PdfReader(pdf_path)
    text = "\n".join([page.extract_text() for page in reader.pages if page.extract_text()])
    return text

# Example Usage
pdf_content = extract_text_from_pdf("Probability_and_Statistics.pdf")
print("PDF Loaded Successfully!")

2️⃣ Store Extracted Knowledge in ChromaDB

from chromadb.config import Settings

# Initialize ChromaDB
client = chromadb.Client(Settings(persist_directory="chroma_db", chroma_db_impl="duckdb+parquet"))

# Create a collection for lectures
collection = client.get_or_create_collection(name="probability_statistics_knowledge")

# Store structured lecture content
lecture = LectureContent(title="Probability Basics", text=pdf_content)
collection.add(
    documents=[lecture.text],
    metadatas=[{"title": lecture.title}]
)
print("Lecture Content Stored in ChromaDB!")

3️⃣ Query the Knowledge Base Using RAG

from scipy.spatial.distance import cosine
import openai

openai.api_key = "YOUR_OPENAI_API_KEY"

# Generate embeddings using OpenAI
def generate_embedding(text):
    response = openai.Embedding.create(input=text, model="text-embedding-ada-002")
    return response["data"][0]["embedding"]

# Query ChromaDB for the most relevant lecture
def query_lecture(query):
    query_embedding = generate_embedding(query)
    results = collection.query(query_embeddings=[query_embedding], n_results=3)
    return results

# Test Query
user_query = "What is the probability of independent events?"
results = query_lecture(user_query)

# Print the most relevant lecture content
for doc, meta in zip(results["documents"], results["metadatas"]):
    print(f"Topic: {meta['title']}\nContent: {doc}\n")

4️⃣ Interactive Teaching Agent Using Gradio

import gradio as gr

# Teaching Agent Function
def teaching_agent(query):
    results = query_lecture(query)
    if results["documents"]:
        return f"Topic: {results['metadatas'][0]['title']}\n\nAnswer: {results['documents'][0]}"
    return "No relevant information found in the knowledge base."

# Gradio Interface
def create_interface():
    with gr.Blocks() as demo:
        gr.Markdown("## Probability & Statistics Teaching Agent")

        question_input = gr.Textbox(label="Ask a Question", placeholder="Enter your question...")
        output = gr.Textbox(label="Answer", interactive=False)
        query_button = gr.Button("Get Answer")

        query_button.click(teaching_agent, inputs=[question_input], outputs=output)

    return demo

if __name__ == "__main__":
    interface = create_interface()
    interface.launch()

✨ Features of the Teaching Agent

1️⃣ Loads a Probability & Statistics textbook in PDF.
2️⃣ Extracts and structures lecture content using Pydantic.
3️⃣ Stores knowledge in ChromaDB for fast retrieval.
4️⃣ Uses OpenAI embeddings for RAG-based search.
5️⃣ Provides a chatbot interface using Gradio.


📌 Next Steps

  • Extend RAG to Web Content: Load Wikipedia & research papers.
  • Enhance Query Understanding: Fine-tune retrieval using cosine similarity.
  • Voice Integration: Convert text responses into speech.

This teaching agent makes learning Probability & Statistics more interactive and intelligent! 🚀 Let me know if you need more enhancements! 🎯



Agent Demo

1. Basic Agent

## Basic Agent
from agno.agent import Agent, RunResponse
from agno.models.ollama import Ollama

agent = Agent(
    model=Ollama(id="llama3.2"),
    markdown=True
)

# Print the response in the terminal
agent.print_response("What is Ministry of Corporate Affairs in India?
what it does?")



Response:




2. Web Search Agent

## Agents with Tools
# Pip install phidata, duckduckgo-search, arxiv
from agno.agent import Agent
from agno.models.ollama import Ollama
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.arxiv import ArxivTools

agent = Agent(
    model=Ollama(id="llama3.2"),
    # tools=[DuckDuckGoTools()],
    tools=[DuckDuckGoTools(), ArxivTools()],
    show_tool_calls=True,
    markdown=True
)

# Print the response in the terminal
# agent.print_response("What do you think of the Latest news on
US deporting migrants.")
#agent.print_response("Give me some latest news
in Indian Politics.")
# agent.print_response("What is 23+89.")
agent.print_response("Search arxiv for 'Reinforcement Learning")


Response:


3. Chat_Agent :

#pip install pydantic requests streamlit ollama

import streamlit as st
from pydantic import BaseModel
import ollama

# 🎭 Define AI Agent
class AIAgent(BaseModel):
    name: str = "OllamaBot"
    version: str = "1.0"
    description: str = "A chatbot powered by Ollama LLM."

agent = AIAgent()

# 🛠️ Streamlit UI
st.title("🤖 iMMSS LLM for Legal Assistance")
st.write("Ask anything! (Type 'exit' to stop)")

# 🎤 Initialize chat history
if "messages" not in st.session_state:
    st.session_state.messages = []

# 🚀 Display chat history
for msg in st.session_state.messages:
    st.write(msg)

# 🎤 User Input
user_query = st.text_input("You:", "")

# 🧠 Function to get AI response
def get_ai_response(question: str):
    response = ollama.chat(model="llama3.2", messages=[{"role": "user", "content": question}])
    return response["message"]["content"]

# 🚀 Process User Query
if user_query:
    if user_query.lower() == "exit":
        st.write("👋 Chatbot: Goodbye! Closing chat...")
        st.stop()

    # Get AI response
    ai_answer = get_ai_response(user_query)

    # Append user and bot messages to session state
    st.session_state.messages.append(f"**You:** {user_query}")
    st.session_state.messages.append(f"**{agent.name}:** {ai_answer}")

    # Display AI response
    st.write(f"**{agent.name}:** {ai_answer}")


Response:

















Deep Seek in colab

 Sure! Here’s your blog post in a funny and engaging style. 🎉 🔥 DeepSeek in Google Colab – The Ultimate Hacker’s Guide! 🔥 "Beca...