Factory function to dynamically create completion functions for Amazon Bedrock Args: model_id (str): Amazon Bedrock model identifier (e.g., "us.anthropic.claude-3-sonnet-20240229-v1:0") Returns: Callable: Generated completion function
(model_id: str)
| 122 | |
| 123 | |
| 124 | def create_amazon_bedrock_complete_function(model_id: str) -> Callable: |
| 125 | """ |
| 126 | Factory function to dynamically create completion functions for Amazon Bedrock |
| 127 | |
| 128 | Args: |
| 129 | model_id (str): Amazon Bedrock model identifier (e.g., "us.anthropic.claude-3-sonnet-20240229-v1:0") |
| 130 | |
| 131 | Returns: |
| 132 | Callable: Generated completion function |
| 133 | """ |
| 134 | async def bedrock_complete( |
| 135 | prompt: str, |
| 136 | system_prompt: Optional[str] = None, |
| 137 | history_messages: List[Any] = [], |
| 138 | **kwargs |
| 139 | ) -> str: |
| 140 | return await amazon_bedrock_complete_if_cache( |
| 141 | model_id, |
| 142 | prompt, |
| 143 | system_prompt=system_prompt, |
| 144 | history_messages=history_messages, |
| 145 | **kwargs |
| 146 | ) |
| 147 | |
| 148 | # Set function name for easier debugging |
| 149 | bedrock_complete.__name__ = f"{model_id}_complete" |
| 150 | |
| 151 | return bedrock_complete |
| 152 | |
| 153 | |
| 154 | async def gpt_4o_complete( |