Skip to content

Commit 2fdd49b

Browse files
Do not use model prefix, rely on hosting platform.
1 parent 5db3fbf commit 2fdd49b

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

singlestoredb/ai/chat.py

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -75,40 +75,16 @@ def SingleStoreChatFactory(
7575
obo_token_getter: Optional[Callable[[], Optional[str]]] = None,
7676
**kwargs: Any,
7777
) -> Union[ChatOpenAI, ChatBedrockConverse]:
78-
"""Return a chat model instance (ChatOpenAI or ChatBedrockConverse) based on prefix.
79-
80-
The fully-qualified model name is expected to contain a prefix followed by
81-
a delimiter (one of '.', ':', '/'). Supported prefixes:
82-
* aura -> OpenAI style (ChatOpenAI backend)
83-
* aura-azr -> Azure OpenAI style (still ChatOpenAI backend)
84-
* aura-amz -> Amazon Bedrock (ChatBedrockConverse backend)
85-
86-
If no supported prefix is detected the entire value is treated as an
87-
OpenAI-style model routed through the SingleStore Fusion gateway.
78+
"""Return a chat model instance (ChatOpenAI or ChatBedrockConverse).
8879
"""
89-
# Parse identifier
90-
prefix = 'aura'
91-
actual_model = model_name
92-
for sep in ('.', ':', '/'):
93-
if sep in model_name:
94-
head, tail = model_name.split(sep, 1)
95-
candidate = head.strip().lower()
96-
if candidate in {'aura', 'aura-azr', 'aura-amz'}:
97-
prefix = candidate
98-
actual_model = tail.strip()
99-
else:
100-
# Unsupported prefix; treat whole string as model for OpenAI path
101-
actual_model = model_name
102-
break
103-
10480
inference_api_manager = (
10581
get_workspace_manager().organizations.current.inference_apis
10682
)
107-
info = inference_api_manager.get(model_name=actual_model)
83+
info = inference_api_manager.get(model_name=model_name)
10884
token_env = os.environ.get('SINGLESTOREDB_USER_TOKEN')
10985
token = api_key if api_key is not None else token_env
11086

111-
if prefix == 'aura-amz':
87+
if info.hosting_platform == 'Amazon':
11288
# Instantiate Bedrock client
11389
cfg = Config(
11490
signature_version=UNSIGNED,
@@ -157,7 +133,7 @@ def _inject_headers(request: Any, **_ignored: Any) -> None:
157133
_inject_headers,
158134
)
159135
return ChatBedrockConverse(
160-
model=actual_model,
136+
model=model_name,
161137
endpoint_url=info.connection_url, # redirect requests to UMG
162138
region_name='us-east-1', # dummy value; UMG does not use this
163139
aws_access_key_id='placeholder', # dummy value; UMG does not use this
@@ -171,7 +147,7 @@ def _inject_headers(request: Any, **_ignored: Any) -> None:
171147
openai_kwargs = dict(
172148
base_url=info.connection_url,
173149
api_key=token,
174-
model=actual_model,
150+
model=model_name,
175151
streaming=streaming,
176152
)
177153
if http_client is not None:

0 commit comments

Comments
 (0)