Add model and file management: - model/model.go: ModelCard (unified base/fine-tuned), ModelCapabilities - file/file.go: File, ListParams, Purpose/SampleType/Source enums - ListModels, GetModel, DeleteModel service methods - UploadFile (multipart/form-data), ListFiles (query params), GetFile, DeleteFile, GetFileContent (binary stream), GetFileURL (signed URL) - doMultipart() HTTP helper for file uploads - 13 new tests covering all endpoints including multipart parsing
74 lines
1.9 KiB
Go
74 lines
1.9 KiB
Go
package file
|
|
|
|
// Purpose indicates the intended use of an uploaded file.
|
|
type Purpose string
|
|
|
|
const (
|
|
PurposeFineTune Purpose = "fine-tune"
|
|
PurposeBatch Purpose = "batch"
|
|
PurposeOCR Purpose = "ocr"
|
|
)
|
|
|
|
// SampleType categorizes file content.
|
|
type SampleType string
|
|
|
|
const (
|
|
SampleTypePretrain SampleType = "pretrain"
|
|
SampleTypeInstruct SampleType = "instruct"
|
|
SampleTypeBatchReq SampleType = "batch_request"
|
|
SampleTypeBatchResult SampleType = "batch_result"
|
|
SampleTypeBatchError SampleType = "batch_error"
|
|
)
|
|
|
|
// Source indicates how a file was created.
|
|
type Source string
|
|
|
|
const (
|
|
SourceUpload Source = "upload"
|
|
SourceRepository Source = "repository"
|
|
SourceMistral Source = "mistral"
|
|
)
|
|
|
|
// File represents an uploaded file.
|
|
type File struct {
|
|
ID string `json:"id"`
|
|
Object string `json:"object"`
|
|
Bytes int `json:"bytes"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
Filename string `json:"filename"`
|
|
Purpose Purpose `json:"purpose"`
|
|
SampleType SampleType `json:"sample_type"`
|
|
NumLines *int `json:"num_lines,omitempty"`
|
|
MimeType *string `json:"mimetype,omitempty"`
|
|
Source Source `json:"source"`
|
|
Signature *string `json:"signature,omitempty"`
|
|
Deleted bool `json:"deleted,omitempty"`
|
|
}
|
|
|
|
// ListResponse is the response from listing files.
|
|
type ListResponse struct {
|
|
Data []File `json:"data"`
|
|
Object string `json:"object"`
|
|
Total *int `json:"total,omitempty"`
|
|
}
|
|
|
|
// DeleteResponse is the response from deleting a file.
|
|
type DeleteResponse struct {
|
|
ID string `json:"id"`
|
|
Object string `json:"object"`
|
|
Deleted bool `json:"deleted"`
|
|
}
|
|
|
|
// SignedURL is the response from getting a signed file URL.
|
|
type SignedURL struct {
|
|
URL string `json:"url"`
|
|
}
|
|
|
|
// ListParams holds optional parameters for listing files.
|
|
type ListParams struct {
|
|
Page *int
|
|
PageSize *int
|
|
Purpose *Purpose
|
|
Search *string
|
|
}
|