Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions api/bedrock_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,18 @@ def _get_model_provider(self, model_id: str) -> str:
"""Extract the provider from the model ID.

Args:
model_id: The model ID, e.g., "anthropic.claude-3-sonnet-20240229-v1:0"
model_id: The model inference ID, e.g., "anthropic.claude-3-sonnet-20240229-v1:0", "global.anthropic.claude-sonnet-4-5-20250929-v1:0", or "global.cohere.embed-v4:0"

Returns:
The provider name, e.g., "anthropic"
"""
if "." in model_id:
return model_id.split(".")[0]
return "amazon" # Default provider
seg = model_id.split(".")
if len(seg) < 2:
return "amazon" # Default to Amazon if format is unexpected
if len(seg) == 2:
return seg[0]
else:
return seg[1]
Comment thread
Warashi marked this conversation as resolved.
Resolved

def _format_prompt_for_provider(self, provider: str, prompt: str, messages=None) -> Dict[str, Any]:
"""Format the prompt according to the provider's requirements.
Expand Down
8 changes: 6 additions & 2 deletions api/websocket_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,14 @@ async def handle_websocket_chat(websocket: WebSocket):
model = BedrockClient()
model_kwargs = {
"model": request.model,
"temperature": model_config["temperature"],
"top_p": model_config["top_p"],
}

if "temperature" in model_config:
model_kwargs["temperature"] = model_config["temperature"]

if "top_p" in model_config:
model_kwargs["top_p"] = model_config["top_p"]
Comment thread
Warashi marked this conversation as resolved.
Resolved

api_kwargs = model.convert_inputs_to_api_kwargs(
input=prompt,
model_kwargs=model_kwargs,
Expand Down