A tool to generate python code with GenAI RestAPIs.
Project description
GenAI REST Builder
The GenAI REST Builder is a tool for creating RESTful services around AI models with minimal effort. It allows you to define service configurations in a YAML file and generates a FastAPI-based project structure to deploy AI-powered endpoints.
Version History
v0.2.2 - AWS Chat-Based Service with Memory Management
Key Features
- Introduced chat-based services for AWS with memory management using DynamoDB.
- Added
chatAppproperty, available only for AWS services:- Set
chatApp: Yto enable chat-based functionality. - Requires the
dynamoDbTableNameproperty to specify the DynamoDB table used for storing chat histories. - Removes the need for the
promptproperty whenchatAppisY.
- Set
- DynamoDB Integration:
- Table must have a primary key of
SessionId(string). - Stores and retrieves chat histories linked to session IDs.
- Table must have a primary key of
YAML Format
PromptServices:
- <service_name>:
chatApp: Y # Available only for AWS services
dynamoDbTableName: <DynamoDB_Table_Name> # Required when chatApp is Y
model:
provider: aws
modelId: <model_id>
temperature: <value>
maxTokens: <value>
If chatApp is omitted or its value is not Y, the prompt property becomes mandatory.
v0.2.1 - Core Features
Key Features
- Introduced foundational functionality to define RESTful services using YAML configuration.
- Added support for custom prompts via the
promptproperty. - Supported AWS and Azure providers for model integration.
- Automated FastAPI-based project generation.
- Introduced the
apiVersionproperty for Azure-specific models.
YAML Format
PromptServices:
- <service_name>:
chatApp: N # Optional; default behavior for prompt-based services
prompt: <prompt_template> # Required if chatApp is omitted or not Y
model:
provider: [aws/azure]
modelId: <model_id>
temperature: <value>
maxTokens: <value>
apiVersion: <api_version> # Azure only
Installation Instructions
1. Install the Builder
pip install pyyaml genai-rest-builder
2. Generate Project Structure
genai-rest-proj-build
- Reads from the
prompt_service.yamlfile to generate project files.
3. Install Dependencies
pip install -r requirements.txt
4. Run the Server
python serve_app.py
- Default host:
localhost:8080.
Generated Project Structure
The project structure remains consistent across versions:
.
├── service_chains/
│ ├── base_chains/ # Base and provider-specific chain definitions
│ │ ├── base_chain.py # Abstract base class for chains
│ │ ├── aws_chain.py # AWS-specific chain implementation
│ │ ├── azure_chain.py # Azure-specific chain implementation
│ │ ├── __init__.py # Exports for base_chains module
│ ├── <servicename>_chain.py # Service-specific chain implementation
│ ├── utils.py # Utility functions for service configurations
│ ├── __init__.py # Package initialization file for service_chains
├── serve_app.py # Main FastAPI application
├── .env # Environment configuration file with host/port settings
├── requirements.txt # Project dependencies file
├── prompt_service.yaml # YAML configuration file (user-defined)
Accessing API Documentation
Once the server is running, OpenAPI documentation can be accessed at:
http://<GENAI_SERVER_HOST>:<GENAI_SERVER_PORT>/docs
Invoking Services
Each service is available via a unique REST API path based on its name in prompt_service.yaml:
http://<GENAI_SERVER_HOST>:<GENAI_SERVER_PORT>/<service_name>
Upgrade Notes
From v0.2.1 to v0.2.2
- For AWS Services:
- Use
chatApp: Yto enable chat-based services. - Provide
dynamoDbTableNameto store message histories. - If
chatAppisY, thepromptproperty is no longer required.
- Use
- For Azure Services:
- Continue using
promptas required for prompt-based services. - Ensure the
apiVersionproperty is provided for Azure models.
- Continue using
- General Rule:
- If
chatAppis omitted or not set toY, thepromptproperty must be included.
- If
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file genai_rest_builder-0.2.3.tar.gz.
File metadata
- Download URL: genai_rest_builder-0.2.3.tar.gz
- Upload date:
- Size: 49.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ab44cbc9b64d9731917157d75093661acc967942528d088ae057703f88452b7
|
|
| MD5 |
ff7a1e603c72d744a659949d4eea6921
|
|
| BLAKE2b-256 |
d35a87500e59c1d02c76c495ca246275cbd3948be901573f3c8b10f32e37ca1e
|
File details
Details for the file genai_rest_builder-0.2.3-py3-none-any.whl.
File metadata
- Download URL: genai_rest_builder-0.2.3-py3-none-any.whl
- Upload date:
- Size: 55.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57503b76ea1cb163f5e0b7629b1443d2fda28ff08f50b76215cbc88363575453
|
|
| MD5 |
6ac8f3743652fd770e31dbd053cc394c
|
|
| BLAKE2b-256 |
6d8c7b2eaa008965a43cda6aa56798e6f7362b66f5b0a124fcaa40f40ab5992c
|