mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
fix: finish conversion to StrEnum (#2514)
# What does this PR do? We still had a few enum declared to behave like string as well as enum. Let's use StrEnum for those. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
ac5fd57387
commit
36d70637b9
8 changed files with 17 additions and 17 deletions
|
@ -4,7 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum, StrEnum
|
||||||
from typing import Annotated, Any, Literal, Protocol
|
from typing import Annotated, Any, Literal, Protocol
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
@ -13,7 +13,7 @@ from llama_stack.apis.resource import Resource, ResourceType
|
||||||
from llama_stack.schema_utils import json_schema_type, register_schema, webmethod
|
from llama_stack.schema_utils import json_schema_type, register_schema, webmethod
|
||||||
|
|
||||||
|
|
||||||
class DatasetPurpose(str, Enum):
|
class DatasetPurpose(StrEnum):
|
||||||
"""
|
"""
|
||||||
Purpose of the dataset. Each purpose has a required input data schema.
|
Purpose of the dataset. Each purpose has a required input data schema.
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from enum import Enum
|
from enum import StrEnum
|
||||||
from typing import Annotated, Literal, Protocol, runtime_checkable
|
from typing import Annotated, Literal, Protocol, runtime_checkable
|
||||||
|
|
||||||
from fastapi import File, Form, Response, UploadFile
|
from fastapi import File, Form, Response, UploadFile
|
||||||
|
@ -16,7 +16,7 @@ from llama_stack.schema_utils import json_schema_type, webmethod
|
||||||
|
|
||||||
|
|
||||||
# OpenAI Files API Models
|
# OpenAI Files API Models
|
||||||
class OpenAIFilePurpose(str, Enum):
|
class OpenAIFilePurpose(StrEnum):
|
||||||
"""
|
"""
|
||||||
Valid purpose values for OpenAI Files API.
|
Valid purpose values for OpenAI Files API.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from enum import Enum
|
from enum import StrEnum
|
||||||
from typing import Any, Literal, Protocol, runtime_checkable
|
from typing import Any, Literal, Protocol, runtime_checkable
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
@ -22,7 +22,7 @@ class CommonModelFields(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
class ModelType(str, Enum):
|
class ModelType(StrEnum):
|
||||||
llm = "llm"
|
llm = "llm"
|
||||||
embedding = "embedding"
|
embedding = "embedding"
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from enum import Enum
|
from enum import StrEnum
|
||||||
from typing import Self
|
from typing import Self
|
||||||
|
|
||||||
from pydantic import BaseModel, model_validator
|
from pydantic import BaseModel, model_validator
|
||||||
|
@ -12,7 +12,7 @@ from pydantic import BaseModel, model_validator
|
||||||
from .conditions import parse_conditions
|
from .conditions import parse_conditions
|
||||||
|
|
||||||
|
|
||||||
class Action(str, Enum):
|
class Action(StrEnum):
|
||||||
CREATE = "create"
|
CREATE = "create"
|
||||||
READ = "read"
|
READ = "read"
|
||||||
UPDATE = "update"
|
UPDATE = "update"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from enum import Enum
|
from enum import StrEnum
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Annotated, Any
|
from typing import Annotated, Any
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ class LoggingConfig(BaseModel):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AuthProviderType(str, Enum):
|
class AuthProviderType(StrEnum):
|
||||||
"""Supported authentication provider types."""
|
"""Supported authentication provider types."""
|
||||||
|
|
||||||
OAUTH2_TOKEN = "oauth2_token"
|
OAUTH2_TOKEN = "oauth2_token"
|
||||||
|
@ -182,7 +182,7 @@ class AuthenticationRequiredError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class QuotaPeriod(str, Enum):
|
class QuotaPeriod(StrEnum):
|
||||||
DAY = "day"
|
DAY = "day"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
from enum import Enum
|
from enum import Enum, StrEnum
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import Annotated, Any, Literal
|
from typing import Annotated, Any, Literal
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ class GenerationResult(BaseModel):
|
||||||
ignore_token: bool
|
ignore_token: bool
|
||||||
|
|
||||||
|
|
||||||
class QuantizationMode(str, Enum):
|
class QuantizationMode(StrEnum):
|
||||||
none = "none"
|
none = "none"
|
||||||
fp8_mixed = "fp8_mixed"
|
fp8_mixed = "fp8_mixed"
|
||||||
int4_mixed = "int4_mixed"
|
int4_mixed = "int4_mixed"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from enum import Enum
|
from enum import StrEnum
|
||||||
from typing import Any, Protocol
|
from typing import Any, Protocol
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ def remote_provider_spec(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class HealthStatus(str, Enum):
|
class HealthStatus(StrEnum):
|
||||||
OK = "OK"
|
OK = "OK"
|
||||||
ERROR = "Error"
|
ERROR = "Error"
|
||||||
NOT_IMPLEMENTED = "Not Implemented"
|
NOT_IMPLEMENTED = "Not Implemented"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from enum import Enum
|
from enum import StrEnum
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pydantic import BaseModel, Field, field_validator
|
from pydantic import BaseModel, Field, field_validator
|
||||||
|
@ -12,7 +12,7 @@ from pydantic import BaseModel, Field, field_validator
|
||||||
from llama_stack.distribution.utils.config_dirs import RUNTIME_BASE_DIR
|
from llama_stack.distribution.utils.config_dirs import RUNTIME_BASE_DIR
|
||||||
|
|
||||||
|
|
||||||
class TelemetrySink(str, Enum):
|
class TelemetrySink(StrEnum):
|
||||||
OTEL_TRACE = "otel_trace"
|
OTEL_TRACE = "otel_trace"
|
||||||
OTEL_METRIC = "otel_metric"
|
OTEL_METRIC = "otel_metric"
|
||||||
SQLITE = "sqlite"
|
SQLITE = "sqlite"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue