Skip to content

Commit d8ba9a1

Browse files
committed
Make safe calls when searching for model
1 parent 09304a1 commit d8ba9a1

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

backend-agent/llm.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,28 @@ def from_model_name(cls, model_name: str) -> 'LLM':
8888
Useful because the user can specify only the name in the agent.
8989
"""
9090
# Foundation-models scenarios in AI Core
91-
if model_name in AICORE_MODELS['azure-openai']:
91+
if model_name in AICORE_MODELS.get('azure-openai', []):
9292
return AICoreOpenAILLM(model_name)
9393
# IBM models are compatible with OpenAI completion API
94-
if model_name in AICORE_MODELS['aicore-ibm']:
94+
if model_name in AICORE_MODELS.get('aicore-ibm', []):
9595
return AICoreOpenAILLM(model_name)
96-
if model_name in AICORE_MODELS['aicore-opensource']:
96+
if model_name in AICORE_MODELS.get('aicore-opensource', []):
9797
return AICoreOpenAILLM(model_name, False)
9898
# Mistral models are compatible with OpenAI completion API
99-
if model_name in AICORE_MODELS['aicore-mistralai']:
99+
if model_name in AICORE_MODELS.get('aicore-mistralai', []):
100100
return AICoreOpenAILLM(model_name, False)
101101
# Perplexity models are compatible with OpenAI completion API
102-
if model_name in AICORE_MODELS['perplexity-ai']:
102+
if model_name in AICORE_MODELS.get('perplexity-ai', []):
103103
return AICoreOpenAILLM(model_name)
104104

105105
# Non OpenAI-compatible models in AI Core
106-
if model_name in AICORE_MODELS['aws-bedrock']:
106+
if model_name in AICORE_MODELS.get('aws-bedrock', []):
107107
if 'titan' in model_name:
108108
# Titan models don't support system prompts
109109
return AICoreAmazonBedrockLLM(model_name, False)
110110
else:
111111
return AICoreAmazonBedrockLLM(model_name)
112-
if model_name in AICORE_MODELS['gcp-vertexai']:
112+
if model_name in AICORE_MODELS.get('gcp-vertexai', []):
113113
return AICoreGoogleVertexLLM(model_name)
114114

115115
# Custom models

0 commit comments

Comments
 (0)