Closed jexp closed 10 months ago
For auth for the REST calls we might need to use this: https://docs.aws.amazon.com/AmazonS3/latest/userguide/RESTAuthentication.html
Authorization = "AWS" + " " + AWSAccessKeyId + ":" + Signature;
Signature = Base64( HMAC-SHA1( UTF-8-Encoding-Of(YourSecretAccessKey), UTF-8-Encoding-Of( StringToSign ) ) );
StringToSign = HTTP-Verb + "\n" +
Content-MD5 + "\n" +
Content-Type + "\n" +
Date + "\n" +
CanonicalizedAmzHeaders +
CanonicalizedResource;
CanonicalizedResource = [ "/" + Bucket ] +
<HTTP-Request-URI, from the protocol name up to the query string> +
[ subresource, if present. For example "?acl", "?location", or "?logging"];
CanonicalizedAmzHeaders = <described below>```
Not sure if this also helps:
https://docs.mendix.com/appstore/connectors/aws/amazon-bedrock/
Hey @jexp I'm the maintainer of litellm a library to simplify LLM API Calls by mapping the input/output to the OpenAI format.
Any chance we could help?
We support all 4 providers on Bedrock (Anthropic, Cohere, AI21, Amazon Titan) - https://docs.litellm.ai/docs/providers/bedrock
And have a self-hosted OpenAI-compatible server you could run to make it work within a Java context - https://docs.litellm.ai/docs/proxy_server
Code to call Claude on Bedrock:
import os
from litellm import completion
os.environ["AWS_ACCESS_KEY_ID"] = ""
os.environ["AWS_SECRET_ACCESS_KEY"] = ""
os.environ["AWS_REGION_NAME"] = ""
response = completion(
model="anthropic.claude-instant-v1",
messages=[{ "content": "Hello, how are you?","role": "user"}]
)
Bedrock API reference
Invoke Model: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_InvokeModel.html
List foundation models: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ListFoundationModels.html
AWS Bedrock workshop: https://github.com/aws-samples/amazon-bedrock-workshop
potentially need to look at langchain code:
Default Model: amazon.titan-tg1-large ?
Langchain LLMs https://python.langchain.com/docs/integrations/llms/bedrock
LangChain Embeddings: https://python.langchain.com/docs/integrations/text_embedding/bedrock