Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switch vercel from zod to jsonSchema #1156

Merged
merged 7 commits into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions js/src/frameworks/vercel.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { tool } from "ai";
import { jsonSchema, tool } from "ai";
import { z } from "zod";
import { ComposioToolSet as BaseComposioToolSet } from "../sdk/base.toolset";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're switching from Zod to JSON Schema, the z import from 'zod' appears to be unused in this file. Consider removing it to keep the imports clean and avoid confusion.

import { TELEMETRY_LOGGER } from "../sdk/utils/telemetry";
import { TELEMETRY_EVENTS } from "../sdk/utils/telemetry/events";
import { RawActionData } from "../types/base_toolset";
import { jsonSchemaToModel } from "../utils/shared";

type Optional<T> = T | null;

const zExecuteToolCallParams = z.object({
const ZExecuteToolCallParams = z.object({
actions: z.array(z.string()).optional(),
apps: z.array(z.string()).optional(),
params: z.record(z.any()).optional(),
Expand Down Expand Up @@ -38,11 +38,11 @@ export class VercelAIToolSet extends BaseComposioToolSet {
}

private generateVercelTool(schema: RawActionData) {
const parameters = jsonSchemaToModel(schema.parameters);
return tool({
description: schema.description,
parameters,
execute: async (params: Record<string, string>) => {
// @ts-ignore the type are JSONSchemV7. Internally it's resolved
parameters: jsonSchema(schema.parameters as unknown),
execute: async (params) => {
return await this.executeToolCall(
{
name: schema.name,
Expand Down Expand Up @@ -76,7 +76,7 @@ export class VercelAIToolSet extends BaseComposioToolSet {
usecaseLimit,
filterByAvailableApps,
actions,
} = zExecuteToolCallParams.parse(filters);
} = ZExecuteToolCallParams.parse(filters);

const actionsList = await this.client.actions.list({
...(apps && { apps: apps?.join(",") }),
Expand Down
Loading