No project description provided
Project description
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
- Use descriptive labels for your endpoints to make them easily discoverable.
- Leverage Pydantic models for request validation and documentation.
- Implement proper error handling in your endpoint functions.
- Use asynchronous functions for I/O-bound operations to improve performance.
- Organize your cookbook into logical sections using the different endpoint types.
Running Your Cookbook
To run your KitchenAI cookbook:
- Create your FastAPI app and KitchenAI wrapper as shown in the examples.
- Run your app using an ASGI server like Uvicorn:
uvicorn main:app --reload
- 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! 🍳🤖
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kitchenai_sdk-0.1.4a1.tar.gz
.
File metadata
- Download URL: kitchenai_sdk-0.1.4a1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.9.3-76060903-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb3e2d8e831ccce67b3bc8d12a66948af0a1d472ddcecfcc2ccf850b3c179455 |
|
MD5 | fb3c51e724db252e089b9ad190b01b8c |
|
BLAKE2b-256 | 99185fb6dd4182db4e1e176b96246a1205d209b22ae7cf0856c7c3edb01155ac |
File details
Details for the file kitchenai_sdk-0.1.4a1-py3-none-any.whl
.
File metadata
- Download URL: kitchenai_sdk-0.1.4a1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.9.3-76060903-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b24316dad77cd1cba6d29a92a7390c24ee9efc1ce6a377c6952da363b3768e66 |
|
MD5 | 6637bd60d323229c54586e07e6bfc243 |
|
BLAKE2b-256 | dd8253b712a80d9c9d45820c6e9efc6b2f6027afd0cad122f71edb0ce6fd7430 |