mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-17 22:17:28 +00:00
add types for FineTuningJobCreate OpenAI
This commit is contained in:
@@ -30,7 +30,7 @@ from openai.types.beta.thread_create_params import (
|
||||
from openai.types.beta.threads.message import Message as OpenAIMessage
|
||||
from openai.types.beta.threads.message_content import MessageContent
|
||||
from openai.types.beta.threads.run import Run
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
from typing_extensions import Dict, Required, override
|
||||
|
||||
FileContent = Union[IO[bytes], bytes, PathLike]
|
||||
@@ -455,3 +455,79 @@ class ChatCompletionUsageBlock(TypedDict):
|
||||
prompt_tokens: int
|
||||
completion_tokens: int
|
||||
total_tokens: int
|
||||
|
||||
|
||||
class Hyperparameters(TypedDict):
|
||||
batch_size: Optional[Union[str, int]] = Field(
|
||||
default="auto", description="Number of examples in each batch."
|
||||
)
|
||||
learning_rate_multiplier: Optional[Union[str, float]] = Field(
|
||||
default="auto", description="Scaling factor for the learning rate."
|
||||
)
|
||||
n_epochs: Optional[Union[str, int]] = Field(
|
||||
default="auto", description="The number of epochs to train the model for."
|
||||
)
|
||||
|
||||
|
||||
class FineTuningJobCreate(TypedDict):
|
||||
"""
|
||||
FineTuningJobCreate - Create a fine-tuning job
|
||||
|
||||
Example Request
|
||||
```
|
||||
{
|
||||
"model": "gpt-3.5-turbo",
|
||||
"training_file": "file-abc123",
|
||||
"hyperparameters": {
|
||||
"batch_size": "auto",
|
||||
"learning_rate_multiplier": 0.1,
|
||||
"n_epochs": 3
|
||||
},
|
||||
"suffix": "custom-model-name",
|
||||
"validation_file": "file-xyz789",
|
||||
"integrations": ["slack"],
|
||||
"seed": 42
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
model: str = Field(..., description="The name of the model to fine-tune.")
|
||||
training_file: str = Field(
|
||||
..., description="The ID of an uploaded file that contains training data."
|
||||
)
|
||||
hyperparameters: Optional[Hyperparameters] = Field(
|
||||
default={}, description="The hyperparameters used for the fine-tuning job."
|
||||
)
|
||||
suffix: Optional[str] = Field(
|
||||
default=None,
|
||||
description="A string of up to 18 characters that will be added to your fine-tuned model name.",
|
||||
)
|
||||
validation_file: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The ID of an uploaded file that contains validation data.",
|
||||
)
|
||||
integrations: Optional[List[str]] = Field(
|
||||
default=None,
|
||||
description="A list of integrations to enable for your fine-tuning job.",
|
||||
)
|
||||
seed: Optional[int] = Field(
|
||||
default=None, description="The seed controls the reproducibility of the job."
|
||||
)
|
||||
|
||||
class Config:
|
||||
allow_population_by_field_name = True
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"model": "gpt-3.5-turbo",
|
||||
"training_file": "file-abc123",
|
||||
"hyperparameters": {
|
||||
"batch_size": "auto",
|
||||
"learning_rate_multiplier": 0.1,
|
||||
"n_epochs": 3,
|
||||
},
|
||||
"suffix": "custom-model-name",
|
||||
"validation_file": "file-xyz789",
|
||||
"integrations": ["slack"],
|
||||
"seed": 42,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user