Skip to main content

KitchenAI SDK

KitchenAI SDK is a powerful tool for authoring and defining AI cookbooks in well-defined stages. It allows you to easily create portable AI frameworks that can run alongside your code as a sidecar.

Features

  • Wrap FastAPI applications with KitchenAI functionality
  • Define query, storage, embedding, and runnable endpoints
  • Automatic Pydantic model integration for request body parsing
  • Metadata management for easy discovery of endpoints
  • Support for both synchronous and asynchronous handlers

Installation

Install the KitchenAI SDK using pip:

pip install kitchenai-sdk

Quick Start

Here's a simple example to get you started with the KitchenAI SDK:

from fastapi import FastAPI, Request
from kitchenai_sdk import KitchenAIApp
from pydantic import BaseModel

app = FastAPI()
kitchen = KitchenAIApp(app_instance=app)

class QueryRequest(BaseModel):
    query: str

@kitchen.query("simple-query")
def simple_query(request: Request, body: QueryRequest):
    return {"result": f"Processed query: {body.query}"}

# Run with: uvicorn main:app

Detailed Usage

Initialization

from fastapi import FastAPI
from kitchenai_sdk import KitchenAIApp

app = FastAPI()
kitchen = KitchenAIApp(app_instance=app, namespace="my-cookbook")

Defining Endpoints

KitchenAI SDK provides decorators for different types of endpoints:

Query Endpoint

@kitchen.query("my-query")
async def my_query(request: Request, body: QueryRequest):
    # Your query logic here
    return {"result": "Query processed"}

Storage Endpoint

@kitchen.storage("store-data")
async def store_data(request: Request):
    # Your storage logic here
    return {"status": "Data stored"}

Embedding Endpoint

@kitchen.embedding("generate-embedding")
def generate_embedding(request: Request):
    # Your embedding logic here
    return {"embedding": [0.1, 0.2, 0.3]}

Runnable Endpoint

@kitchen.runnable("custom-workflow")
async def custom_workflow(request: Request):
    # Your custom workflow logic here
    return {"status": "Workflow completed"}

Using Pydantic Models

KitchenAI SDK automatically detects Pydantic models in your function signatures:

class MyModel(BaseModel):
    field1: str
    field2: int

@kitchen.query("pydantic-example")
def pydantic_example(request: Request, body: MyModel):
    return {"received": body.dict()}

Streaming Responses

You can use StreamingResponse for long-running or real-time operations:

from fastapi.responses import StreamingResponse

@kitchen.query("streaming-query")
def streaming_query(request: Request, body: QueryRequest):
    def generate():
        for i in range(10):
            yield f"Data chunk {i}\n"
    
    return StreamingResponse(generate(), media_type="text/plain")

Best Practices

  1. Use descriptive labels for your endpoints to make them easily discoverable.
  2. Leverage Pydantic models for request validation and documentation.
  3. Implement proper error handling in your endpoint functions.
  4. Use asynchronous functions for I/O-bound operations to improve performance.
  5. Organize your cookbook into logical sections using the different endpoint types.

Running Your Cookbook

To run your KitchenAI cookbook:

  1. Create your FastAPI app and KitchenAI wrapper as shown in the examples.
  2. Run your app using an ASGI server like Uvicorn:
uvicorn main:app --reload
  1. Your KitchenAI endpoints will be available under the specified namespace, e.g., /default/query/my-query.

Contributing

We welcome contributions to the KitchenAI SDK! Please see our Contributing Guidelines for more details.

License

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

Support

For support, please open an issue on our GitHub repository or contact our support team at support@kitchenai.com.


Happy cooking with KitchenAI! 🍳🤖

Metadata

Release files for kitchenai-sdk 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kitchenai-sdk 0.1.4
File Size Uploaded Provenance Actions
kitchenai_sdk-0.1.4.tar.gz 3.4 kB Without provenance Details for kitchenai_sdk-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kitchenai-sdk 0.1.4
File Interpreter ABI Platform Actions
kitchenai_sdk-0.1.4-py3-none-any.whl Python 3 none any Details for kitchenai_sdk-0.1.4-py3-none-any.whl

Total release size: 7.2 kB

Release files / kitchenai_sdk-0.1.4.tar.gz

Download URL kitchenai_sdk-0.1.4.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
46750ccef93b57338ebf5262d6a5d27505dbc9a2b02dc226be739253e217c630
BLAKE2b-256 checksum
How to use checksums
08622fb5a56753ba83d4dd2f44dcb7df396a79b700d7a1f23bdde9754d82eb6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.9.3-76060903-generic

Release files / kitchenai_sdk-0.1.4-py3-none-any.whl

Download URL kitchenai_sdk-0.1.4-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7a585861c2db1e440d0cd2ba922bd7a44a9d6f60c140864991e6f189e534a28
BLAKE2b-256 checksum
How to use checksums
0a11aa694d8b4adf18f6d5271a1e6a5a6be2f6c0dfced6f5e16ff26f9f66e2f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.9.3-76060903-generic

Security for kitchenai-sdk 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page