Skip to main content

No project description provided

Project description

Lamoom

Our Philosophy

Lamoom, derived from "Lambda on Mechanisms," refers to computation within a system that iteratively guides the LLM to perform correctly. Inspired by Amazon's culture, as Jeff Bezos said, "Good intentions don't work, mechanisms do," we focus on building mechanisms for LLMs rather than relying on their good intentions

Lamoom Mechanisms

Introduction

Lamoom is a dynamic, all-in-one library designed for managing and optimizing prompts and making tests based on the ideal answer for large language models (LLMs) in production and R&D. It facilitates dynamic data integration, latency and cost metrics visibility, and efficient load distribution across multiple AI models.

Lamoom Introduction Video

Getting Started

To help you get started quickly, you can explore our Getting Started Notebook which provides step-by-step examples of using Lamoom.

Features

  • CI/CD testing: Generates tests based on the context and ideal answer (usually written by the human).
  • Dynamic Prompt Development: Avoid budget exceptions with dynamic data.
  • Multi-Model Support: Seamlessly integrate with various LLMs like OpenAI, Anthropic, and more.
  • Real-Time Insights: Monitor interactions, request/response metrics in production.
  • Prompt Testing and Evaluation: Quickly test and iterate on prompts using historical data.
  • Smart Prompt Caching: Efficiently cache prompts for 5 minutes to reduce latency while keeping them updated.
  • Asynchronous Logging: Record interactions without blocking the main execution flow.

Core Functionality

Prompt Management and Caching

Lamoom implements an efficient prompt caching system with a 5-minute TTL (Time-To-Live):

  • Automatic Updates: When you call a prompt, Lamoom checks if a newer version exists on the server.
  • Cache Invalidation: Prompts are automatically refreshed after 5 minutes to ensure up-to-date content.
  • Local Fallback: If the LamoomService is unavailable, Lamoom library falls back to the locally defined prompt.
  • Version Control: Track prompt versions between local and server instances.

Lamoom Call Flow

Test Generation and CI/CD Integration

Lamoom supports two methods for test creation:

  1. Inline Test Generation: Add test_data with an ideal answer during normal LLM calls to automatically generate tests.
  2. Direct Test Creation: Use the create_test() method to explicitly create tests for specific prompts.

Tests automatically compare LLM responses to ideal answers, helping maintain prompt quality as models or prompts evolve.

Test Creation Flow

Logging and Analytics

Interaction logging happens asynchronously using a worker pattern:

  • Performance Metrics: Automatically track latency, token usage, and cost.
  • Complete Context: Store the full prompt, context, and response for analysis.
  • Non-Blocking: Logging happens in the background without impacting response times.

Logging Flow

Feedback Collection

Improve prompt quality through explicit feedback:

  • Ideal Answer Addition: Associate ideal answers with previous responses using add_ideal_answer().
  • Continuous Improvement: Use feedback to automatically generate new tests and refine prompts.

Feedback Flow

Installation

Install Flow Prompt using pip:

pip install lamoom

Obtain an API token from Lamoom and add it as an env variable: LAMOOM_API_TOKEN ;

Getting Started

To help you get started quickly, you can explore our Getting Started Notebook which provides step-by-step examples of using Lamoom.

Authentication

Add Keys depending on models you're using:

# Add LAMOOM_API_TOKEN as an environment variable:
os.setenv('LAMOOM_API_TOKEN', 'your_token_here')

# add OPENAI_API_KEY
os.setenv('OPENAI_API_KEY', 'your_key_here')

# add Azure Keys
os.setenv('AZURE_KEYS', '{"name_realm":{"url": "https://baseurl.azure.com/","key": "secret"}}')
# or creating flow_prompt obj
Lamoom(azure_keys={"realm_name":{"url": "https://baseurl.azure.com/", "key": "your_secret"}})

Model Agnostic:

Mix models easily, and districute the load across models. The system will automatically distribute your load based on the weights. We support:

  • Claude
  • Gemini
  • OpenAI (w/ Azure OpenAI models)
  • Nebius with (Llama, DeepSeek, Mistral, Mixtral, dolphin, Qwen and others)

Model string format is the following for Claude, Gemini, OpenAI, Nebius: "{model_provider}/{model_name}" For Azure models format is the following: "azure/{realm}/{model_name}"

response_llm = client.call(agent.id, context, model = "openai/gpt-4o")
response_llm = client.call(agent.id, context, model = "azure/useast/gpt-4o")

Lamoom Keys

Obtain an API token from Flow Prompt and add it:

# As an environment variable:
os.setenv('LAMOOM_API_TOKEN', 'your_token_here')
# Via code: 
Lamoom(api_token='your_api_token')

Usage Examples:

Basic Usage

from lamoom import Lamoom, Prompt

# Initialize and configure Lamoom
client = Lamoom(openai_key='your_api_key', openai_org='your_org')

# Create a prompt
prompt = Prompt('greet_user')
prompt.add("You're {name}. Say Hello and ask what's their name.", role="system")

# Call AI model with Lamoom
context = {"name": "John Doe"}
response = client.call(prompt.id, context, "openai/gpt-4o")
print(response.content)

Creating Tests While Using Prompts

# Call with test_data to automatically generate tests
response = client.call(prompt.id, context, "openai/gpt-4o", test_data={
    'ideal_answer': "Hello, I'm John Doe. What's your name?", 
    'model_name': "gemini/gemini-1.5-flash"
})

Creating Tests Explicitly

# Create a test directly
client.create_test(
    prompt_id="greet_user",
    test_context={"name": "John Doe"},
    ideal_answer="Hello, I'm John Doe. What's your name?",
    model_name="gemini/gemini-1.5-flash"
)

Adding Feedback to Previous Responses

# Add an ideal answer to a previous response for quality assessment
client.add_ideal_answer(
    response_id="greet_user#1620000000000",
    ideal_answer="Hello, I'm John Doe. What's your name?"
)

Monitoring and Management

The system is designed to allow prompt updates without code redeployment—simply publish a new prompt version online, and the library will automatically fetch and use it.

Best Security Practices

For production environments, it is recommended to store secrets securely and not directly in your codebase. Consider using a secret management service or encrypted environment variables.

Contributing

We welcome contributions! Please see our Contribution Guidelines for more information on how to get involved.

License

This project is licensed under the Apache2.0 License - see the LICENSE file for details.

Contact

For support or contributions, please contact us via GitHub Issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lamoom-0.1.37.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lamoom-0.1.37-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file lamoom-0.1.37.tar.gz.

File metadata

  • Download URL: lamoom-0.1.37.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.11.11 Linux/6.8.0-1021-azure

File hashes

Hashes for lamoom-0.1.37.tar.gz
Algorithm Hash digest
SHA256 f16210cbcefb794100d8398b70feae90e5de46f4d23f2b80ed2f13c80fd52388
MD5 40174483b530e10b1a112550876e07b5
BLAKE2b-256 d304f75ba66abeed1b665a3b668fae5765a3d34ff39e054bb01b45f2a3ca2305

See more details on using hashes here.

File details

Details for the file lamoom-0.1.37-py3-none-any.whl.

File metadata

  • Download URL: lamoom-0.1.37-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.11.11 Linux/6.8.0-1021-azure

File hashes

Hashes for lamoom-0.1.37-py3-none-any.whl
Algorithm Hash digest
SHA256 5cf35d023fa50bd5ac6e73f44d5061976c515f4210150b987ba2388f7ac8d432
MD5 256ccbbbde943250ca5efaef505fe21a
BLAKE2b-256 ef4ec217bb4fc2dd9759fd2e8836a1489067ddafcce532b5fc0b1b80623849a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page