Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract ChatCompletionMessage type #19

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ export interface ChatCompletionOptions {
* The messages to generate chat completions for, in the chat format.The messages to generate chat completions for, in the chat format.
* https://platform.openai.com/docs/api-reference/chat/create#chat/create-messages
*/
messages: {
name?: string;
role: "system" | "assistant" | "user";
content: string;
}[];
messages: ChatCompletionMessage[];

/**
* What sampling temperature to use, between 0 and 2.
Expand Down Expand Up @@ -205,14 +201,14 @@ export interface ChatCompletionOptions {
functions?: ChatCompletionOptionsFunction[];

/**
* Controls how the model responds to function calls.
* "none" means the model does not call a function, and responds to the end-user.
* "auto" means the model can pick between an end-user or calling a function.
* Specifying a particular function via {"name":\ "my_function"} forces the model to call that function.
* Controls how the model responds to function calls.
* "none" means the model does not call a function, and responds to the end-user.
* "auto" means the model can pick between an end-user or calling a function.
* Specifying a particular function via {"name":\ "my_function"} forces the model to call that function.
* "none" is the default when no functions are present. "auto" is the default if functions are present.
* https://platform.openai.com/docs/api-reference/chat/create#chat/create-function_call
*/
function_call?: 'none' | 'auto' | { name: string };
function_call?: "none" | "auto" | { name: string };
}

export type ChatCompletionOptionsFunction = {
Expand All @@ -221,13 +217,25 @@ export type ChatCompletionOptionsFunction = {
parameters: ObjectSchema;
};

type JSONSchema = (
| ObjectSchema
| StringSchema
| NumberSchema
| BooleanSchema
| ArraySchema
) & { description?: string };
export interface ChatCompletionMessage {
name?: string;
role: "system" | "assistant" | "user" | "function";
blakechambers marked this conversation as resolved.
Show resolved Hide resolved
content: string | null;
function_call?: {
"name": string;
"arguments": string;
};
}

type JSONSchema =
& (
| ObjectSchema
| StringSchema
| NumberSchema
| BooleanSchema
| ArraySchema
)
& { description?: string };
Comment on lines +260 to +268
Copy link
Contributor Author

@blakechambers blakechambers Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change unrelated to the PR: this is auto-formatting from the vscode deno formatter.


type ObjectSchema = {
type: "object";
Expand Down Expand Up @@ -668,15 +676,7 @@ export interface ChatCompletion {
created: number;
choices: {
index: number;
message: {
name?: string;
role: "system" | "assistant" | "user";
content: string;
function_call?: {
"name": string,
"arguments": string
}
};
message: ChatCompletionMessage;
finish_reason: string;
}[];
usage: {
Expand Down