Chalice x Agents for Amazon Bedrock plug-ins
Project description
Chalice-A4AB
What is this?
Chalice plugin: Support Agents for Amazon Bedrock
URL Links
PYPI :: Chalice-a4ab
https://pypi.org/project/chalice-a4ab/
Github :: Chalice-a4ab
https://github.com/ShotaOki/ChaliceA4AB
Usage
-
Install
pip install -U chalice chalice-a4ab pydantic
-
Replace
from chalice import Chalice
tofrom chalice_a4ab import Chalice
.Before:
from chalice import Chalice app = Chalice("app-name") @app.router("path-name") ...
After:
from chalice_a4ab import Chalice app = Chalice("app-name") @app.router("path-name") ...
-
(Optional) Add Parser Lambda Function
Add these decorator, function becomes "parser lambda"
from chalice_a4ab import ( Chalice, AgentsForAmazonBedrockConfig, ParserLambdaAbortException, ParserLambdaResponseModel, ) # Set Config for Agents for Amazon bedrock AgentsForAmazonBedrockConfig().apply() ... # PRE_PROCESSING @app.parser_lambda_pre_processing() def pre_processing(event, default_result: ParserLambdaResponseModel) -> ParserLambdaResponseModel: # [MEMO] is_valid_input :: Allow/Deny API invocation # default_result.pre_processing_parsed_response.is_valid_input = True return default_result # ORCHESTRATION @app.parser_lambda_orchestration() def orchestration(event: dict, default_result: ParserLambdaResponseModel) -> ParserLambdaResponseModel: # [MEMO] Throw this Exception, Overwrite LLM response # raise ParserLambdaAbortException(message="Overwrited") return default_result
-
Application works ::
What you can do Status Execute from Agents for Amazon Bedrock 〇 Auto generate OpenAPI schema × Management on cli ×
Advanced Usage
Create OpenAPI Schema automatically.
-
Install Chalice-a4ab and Chalice-spec
pip install -U chalice chalice-spec==0.7.0 chalice-a4ab boto3 pydantic
-
Add Setting
from chalice_a4ab import Chalice, AgentsForAmazonBedrockConfig from chalice_spec.docs import Docs, Operation # Set Config for Agents for Amazon bedrock AgentsForAmazonBedrockConfig( instructions="Situation Settings for talking with Human and agent.(more than 40 words)", description="Description of application", ).apply() app = Chalice(app_name="app-name") @app.router("path-name", methods=["POST"], docs=Docs( post=Operation( request=PyDanticRequestModelClass, response=PyDanticOutputModelClass, ) )) def post_method(): ...
documentation for
@app.router
sample: https://github.com/TestBoxLab/chalice-spec -
Management CLI
Init command :: Create AWS Resource and OpenAPI Schema.
chalice-a4ab init --profile ${PROFILE_NAME} --region ${REGION_NAME}
Sync command :: Update Already AWS Resource and OpenAPISchema.
chalice-a4ab sync --profile ${PROFILE_NAME} --region ${REGION_NAME}
Show command :: Show OpenAPI Schema.
chalice-a4ab show --profile ${PROFILE_NAME} --region ${REGION_NAME}
Info command :: Show about Agents for Amazon Bedrock.
chalice-a4ab info --profile ${PROFILE_NAME} --region ${REGION_NAME}
Invoke command :: Invoke Agents for Amazon Bedrock.
chalice-a4ab invoke "Natural Language Query" \ --agent-id ${AGENT_ID} \ --agent-alias-id ${AGENT_ALIAS_ID} \ --end-session \ --profile ${PROFILE_NAME} --region ${REGION_NAME}
Delete AWS Resource
chalice-a4ab delete --profile ${PROFILE_NAME} --region ${REGION_NAME}
-
Application works ::
What you can do Status Execute from Agents for Amazon Bedrock 〇 Auto generate OpenAPI schema 〇 Management on cli 〇
Develop
-
Setup
poetry install
-
Run test
poetry run pytest
Lisence
MIT
API
Command Line TOOL
Command | Descritpion |
---|---|
chalice-a4ab init | Create AWS resource for Agents for amazon bedrock |
chalice-a4ab sync | Sync OpenAPI schema to AWS |
chalice-a4ab delete | Delete AWS resource for Agents for amazon bedrock |
Options | Description |
---|---|
--bucket | Set S3 bucket name (for put OpenAPI schema) |
--profile | Set AWS Profile Name |
--region | Set AWS Region Name |
--help | Show Help |
API
AgentsForAmazonBedrockConfig
Method | Type | Description |
---|---|---|
apply | - | Current instace becomes global variable. |
agents_for_bedrock_schema_json | - | Get OpenAPI Schema |
save_schema_to_local | - | Save OpenAPI Schema to local folder |
save_schema_to_s3 | - | Upload OpenAPI Schema to S3 bucket |
save_config_to_local | - | Save Config setting to local folder |
get_global_config | static | Get global variable. |
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
Hashes for chalice_a4ab-0.2.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec73a7bba4dd84e8b049397136f2c73bd41d7439e3a9005b71d1944bf50df1ff |
|
MD5 | f1aabd33b49e0e46013b21f807bab81b |
|
BLAKE2b-256 | 9f14aed4658a9613bc484656b497e8ca2c696b466dd0febf865fd743922e52b1 |