Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #87 from grafana/remove-any-types
Browse files Browse the repository at this point in the history
Replace 'any' types with unions and 'in' checks in type predicates
  • Loading branch information
codeincarnate authored Oct 18, 2023
2 parents 6736053 + 3c862e3 commit ace60c4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/llms/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@ export interface ChatCompletionsChunk {
}

/** Return true if the message is a 'content' message. */
export function isContentMessage(message: any): message is ContentMessage {
return message.content != null;
export function isContentMessage(message: ChatCompletionsDelta): message is ContentMessage {
return 'content' in message
}


/** Return true if the message is a 'done' message. */
export function isDoneMessage(message: any): message is DoneMessage {
return message.done !== undefined
export function isDoneMessage(message: ChatCompletionsDelta): message is DoneMessage {
return 'done' in message && message.done != null;
}

/** Return true if the response is an error response. */
export function isErrorResponse(response: any): response is ChatCompletionsErrorResponse {
return response.error !== undefined;
export function isErrorResponse<T>(response: ChatCompletionsResponse<T> | ChatCompletionsErrorResponse): response is ChatCompletionsErrorResponse {
return 'error' in response;
}

/**
Expand Down

0 comments on commit ace60c4

Please sign in to comment.