Skip to content

Commit

Permalink
Proper return type for toVsCodeChatMessages (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens authored Dec 1, 2024
1 parent 3469c39 commit 70ec988
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export async function renderPrompt<P extends BasePromptElementProps>(
? new AnyTokenizer((text, token) => tokenizerMetadata.countTokens(text, token))
: tokenizerMetadata;
const renderer = new PromptRenderer(endpoint, ctor, props, tokenizer);
let { messages, tokenCount, references, metadata } = await renderer.render(progress, token);
const renderResult = await renderer.render(progress, token);
const { tokenCount, references, metadata } = renderResult;
let messages: ChatMessage[] | LanguageModelChatMessage[] = renderResult.messages;
const usedContext = renderer.getUsedContext();

if (mode === 'vscode') {
Expand Down Expand Up @@ -209,7 +211,7 @@ export function renderElementJSON<P extends BasePromptElementProps>(
* @param messages - The array of {@link ChatMessage} objects to convert.
* @returns An array of {@link LanguageModelChatMessage VS Code chat messages}.
*/
export function toVsCodeChatMessages(messages: ChatMessage[]) {
export function toVsCodeChatMessages(messages: ChatMessage[]): LanguageModelChatMessage[] {
const vscode = require('vscode');
return messages.map(m => {
switch (m.role) {
Expand Down

0 comments on commit 70ec988

Please sign in to comment.