Skip to content

Commit

Permalink
Merge pull request #53 from microsoft/joh/mammoth-meadowlark
Browse files Browse the repository at this point in the history
add `FunctionMessage` and `ChatRole.Function`
  • Loading branch information
ulugbekna authored Jun 5, 2024
2 parents b32fad9 + 457cd08 commit 4cdaea5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vscode/prompt-tsx",
"version": "0.1.12-alpha",
"version": "0.1.13-alpha",
"description": "Declare LLM prompts with TSX",
"main": "./dist/base/index.js",
"types": "./dist/base/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/base/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export declare interface ChatMessage {
export enum ChatRole {
System = 'system',
User = 'user',
Assistant = 'assistant'
Assistant = 'assistant',
Function = 'function'
}

/**
Expand Down
12 changes: 12 additions & 0 deletions src/base/promptElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ export class AssistantMessage extends BaseChatMessage {
}
}

/**
* A {@link PromptElement} which can be rendered to an OpenAI function chat message.
*
* See {@link https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages}
*/
export class FunctionMessage extends BaseChatMessage {
constructor(props: ChatMessageProps & { name: string }) {
props.role = ChatRole.Function;
super(props);
}
}

/**
* A chunk of single-line or multi-line text that is a direct child of a {@link ChatMessagePromptElement}.
*
Expand Down

0 comments on commit 4cdaea5

Please sign in to comment.