Gen AI Developer Classroom notes 03/Sep/2025

Handling the Source updates (files/folders)

  • For this we need to update the metadata
raw_documents[0].metadata.update({
    "category": "HR",
    "department": "PGE"
})

Running uv Package

Got it πŸ‘ You want to create a Python package using uv (a super-fast Python package manager) and run it locally. Let me guide you step by step.


βœ… Steps to Create & Run a Package with uv

1. Install uv (if not already installed)

curl -LsSf https://astral.sh/uv/install.sh | sh

or with pipx:

pipx install uv

Check installation:

uv --version

2. Create a New Project

Use uv to create a new Python project:

uv init mypackage
cd mypackage

This will create a structure like:

mypackage/
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ README.md
└── src/
    └── mypackage/
        └── __init__.py

3. Add Some Code

Edit src/mypackage/__init__.py:

def greet(name: str) -> str:
    return f"Hello, {name}!"

4. Run Code Locally

Option A: Run in a REPL

uv run python

Inside Python:

from mypackage import greet
print(greet("Khaja"))

Option B: Run a Script

Create a script src/mypackage/main.py:

from mypackage import greet

if __name__ == "__main__":
    print(greet("Khaja"))

Run it with:

uv run src/mypackage/main.py

5. Install Your Package Locally

You can install it into an environment:

uv pip install -e .

Now you can just do:

uv run python -m mypackage.main

RecordManager

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug package entrypoint",
            "type": "debugpy",
            "request": "launch",
            "program": "${workspaceFolder}/src/kb_articles_rag_prd/__init__.py",
            "console": "integratedTerminal"
        }
    ]
}

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading