Skip to content

Commit

Permalink
Update type.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb8005 authored Aug 29, 2023
1 parent 1d99d34 commit d3e63fe
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
export type OpenAiModel = "text-davinci-003" | "gpt-3.5-turbo" | "gpt-4";
// https://platform.openai.com/docs/models/model-endpoint-compatibility
export type ChatGPTModel =
| "gpt-4"
| "gpt-4-0613"
| "gpt-4-32k"
| "gpt-4-32k-0613"
| "gpt-3.5-turbo"
| "gpt-3.5-turbo-0613"
| "gpt-3.5-turbo-16k"
| "gpt-3.5-turbo-16k-0613"; // "gpt-3.5-turbo" | "gpt-4";

export interface OpenAIResponseChoice {
text: string;
Expand All @@ -16,7 +25,7 @@ export interface OpenAIResponse {
id: string;
object: "text_completion";
created: number;
model: OpenAiModel;
model: ChatGPTModel;
choices: OpenAIResponseChoice[];
usage: {
prompt_tokens: number;
Expand All @@ -27,7 +36,7 @@ export interface OpenAIResponse {

// ref: https://platform.openai.com/docs/api-reference/completions/create#completions/create-model
export interface Payload {
model: OpenAiModel;
model: ChatGPTModel;
prompt: string;
max_tokens: number;
temperature: number;
Expand All @@ -39,30 +48,21 @@ export interface Payload {
logprobs: number;
}

export type Role = 'user' | 'system' | 'assistant';
export interface Message {role:Role, content:string};

export type PayloadFunctionType = 'string' | 'object';
export type Role = "user" | "system" | "assistant";
export interface Message {
role: Role;
content: string;
}

export interface PayloadFunction {
name: string;
description: string;
parameters: {
type: PayloadFunctionType,
properties: {
location: {
type: PayloadFunctionType,
description: string,
},
unit: {type: PayloadFunctionType, enum?: string[]},
},
required: string[],
},
export interface MessageResponse {
role: Role;
content: string | null;
function_call?: { name: string; arguments: string };
}

export interface PayloadChatCompletion {
model: OpenAiModel,
messages: Message[],
functions?: PayloadFunction[]
function_call?: "auto",
};
export type JSONSchema = any;
export interface Function {
name: string;
description?: string;
parameters: JSONSchema;
}

0 comments on commit d3e63fe

Please sign in to comment.