nsarrazin's picture
nsarrazin HF Staff
Function calling (#996)
564e576 unverified
raw
history blame
1.24 kB
import type { WebSearch, WebSearchSource } from "$lib/types/WebSearch";
import {
MessageUpdateType,
MessageWebSearchUpdateType,
type MessageWebSearchErrorUpdate,
type MessageWebSearchFinishedUpdate,
type MessageWebSearchGeneralUpdate,
type MessageWebSearchSourcesUpdate,
} from "$lib/types/MessageUpdate";
export function makeGeneralUpdate(
update: Pick<MessageWebSearchGeneralUpdate, "message" | "args">
): MessageWebSearchGeneralUpdate {
return {
type: MessageUpdateType.WebSearch,
subtype: MessageWebSearchUpdateType.Update,
...update,
};
}
export function makeErrorUpdate(
update: Pick<MessageWebSearchErrorUpdate, "message" | "args">
): MessageWebSearchErrorUpdate {
return {
type: MessageUpdateType.WebSearch,
subtype: MessageWebSearchUpdateType.Error,
...update,
};
}
export function makeSourcesUpdate(sources: WebSearchSource[]): MessageWebSearchSourcesUpdate {
return {
type: MessageUpdateType.WebSearch,
subtype: MessageWebSearchUpdateType.Sources,
message: "sources",
sources,
};
}
export function makeFinalAnswerUpdate(webSearch: WebSearch): MessageWebSearchFinishedUpdate {
return {
type: MessageUpdateType.WebSearch,
subtype: MessageWebSearchUpdateType.Finished,
webSearch,
};
}