title: Lesson 1 weight: 10 draft: true

TO BE REVIEWED!

๐Ÿ“˜ Lesson 1 โ€“ Integrated Services & First Exercise

Welcome! After launching and configuring your environment, ensure you're logged in to begin.


๐Ÿ“ฅ Downloading the Lesson

  1. In the extension, select Lesson 1 from the sidebar.
  2. This will automatically download all lesson files.
  3. You can preview the new lesson by selecting the markdown file under lessons/.

โœ… Lesson 0 was the environment setup. Lesson 1 is the first real lesson of the course.


๐Ÿงฐ Included “Hello” Examples

The hello package includes small examples demonstrating system services:

ServiceDescription
RedisCache operations (info, keys, etc.)
MilvusVector DB search using embedding
StreamerASCII-based output streaming
LLM (Alma)Query small language model
S3 StorageStore, list, upload & delete files
Tests2 failing tests to practice debugging

These examples are useful for testing, debugging, and learning the system APIs.


โœ… Running and Fixing Tests

  1. Run the tests (๐Ÿงช Tests tab).
  2. Two tests intentionally fail.
  3. Locate the TODO in the broken test.
  4. Example fix: change "Hi" to "Hello" and save.

Why Tests Still Fail After Fix?

  • โœ… Unit test will pass immediately.
  • โŒ Integration test will still fail โ€” it requires deployment!

Fix Integration Tests

# Deploy the fixed code
obs deploy

# Or just redeploy the specific action
obs ide deploy hello-llm

Enable Dev Mode (Devil) for automatic deploy on save.


๐ŸŒ Using the Deployed Examples

After deployment, youโ€™ll get a custom URL. Login with your user credentials.

Example Services Overview

1. ๐Ÿค– Alma (LLM)

  • Powered by a 3.18B parameter model
  • Works in Italian and English
  • Example:
    • Ask: What is the capital of Italy?
    • Response: Rome

2. ๐Ÿ”„ Streamer

  • Demonstrates streaming via slow ASCII output
  • Example: Hi, how are you? โ†’ streamed char-by-char

3. โšก Redis

  • Supports CLI-like interaction
  • Examples:
    info
    keys *
    

4. ๐Ÿ—‚๏ธ Object Storage (MinIO)

  • S3-compatible local storage
  • Commands: list, insert (+ key = value), search, delete
  • Supports file upload via UI

5. ๐Ÿ“š Vector DB (Milvus)

  • Supports semantic search
  • Example:
    This is a test
    Another test
    
    Then search: *test โ†’ shows ranked results by similarity

๐Ÿ”ง Command-Line Tools (OBS CLI)

Use obs or oops for CLI actions. Common subcommands:

obs ai lesson            # download lessons
obs ai user              # manage users
obs ai chat <svc>        # chat with an LLM from CLI
obs ide deploy <action>  # deploy a single action
obs action delete <svc>  # delete an action
obs clean                # cleanup temp files

obs ai chat is a terminal version of the web chat.


โœจ Creating a New Service: Reverse Text

Step-by-step: “Reverse Text” Chat App

  1. Ask Alma: “How do I reverse a string in Python?”
  2. Create the service:
obs ai new reverse -p messiah

This creates:

packages/
  messiah/
    reverse/      # your new action
    __tests__/
      reverse.unit.test.py
      reverse.int.test.py
  1. Run the tests โ†’ Integration test should fail initially
  2. Deploy:
obs deploy
  1. Add to UI:
    • Edit packages/mastrogpt/index/index.py
    • Add:
      reverse("messiah/reverse")
      
  2. Redeploy the index:
obs ide deploy mastrogpt-index
  1. Try it in the web UI:
    Log in โ†’ Select Reverse โ†’ Input: hello โ†’ Output: olleh

๐Ÿง  Edit Logic in Code

File: packages/messiah/reverse/main.py

def main(args):
    inp = args.get("input", "")
    if inp == "":
        return {"output": "Please provide an input"}
    else:
        out = inp[::-1]
        return {"output": f"**{out}**"}  # bold markdown

Use Dev Mode to auto-deploy as you edit.


โœ… Summary

You now:

  • Downloaded your first real lesson
  • Ran & fixed tests (unit + integration)
  • Explored system services: Redis, Alma, MinIO, Milvus, Streamer
  • Built and deployed a custom chat service
  • Learned how to modify and extend the UI

๐Ÿง‘โ€๐Ÿซ Up Next

Next lessons will:

  • Dive deeper into LLM usage
  • Cover vision models and embeddings
  • Show full-stack app development using Open Serverless

Happy hacking! ๐Ÿงช๐Ÿค–