add back Any

This commit is contained in:
Dinesh Yeduguru 2024-11-01 14:32:50 -07:00 committed by Dinesh Yeduguru
parent 1bcf484d83
commit a3064ca6fc
5 changed files with 15 additions and 11 deletions

View file

@ -4,16 +4,16 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Dict, List, Literal, Optional, Protocol
from typing import Any, Dict, List, Literal, Optional, Protocol
from llama_models.llama3.api.datatypes import URL
from llama_models.schema_utils import json_schema_type, webmethod
from pydantic import BaseModel, Field
from llama_stack.apis.common.type_system import ParamType
from pydantic import BaseModel, Field
@json_schema_type
class DatasetDef(BaseModel):
@ -24,7 +24,7 @@ class DatasetDef(BaseModel):
description="The schema definition for this dataset",
)
url: URL
metadata: Dict[str, str] = Field(
metadata: Dict[str, Any] = Field(
default_factory=dict,
description="Any additional metadata for this dataset",
)

View file

@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Dict, List, Literal, Optional, Protocol, runtime_checkable
from typing import Any, Dict, List, Literal, Optional, Protocol, runtime_checkable
from llama_models.schema_utils import json_schema_type, webmethod
from pydantic import BaseModel, Field
@ -17,7 +17,7 @@ class ModelDef(BaseModel):
llama_model: str = Field(
description="Pointer to the underlying core Llama family model. Each model served by Llama Stack must have a core Llama model.",
)
metadata: Dict[str, str] = Field(
metadata: Dict[str, Any] = Field(
default_factory=dict,
description="Any additional metadata for this model",
)

View file

@ -4,12 +4,12 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Dict, List, Literal, Optional, Protocol, runtime_checkable
from typing import Any, Dict, List, Literal, Optional, Protocol, runtime_checkable
from llama_models.schema_utils import json_schema_type, webmethod
from pydantic import BaseModel, Field
from llama_stack.apis.common.type_system import ParamType
from pydantic import BaseModel, Field
@json_schema_type
@ -36,7 +36,7 @@ class LLMAsJudgeContext(BaseModel):
class ScoringFnDef(BaseModel):
identifier: str
description: Optional[str] = None
metadata: Dict[str, str] = Field(
metadata: Dict[str, Any] = Field(
default_factory=dict,
description="Any additional metadata for this definition",
)

View file

@ -5,7 +5,7 @@
# the root directory of this source tree.
from enum import Enum
from typing import Dict, List, Literal, Optional, Protocol, runtime_checkable
from typing import Any, Dict, List, Literal, Optional, Protocol, runtime_checkable
from llama_models.schema_utils import json_schema_type, webmethod
from pydantic import BaseModel, Field
@ -26,7 +26,7 @@ class ShieldDef(BaseModel):
type: str = Field(
description="The type of shield this is; the value is one of the ShieldType enum"
)
params: Dict[str, str] = Field(
params: Dict[str, Any] = Field(
default_factory=dict,
description="Any additional parameters needed for this shield",
)

View file

@ -47,6 +47,10 @@ class DiskRegistry(Registry):
# TODO: make it thread safe using CAS
async def register(self, obj: RoutableObjectWithProvider) -> None:
existing_objects = await self.get(obj.identifier)
# dont register if the object's providerid already exists
for eobj in existing_objects:
if eobj.provider_id == obj.provider_id:
return
existing_objects.append(obj)