-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an experimental support for Realtime API. (#35)
- Loading branch information
Showing
38 changed files
with
2,454 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
test.ps1 | ||
test*.ps1 | ||
**/Debug | ||
**/bin | ||
**/obj |
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,194 @@ | ||
--- | ||
external help file: PSOpenAI-help.xml | ||
Module Name: PSOpenAI | ||
online version: https://github.com/mkht/PSOpenAI/blob/main/Docs/Add-RealtimeSessionItem.md | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Add-RealtimeSessionItem | ||
|
||
## SYNOPSIS | ||
Add a new Item to the Conversation's context, including messages, function calls, and function call responses. | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Add-RealtimeSessionItem | ||
[-Content] <String> | ||
[-EventId <String>] | ||
[-PreviousItemId <String>] | ||
[-ItemId <String>] | ||
[-ItemType <String>] | ||
[-Status <String>] | ||
[-Role <String>] | ||
[-ContentType <String>] | ||
[-ContentTranscript <String>] | ||
[-FunctionCallId <String>] | ||
[-FunctionCallName <String>] | ||
[-FunctionCallArguments <String>] | ||
[-FunctionCallOutput <String>] | ||
[-TriggerResponse] | ||
``` | ||
|
||
## DESCRIPTION | ||
Add a new Item to the Conversation's context, including messages, function calls, and function call responses. This event can be used both to populate a "history" of the conversation and to add new items mid-stream | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
```powershell | ||
PS C:\> Add-RealtimeSessionItem 'Hello. Why is the sun so bright?' | ||
``` | ||
|
||
### Example 2 | ||
```powershell | ||
PS C:\> Add-RealtimeSessionItem 'This is a great question!' -Role assistant | ||
``` | ||
|
||
## PARAMETERS | ||
|
||
### -Content | ||
The content of the message. | ||
|
||
```yaml | ||
Type: String | ||
Aliases: Message, Text | ||
Required: True | ||
Position: 0 | ||
``` | ||
### -ContentTranscript | ||
The transcript of the audio, used for `input_audio` content type. | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -ContentType | ||
The content type (`input_text`, `input_audio`, `text`). | ||
The default value is `input_text`. | ||
|
||
```yaml | ||
Type: String | ||
Accepted values: input_text, input_audio, text, audio | ||
Required: False | ||
Position: Named | ||
Default value: input_text | ||
``` | ||
|
||
### -EventId | ||
Optional client-generated ID used to identify this event. | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -FunctionCallArguments | ||
The arguments of the function call (for `function_call` items). | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -FunctionCallId | ||
The ID of the function call (for `function_call` and `function_call_output` items). | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -FunctionCallName | ||
The name of the function being called (for `function_call` items). | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -FunctionCallOutput | ||
The output of the function call (for `function_call_output` items). | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -ItemId | ||
The unique ID of the item, this can be generated by the client to help manage server-side context, but is not required because the server will generate one if not provided. | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -ItemType | ||
The type of the item (`message`, `function_call`, `function_call_output`). | ||
The default is `message`. | ||
|
||
```yaml | ||
Type: String | ||
Accepted values: message, function_call, function_call_output | ||
Required: False | ||
Position: Named | ||
Default value: message | ||
``` | ||
|
||
### -PreviousItemId | ||
The ID of the preceding item after which the new item will be inserted. If not set, the new item will be appended to the end of the conversation. If set, it allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be returned and the item will not be added. | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -Role | ||
The role of the message sender (`user`, `assistant`, `system`), only applicable for message items. | ||
|
||
```yaml | ||
Type: String | ||
Accepted values: user, assistant, system | ||
Required: False | ||
Position: Named | ||
Default value: user | ||
``` | ||
|
||
### -Status | ||
The status of the item (`completed`, `incomplete`). These have no effect on the conversation. | ||
|
||
```yaml | ||
Type: String | ||
Accepted values: completed, in_progress, incomplete | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -TriggerResponse | ||
If specified, instructs the server to create a response after adding this item. | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
## INPUTS | ||
|
||
## OUTPUTS | ||
|
||
## NOTES | ||
|
||
## RELATED LINKS | ||
|
||
[https://platform.openai.com/docs/api-reference/realtime-client-events/conversation/item/create](https://platform.openai.com/docs/api-reference/realtime-client-events/conversation/item/create) |
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,97 @@ | ||
--- | ||
external help file: PSOpenAI-help.xml | ||
Module Name: PSOpenAI | ||
online version: https://github.com/mkht/PSOpenAI/blob/main/Docs/Connect-RealtimeSession.md | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Connect-RealtimeSession | ||
|
||
## SYNOPSIS | ||
Create a new OpenAI realtime conversation session. | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Connect-RealtimeSession | ||
[-Model <String>] | ||
[-ApiType <OpenAIApiType>] | ||
[-ApiBase <Uri>] | ||
[-AuthType <String>] | ||
[-ApiKey <SecureString>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Create a new realtime conversation session. This technically means connecting to the WebSocket endpoint provided by the OpenAI Realtime API. | ||
|
||
Once the session is opened, the connection will continue until it is disconnected from the server side or a Disconnect-RealtimeSession is executed. You always need run Disconnect-RealtimeSession when you are finished conversation. | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
```powershell | ||
PS C:\> Connect-RealtimeSession -Model 'gpt-4o-realtime-preview-2024-10-01' | ||
``` | ||
|
||
## PARAMETERS | ||
### -Model | ||
It is recommended that you always specify the model you want to use. | ||
|
||
```yaml | ||
Type: String | ||
Required: False | ||
Position: Named | ||
``` | ||
### -ApiBase | ||
Specifies an API endpoint URL such like: `https://your-api-endpoint.test/v1` | ||
If not specified, it will use `https://api.openai.com/v1` | ||
|
||
```yaml | ||
Type: System.Uri | ||
Required: False | ||
Position: Named | ||
Default value: https://api.openai.com/v1 | ||
``` | ||
|
||
### -ApiKey | ||
Specifies API key for authentication. | ||
The type of data should `[string]` or `[securestring]`. | ||
If not specified, it will try to use `$global:OPENAI_API_KEY` or `$env:OPENAI_API_KEY` | ||
|
||
```yaml | ||
Type: Object | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
### -ApiType | ||
Specifies API type of use. `OpenAI`(default) or `Azure` | ||
|
||
```yaml | ||
Type: OpenAIApiType | ||
Accepted values: OpenAI, Azure | ||
Required: False | ||
Position: Named | ||
Default value: OpenAI | ||
``` | ||
|
||
### -AuthType | ||
If you wish to use Entra-ID based authentication, specifies as `azure_ad`. | ||
|
||
```yaml | ||
Type: String | ||
Accepted values: openai, azure, azure_ad | ||
Required: False | ||
Position: Named | ||
``` | ||
|
||
## INPUTS | ||
|
||
## OUTPUTS | ||
|
||
## NOTES | ||
|
||
## RELATED LINKS | ||
|
||
[https://platform.openai.com/docs/guides/realtime](https://platform.openai.com/docs/guides/realtime) |
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,37 @@ | ||
--- | ||
external help file: PSOpenAI-help.xml | ||
Module Name: PSOpenAI | ||
online version: https://github.com/mkht/PSOpenAI/blob/main/Docs/Disconnect-RealtimeSession.md | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Disconnect-RealtimeSession | ||
|
||
## SYNOPSIS | ||
Close realtime session. | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Disconnect-RealtimeSession | ||
``` | ||
|
||
## DESCRIPTION | ||
Terminates a connected conversation session. If audio input/output is activated, they are also terminated. | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
```powershell | ||
PS C:\> Disconnect-RealtimeSession | ||
``` | ||
|
||
## PARAMETERS | ||
|
||
## INPUTS | ||
|
||
## OUTPUTS | ||
|
||
## NOTES | ||
|
||
## RELATED LINKS |
Oops, something went wrong.