mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 18:00:36 +00:00
Revert changes
This commit is contained in:
parent
75e50e87c8
commit
d2b1a99983
1 changed files with 23 additions and 8 deletions
|
|
@ -274,22 +274,37 @@ class WatsonXInferenceAdapter(LiteLLMOpenAIMixin):
|
||||||
models = []
|
models = []
|
||||||
for model_spec in self._get_model_specs():
|
for model_spec in self._get_model_specs():
|
||||||
functions = [f["id"] for f in model_spec.get("functions", [])]
|
functions = [f["id"] for f in model_spec.get("functions", [])]
|
||||||
|
# Format: {"embedding_dimension": 1536, "context_length": 8192}
|
||||||
|
|
||||||
|
# Example of an embedding model:
|
||||||
|
# {'model_id': 'ibm/granite-embedding-278m-multilingual',
|
||||||
|
# 'label': 'granite-embedding-278m-multilingual',
|
||||||
|
# 'model_limits': {'max_sequence_length': 512, 'embedding_dimension': 768},
|
||||||
|
# ...
|
||||||
provider_resource_id = f"{self.__provider_id__}/{model_spec['model_id']}"
|
provider_resource_id = f"{self.__provider_id__}/{model_spec['model_id']}"
|
||||||
if "embedding" in functions:
|
if "embedding" in functions:
|
||||||
model_type = ModelType.embedding
|
embedding_dimension = model_spec.get("model_limits", {}).get("embedding_dimension", 0)
|
||||||
elif "text_chat" in functions:
|
context_length = model_spec.get("model_limits", {}).get("max_sequence_length", 0)
|
||||||
model_type = ModelType.llm
|
embedding_metadata = {
|
||||||
else:
|
"embedding_dimension": embedding_dimension,
|
||||||
model_type = None
|
"context_length": context_length,
|
||||||
|
}
|
||||||
if model_type is not None:
|
model = Model(
|
||||||
|
identifier=model_spec["model_id"],
|
||||||
|
provider_resource_id=provider_resource_id,
|
||||||
|
provider_id=self.__provider_id__,
|
||||||
|
metadata=embedding_metadata,
|
||||||
|
model_type=ModelType.embedding,
|
||||||
|
)
|
||||||
|
self._model_cache[provider_resource_id] = model
|
||||||
|
models.append(model)
|
||||||
|
if "text_chat" in functions:
|
||||||
model = Model(
|
model = Model(
|
||||||
identifier=model_spec["model_id"],
|
identifier=model_spec["model_id"],
|
||||||
provider_resource_id=provider_resource_id,
|
provider_resource_id=provider_resource_id,
|
||||||
provider_id=self.__provider_id__,
|
provider_id=self.__provider_id__,
|
||||||
metadata={},
|
metadata={},
|
||||||
model_type=model_type,
|
model_type=ModelType.llm,
|
||||||
)
|
)
|
||||||
self._model_cache[provider_resource_id] = model
|
self._model_cache[provider_resource_id] = model
|
||||||
models.append(model)
|
models.append(model)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue