UNPKG

@autobe/agent

Version:

AI backend server code generator

44 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createAgenticaHistory = createAgenticaHistory; function createAgenticaHistory(props) { if (props.history.type === "userMessage") { // @todo Seems to need more explanation that // this is not a pure text // but a text by analyzing an image const history = Object.assign(Object.assign({}, props.history), { contents: props.history.contents.map((c) => { if (c.type === "image") { return { type: "text", text: c.description, }; } else return c; }) }); return Object.assign(Object.assign({}, history), { toJSON: () => history }); } else if (props.history.type === "assistantMessage") return Object.assign(Object.assign({}, props.history), { toJSON: () => props.history }); const operation = props.operations.find((op) => op.function.name === props.history.type); if (operation === undefined) return null; const partial = { id: props.history.id, created_at: props.history.created_at, type: "execute", arguments: { instruction: props.history.type === "analyze" ? undefined : props.history.instruction, }, value: { success: props.history.type === "analyze" || props.history.type === "interface" ? true : props.history.compiled.type === "success", }, success: true, }; return Object.assign(Object.assign({}, partial), { protocol: operation.protocol, operation: operation, toJSON: () => (Object.assign(Object.assign({}, partial), { protocol: operation.protocol, operation: operation.toJSON() })) }); } //# sourceMappingURL=createAgenticaHistory.js.map