Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Call Anthropic models via AWS Bedrock with Freeplay integration.
from freeplay import Freeplay, RecordPayload, CallInfo from anthropic.lib.bedrock import AnthropicBedrock from anthropic import NotGiven import os import time from dotenv import load_dotenv load_dotenv() project_id = os.getenv("FREEPLAY_PROJECT_ID") freeplay_key = os.getenv("FREEPLAY_API_KEY") freeplay_url = os.getenv("FREEPLAY_URL") aws_access_key_id = os.getenv("AWS_ACCESS_KEY_ID") aws_secret_key = os.getenv("AWS_SECRET_KEY") fpClient = Freeplay( api_base=freeplay_url, freeplay_api_key=freeplay_key ) bedrockClient = AnthropicBedrock( aws_secret_key=aws_secret_key, aws_access_key=aws_access_key_id, aws_region="us-east-1" ) # fetch the prompt prompt_vars = { "pop_star": "Taylor Swift", } formatted_prompt = fpClient.prompts.get_formatted( project_id=project_id, template_name="album_bot", environment="latest", variables=prompt_vars ) s = time.time() response = bedrockClient.messages.create( model=formatted_prompt.prompt_info.model, system=formatted_prompt.system_content or NotGiven(), messages=formatted_prompt.llm_prompt, **formatted_prompt.prompt_info.model_parameters ) e = time.time() response_text = response.content[0].text all_messages = formatted_prompt.all_messages( {"role": "assistant", "content": response_text} ) session = fpClient.sessions.create() payload = RecordPayload( project_id=project_id, all_messages=all_messages, inputs=prompt_vars, session_info=session, prompt_version_info=formatted_prompt.prompt_info, call_info=CallInfo.from_prompt_info(formatted_prompt.prompt_info, start_time=s, end_time=e) ) fpClient.recordings.create(payload)
Contact support