Spaces:
Configuration error
Configuration error
Download openhands/llm/bedrock.py from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/openhands/llm/bedrock.py
- Command line
-
hf download hf://spaces/flyingdarkdev/README/openhands/llm/bedrock.py
-
curl -L -o bedrock.py https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/openhands/llm/bedrock.py
1.15 kB
| import boto3 | |
| from openhands.core.logger import openhands_logger as logger | |
| def list_foundation_models( | |
| aws_region_name: str, aws_access_key_id: str, aws_secret_access_key: str | |
| ) -> list[str]: | |
| try: | |
| # The AWS bedrock model id is not queried, if no AWS parameters are configured. | |
| client = boto3.client( | |
| service_name='bedrock', | |
| region_name=aws_region_name, | |
| aws_access_key_id=aws_access_key_id, | |
| aws_secret_access_key=aws_secret_access_key, | |
| ) | |
| foundation_models_list = client.list_foundation_models( | |
| byOutputModality='TEXT', byInferenceType='ON_DEMAND' | |
| ) | |
| model_summaries = foundation_models_list['modelSummaries'] | |
| return ['bedrock/' + model['modelId'] for model in model_summaries] | |
| except Exception as err: | |
| logger.warning( | |
| '%s. Please config AWS_REGION_NAME AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY' | |
| ' if you want use bedrock model.', | |
| err, | |
| ) | |
| return [] | |
| def remove_error_modelId(model_list): | |
| return list(filter(lambda m: not m.startswith('bedrock'), model_list)) | |