Open
Description
Use case
Use case:
I would like to see Lambda Power Tools being able to produce the ToolSpec definition, from a method, to be then used with Bedrock.
Here is a ToolSpec example:
"toolSpec": {
"name": "cosine",
"description": "Calculate the cosine of x.",
"inputSchema": {
"json": {
"type": "object",
"properties": {
"x": {
"type": "number",
"description": "The number to pass to the function."
}
},
"required": ["x"]
}
}
}
the python method would look like this:
def cosine(x:float): -> number
return math.cos(x)
Solution/User Experience
A developer woud decorate its method like this:
tools = LambdaPowerToolsBedrockToolsResolver()
@tools.toolSpec(description="Calculate cosine of a number)
def cosine(
x: Annotated[float, Query(description="The number to calculate cosine from")]
)
then it could use it with Converse Api like this:
response = bedrock.converse(
modelId="anthropic.claude-3-sonnet-20240229-v1:0",
messages=message_list,
inferenceConfig={
"maxTokens": 2000,
"temperature": 0
},
toolConfig={
"tools":tools.toolSpecs
},
system=[{"text":"what is cosine of 3.4"}]
)
Alternative solutions
None
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Ideas