Skip to content

Conversation

patilvishal0597
Copy link
Contributor

@patilvishal0597 patilvishal0597 commented Jan 23, 2025

Created a demo chat bedrock to simplify implementation. WIP.

Implementation

New Integration class: DemoChatBedrock
New optional argument: chat_prompt_adapter: ModelAdapter

ModelAdapter is an abstract class that will be extended to model provider specific classes e.g. BedrockClaudeAdapter, BedrockLlamaAdapter

If the model adapter is not passed, DemoChatBedrock will switch to ChatBedrockConverse implementation internally. If it is passed, DemoChatBedrock will use Bedrock Invoke API internally using the model adapter to handle input/output conversion.

Usage

def main():
    """Initializing Demo Bedrock Chat for testing DemoChatBedrock calls"""
    llm = getDemoChatBedrock()

    response = llm.invoke(getInputMessage())
    print(response.content)


def getDemoChatBedrock():
    model_adapter = BedrockClaudeAdapter()

    return DemoChatBedrock(
        model_id="us.anthropic.claude-3-5-sonnet-20241022-v2:0",
        region_name="us-east-1",
        model_kwargs={
            "max_tokens": 100,
            "top_p": 0.9,
            "temperature": 0.1,
        },
        chat_prompt_adapter=model_adapter,
    )


def getInputMessage():
    messages = [
        (
            "system",
            "You are a helpful assistant that translates English to French. Translate the user sentence.",
        ),
        ("human", "I love going out for a walk when the weather is bright and sunny."),
    ]
    return messages


if __name__ == "__main__":
    main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant