Skip to content

Commit

Permalink
Add more sleep, support non-Core
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Oct 28, 2023
1 parent f2f630d commit b6efcc2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 16 deletions.
7 changes: 3 additions & 4 deletions finetuna.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
RootModule = 'finetuna.psm1'

# Version number of this module.
ModuleVersion = '1.0'
ModuleVersion = '1.0.1'

# Minimum PowerShell version
PowerShellVersion = '7.0'
PowerShellVersion = '3.0'

# ID used to uniquely identify this module
GUID = '3dc00ef4-ff85-48c9-8701-b96aa91cfa99'
Expand Down Expand Up @@ -70,9 +70,8 @@
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = @("openai", "chatgpt", "modeling", "tuning", "fine-tuning")
Tags = @("openai", "chatgpt", "modeling", "tuning", "fine-tuning", "potato")

# A URL to the license for this module.
LicenseUri = 'https://github.com/potatoqualitee/finetuna/blob/main/LICENSE'
Expand Down
15 changes: 12 additions & 3 deletions public/New-TuneModel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,19 @@ function New-TuneModel {

Write-Verbose "Tuning took $($stopwatch.Elapsed)"


# Initialize the progress bar
$progressparm = @{
Status = "Fine tuning complete! Now waiting for the new model, $script:currentmodel, to be ready.."
Activity = "Fine-tuning $Model"
PercentComplete = ($progress.PercentComplete) + 1
}
Write-Progress @progressparm

# Use ChatGPT to inform the user about the new model
Start-Sleep 5
Start-Sleep 15
$params = @{
Message = "Can you say 'Say hello to your new model, $script:currentmodel!' exactly like that?"
Message = "Can you say 'Say hello to your new model, $script:currentmodel!' exactly like that?"
Model = $script:currentmodel
ErrorVariable = "weberror"
}
Expand All @@ -120,7 +129,7 @@ function New-TuneModel {
Start-Sleep 10

$params = @{
Message = "Can you say 'Say hello to your new model, $script:currentmodel!' exactly like that?"
Message = "Can you say 'Say hello to your new model, $script:currentmodel!' exactly like that?"
Model = $script:currentmodel
ErrorVariable = "weberror2"
}
Expand Down
49 changes: 40 additions & 9 deletions public/Send-TuneFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,48 @@ function Send-TuneFile {
}
}

# Existing variables
# PowerShell 5.1 needs to create a manual boundary
# for multipart/form-data

$uri = "https://api.openai.com/v1/files"
$form = @{
purpose = "fine-tune"
file = Get-Item -Path $tempFile
}

$params = @{
Uri = $Uri
Method = "POST"
Form = $Form
if ($PSVersionTable.PSVersion.Major -le 5) {
$fileBytes = [System.IO.File]::ReadAllBytes($tempFile)
$fileEnc = [System.Text.Encoding]::GetEncoding('UTF-8').GetString($fileBytes)
$boundary = [System.Guid]::NewGuid().ToString()

$LF = "`r`n"

$bodyLines = (
"--$boundary",
"Content-Disposition: form-data; name=`"purpose`"$LF",
"fine-tune",
"--$boundary",
"Content-Disposition: form-data; name=`"file`"; filename=`"$basename.jsonl`"",
"Content-Type: application/octet-stream$LF",
$fileEnc,
"--$boundary--$LF"
) -join $LF

# turn invoke-restmethod into splat
$params = @{
Uri = $Uri
Method = "POST"
ContentType = "multipart/form-data; boundary=`"$boundary`""
Body = $bodyLines
}
} else {
# Existing variables
$form = @{
purpose = "fine-tune"
file = Get-Item -Path $tempFile
}

$params = @{
Uri = $Uri
Method = "POST"
Form = $Form
}
}

Invoke-RestMethod2 @params
Expand Down

0 comments on commit b6efcc2

Please sign in to comment.