Skip to content

Commit

Permalink
Enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Jun 29, 2024
1 parent 818e975 commit abd9922
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ Right now, the awesome functionality is that you can pipe a whole directory of j
Dependencies will be installed automatically.

3. **Get and set your OpenAI API Key**:
Get/Create your OpenAI API key from [ https://platform.openai.com/account/api-keys]( https://platform.openai.com/account/api-keys) and then set as *plain text* with `$env:OpenAIKey`:
Get/Create your OpenAI API key from [ https://platform.openai.com/account/api-keys]( https://platform.openai.com/account/api-keys) and then set as *plain text* with `$env:OPENAI_API_KEY`:
```powershell
$env:OpenAIKey = "sk-fake-T3BlbFJi7vpHiKhyYKy8aUT3Blbk"
$env:OPENAI_API_KEY = "sk-fake-T3BlbFJi7vpHiKhyYKy8aUT3Blbk"
```
You may also want to put it in your $profile.
You may also want to put it in your $profile. `$env:OpenAIKey` also works to provide compatibility with other PowerShell modules.

## Quick Start

Expand Down Expand Up @@ -99,22 +99,32 @@ Drop that append parameter and train a bunch of models with a bunch of jsonl fil

| Command Name | Description |
|--------------------|----------------------------------------------------|
| Clear-TuneProvider | Clears the OpenAI provider configuration for finetuna |
| Compare-Embedding | Calculates the similarity between two embedding vectors |
| Create-CustomModel | An alias for New-TuneModel |
| Invoke-TunedChat | Initiates a chat session with any model |
| Get-Embedding | Creates an embedding vector for the given text |
| Get-TuneFile | Retrieves a list or a specific tuning file |
| Get-TuneFileContent| Reads the content of a list or specific tuning file|
| Get-TuneJob | Retrieves a list or details of a specific tuning job|
| Get-TuneJobEvent | Fetches events for a list or specific tuning job |
| Get-TuneModel | Retrieves a list or a specific tuning model |
| Get-TuneModelDefault| Gets the default model that Invoke-TuneChat uses |
| Get-TuneProvider | Retrieves the current OpenAI provider configuration for finetuna |
| Invoke-TuneChat | Initiates a chat session with a tuning model |
| Invoke-TunedChat | Initiates a chat session with any model (alias for Invoke-TuneChat) |
| Measure-TuneToken | Measures the token usage of the provided text |
| New-TuneModel | Creates a new tuning model |
| Remove-TuneFile | Deletes a specific tuning file |
| Remove-TuneModel | Deletes a specific tuning model |
| Request-TuneFileReview | Submits a file to Invoke-TuneChat for improvement suggestions |
| Send-TuneFile | Sends a file for tuning |
| Set-TuneModelDefault| Sets the default model that Invoke-TuneChat will use|
| Set-TuneProvider | Configures the OpenAI or Azure OpenAI service context for finetuna |
| Start-TuneDemo | Launches the finetuna demo notebook |
| Start-TuneJob | Starts a new tuning job |
| Stop-TuneJob | Stops a running tuning job |
| Test-TuneFile | Validates tune files before sending to model for training |
| Wait-TuneJob | Waits for a fine-tuning job to complete |

## Azure OpenAI Services

Expand Down
1 change: 1 addition & 0 deletions finetuna.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'Send-TuneFile',
'Set-TuneModelDefault',
'Set-TuneProvider',
'Start-TuneDemo',
'Start-TuneJob',
'Stop-TuneJob',
'Test-TuneFile',
Expand Down
5 changes: 5 additions & 0 deletions finetuna.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ if (-not (Test-Path -Path $script:configdir)) {

$configFile = Join-Path -Path $script:configdir -ChildPath config.json

# make it compat with PSAI
if ($env:OpenAIKey -and -not $env:OPENAI_API_KEY) {
$env:OPENAI_API_KEY = $env:OpenAIKey
}

$apiKey = (Get-OpenAIContext).ApiKey

if (-not $apiKey -and (Test-Path -Path $configFile)) {
Expand Down
64 changes: 64 additions & 0 deletions public/Start-TuneDemo.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
function Start-TuneDemo {
<#
.SYNOPSIS
Launches the finetuna demo notebook in Visual Studio Code or a platform-specific launcher.
.DESCRIPTION
The Start-TuneDemo function attempts to launch the 'demo.ipynb' notebook in Visual Studio Code (regular or Insiders edition).
If Visual Studio Code is not available, it falls back to platform-specific launchers such as Jupyter or the default application associated with .ipynb files.
If no suitable launcher is found, it displays a warning message advising the user to open the notebook manually.
.EXAMPLE
PS C:\> Start-TuneDemo
Launches the 'demo.ipynb' notebook in Visual Studio Code or a platform-specific launcher.
.NOTES
- The function assumes that the 'demo.ipynb' notebook is located in the root directory of the finetuna module.
- It attempts to launch the notebook using the following methods, in order of preference:
1. Visual Studio Code (regular edition)
2. Visual Studio Code Insiders edition
3. Platform-specific launchers (Jupyter on Windows, 'open' on macOS, 'xdg-open' on Linux)
- If none of the above methods succeed, it displays a warning message to open the notebook manually.
#>
[CmdletBinding()]
param()

$notebookPath = Join-Path -Path $script:ModuleRoot -ChildPath "demo.ipynb"

if (-not (Test-Path -Path $notebookPath)) {
Write-Error "The demo notebook 'demo.ipynb' was not found in the module directory."
return
}

$launched = $false

# Try launching with Visual Studio Code
$vscodeCommands = @("code", "code-insiders")
foreach ($command in $vscodeCommands) {
$vscodeCheck = Get-Command -Name $command -ErrorAction SilentlyContinue
if ($vscodeCheck) {
Start-Process -FilePath $command -ArgumentList "`"$notebookPath`""
$launched = $true
break
}
}

if (-not $launched) {
# Fall back to platform-specific launchers
if ($IsWindows) {
Start-Process -FilePath "jupyter" -ArgumentList "notebook `"$notebookPath`""
$launched = $true
} elseif ($IsMacOS) {
Start-Process -FilePath "open" -ArgumentList "-a Jupyter `"$notebookPath`""
$launched = $true
} elseif ($IsLinux) {
Start-Process -FilePath "xdg-open" -ArgumentList "`"$notebookPath`""
$launched = $true
}
}

if (-not $launched) {
Write-Warning "Failed to launch the demo notebook. Please open it manually."
}
}

0 comments on commit abd9922

Please sign in to comment.