mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 10:00:39 +00:00
Fix streaming for z-ai in anthropic provider, add preliminary support for tool call streaming. Only reporting argument string deltas, not partial JSON objects
This commit is contained in:
parent
2bdb87dfe7
commit
98a876f3a0
21 changed files with 784 additions and 448 deletions
44
packages/ai/src/agent/tools/get-current-time.ts
Normal file
44
packages/ai/src/agent/tools/get-current-time.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import type { AgentTool } from "../../agent";
|
||||
import type { AgentToolResult } from "../types";
|
||||
|
||||
export interface GetCurrentTimeResult extends AgentToolResult<{ utcTimestamp: number }> {}
|
||||
|
||||
export async function getCurrentTime(timezone?: string): Promise<GetCurrentTimeResult> {
|
||||
const date = new Date();
|
||||
if (timezone) {
|
||||
try {
|
||||
return {
|
||||
output: date.toLocaleString("en-US", {
|
||||
timeZone: timezone,
|
||||
dateStyle: "full",
|
||||
timeStyle: "long",
|
||||
}),
|
||||
details: { utcTimestamp: date.getTime() },
|
||||
};
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid timezone: ${timezone}. Current UTC time: ${date.toISOString()}`);
|
||||
}
|
||||
}
|
||||
return {
|
||||
output: date.toLocaleString("en-US", { dateStyle: "full", timeStyle: "long" }),
|
||||
details: { utcTimestamp: date.getTime() },
|
||||
};
|
||||
}
|
||||
|
||||
export const getCurrentTimeTool: AgentTool<{ utcTimestamp: number }> = {
|
||||
label: "Current Time",
|
||||
name: "get_current_time",
|
||||
description: "Get the current date and time",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
timezone: {
|
||||
type: "string",
|
||||
description: "Optional timezone (e.g., 'America/New_York', 'Europe/London')",
|
||||
},
|
||||
},
|
||||
},
|
||||
execute: async (args: { timezone?: string }) => {
|
||||
return getCurrentTime(args.timezone);
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue