mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-31 07:10:00 +00:00
Use our own pydantic models for OpenAI Server APIs
Importing the models from the OpenAI client library required a top-level dependency on the openai python package, and also was incompatible with our API generation code due to some quirks in how the OpenAI pydantic models are defined. So, this creates our own stubs of those pydantic models so that we're in more direct control of our API surface for this OpenAI-compatible API, so that it works with our code generation, and so that the openai python client isn't a hard requirement of Llama Stack's API.
This commit is contained in:
parent
a193c9fc3f
commit
92fdf6d0c9
8 changed files with 1826 additions and 15 deletions
|
|
@ -7,7 +7,6 @@
|
|||
from enum import Enum
|
||||
from typing import Any, Dict, List, Literal, Optional, Protocol, runtime_checkable
|
||||
|
||||
from openai.types.model import Model as OpenAIModel
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from llama_stack.apis.resource import Resource, ResourceType
|
||||
|
|
@ -57,6 +56,22 @@ class ListModelsResponse(BaseModel):
|
|||
data: List[Model]
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class OpenAIModel(BaseModel):
|
||||
"""A model from OpenAI.
|
||||
|
||||
:id: The ID of the model
|
||||
:object: The object type, which will be "model"
|
||||
:created: The Unix timestamp in seconds when the model was created
|
||||
:owned_by: The owner of the model
|
||||
"""
|
||||
|
||||
id: str
|
||||
object: Literal["model"] = "model"
|
||||
created: int
|
||||
owned_by: str
|
||||
|
||||
|
||||
class OpenAIListModelsResponse(BaseModel):
|
||||
data: List[OpenAIModel]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue