generated from joyqi/typescript-module-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
174 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { ApiClient } from ".."; | ||
import { File } from "./files"; | ||
|
||
type FineTuneHyperparameters = { | ||
learning_rate_multiplier: number; | ||
prompt_loss_weight: number; | ||
batch_size: number; | ||
n_epochs: number; | ||
}; | ||
|
||
type FineTuneRequest = { | ||
training_file: string; | ||
validation_file?: string; | ||
model?: string; | ||
compute_classification_metrics?: boolean; | ||
classification_n_classes?: number; | ||
classification_positive_class?: string; | ||
classification_betas?: number[]; | ||
suffix?: string; | ||
} & FineTuneHyperparameters; | ||
|
||
type FineTuneEvent = { | ||
object: "fine-tune-event"; | ||
created_at: number; | ||
level: string; | ||
message: string; | ||
} | ||
|
||
type FineTune = { | ||
id: string; | ||
object: "fine-tune"; | ||
model: string; | ||
created_at: number; | ||
fine_tuned_model: string | null; | ||
hyperparameters: FineTuneHyperparameters; | ||
organization_id: string; | ||
result_files: File[]; | ||
status: string; | ||
validation_files: File[]; | ||
training_files: File[]; | ||
updated_at: number; | ||
events: FineTuneEvent[]; | ||
}; | ||
|
||
type FineTuneList = { | ||
object: "list"; | ||
data: Omit<FineTune, 'events'>[]; | ||
}; | ||
|
||
type FineTuneEvents = { | ||
object: "list"; | ||
data: FineTuneEvent[]; | ||
}; | ||
|
||
export function createFineTune(client: ApiClient) { | ||
return async (fineTuneRequest: FineTuneRequest): Promise<FineTune> => { | ||
return await client("fine-tunes", { method: "POST", data: fineTuneRequest }); | ||
} | ||
} | ||
|
||
export function retrieveFineTune(client: ApiClient) { | ||
return async (id: string): Promise<FineTune> => { | ||
return await client(`fine-tunes/${id}`, { method: "GET" }); | ||
} | ||
} | ||
|
||
export function listFineTunes(client: ApiClient) { | ||
return async (): Promise<FineTuneList> => { | ||
return await client("fine-tunes", { method: "GET" }); | ||
} | ||
} | ||
|
||
export function cancelFineTune(client: ApiClient) { | ||
return async (id: string): Promise<FineTune> => { | ||
return await client(`fine-tunes/${id}/cancel`, { method: "POST" }); | ||
} | ||
} | ||
|
||
export function listFineTuneEvents(client: ApiClient) { | ||
return async (id: string): Promise<FineTuneEvents> => { | ||
return await client(`fine-tunes/${id}/events`, { method: "GET" }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters