mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-10 10:48:45 +00:00
run formatter
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import { tool, type Tool as AITool } from "ai";
|
||||
import { Log } from "../util/log";
|
||||
import { tool, type Tool as AITool } from "ai"
|
||||
import { Log } from "../util/log"
|
||||
|
||||
const log = Log.create({ service: "tool" });
|
||||
const log = Log.create({ service: "tool" })
|
||||
|
||||
export namespace Tool {
|
||||
export interface Metadata<
|
||||
Properties extends Record<string, any> = Record<string, any>,
|
||||
> {
|
||||
properties: Properties;
|
||||
properties: Properties
|
||||
time: {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
start: number
|
||||
end: number
|
||||
}
|
||||
}
|
||||
export function define<
|
||||
Params,
|
||||
@@ -19,7 +19,7 @@ export namespace Tool {
|
||||
Name extends string,
|
||||
>(
|
||||
input: AITool<Params, Output> & {
|
||||
name: Name;
|
||||
name: Name
|
||||
},
|
||||
) {
|
||||
return tool({
|
||||
@@ -29,33 +29,33 @@ export namespace Tool {
|
||||
id: opts.toolCallId,
|
||||
name: input.name,
|
||||
...params,
|
||||
});
|
||||
})
|
||||
try {
|
||||
const start = Date.now();
|
||||
const result = await input.execute!(params, opts);
|
||||
const start = Date.now()
|
||||
const result = await input.execute!(params, opts)
|
||||
const metadata: Metadata<Output["metadata"]> = {
|
||||
...result.metadata,
|
||||
time: {
|
||||
start,
|
||||
end: Date.now(),
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
metadata,
|
||||
output: result.output,
|
||||
};
|
||||
}
|
||||
} catch (e: any) {
|
||||
log.error("error", {
|
||||
msg: e.toString(),
|
||||
});
|
||||
})
|
||||
return {
|
||||
metadata: {
|
||||
error: true,
|
||||
},
|
||||
output: "An error occurred: " + e.toString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user