Skip to content

Conversation

andresgutgon
Copy link
Contributor

@andresgutgon andresgutgon commented Sep 30, 2025

What?

A more detailed explanation is in the last attend to merge this

This PR will focus on fixing a bug we saw yesterday related with compatibility between our messages and new vercel sdk model message format.

TODO

  • Add compatibility layer
  • Add test for it
  • QA all the things in the other PR + the bug

@andresgutgon andresgutgon force-pushed the feature/vercel-sdk-v5-zod-4-replace-zsa-server-actions branch 2 times, most recently from 1d68a17 to 47fdb6c Compare September 30, 2025 09:05
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🔥 I removed the vercel rules. Please check this file and let me know if something on convertLatitudeMessages method is not there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix for what was failing yesterday.

Basically I took all the types from Vercel SDK and tried to match with our message types trying to ensure the messages passed to Vercel are in their format

@andresgutgon andresgutgon force-pushed the feature/vercel-sdk-v5-zod-4-replace-zsa-server-actions branch from 47fdb6c to 2abea99 Compare September 30, 2025 09:19
if (result) {
await executeFrontendAction({
type,
parameters: result as ActionFrontendParameters<T>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this changed, how did the type change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Complex generic. I had to force the type

Copy link
Contributor

Choose a reason for hiding this comment

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

ok np I will review it in the future

* This can be improved by passing specific schemas per type/metric
* But I'm fed up of fixing zod errors sorry
*/
type EvaluationV2FormSchema = StandardSchemaV1<{
Copy link
Contributor

Choose a reason for hiding this comment

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

No more automatic action error typying?

Copy link
Contributor Author

@andresgutgon andresgutgon Sep 30, 2025

Choose a reason for hiding this comment

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

It's automatic It can be improved in this case. Which is a generic form that pass actions

}

return Result.ok(output)
return Result.ok(
response.object as S extends z.ZodType ? z.infer<S> : unknown,
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be just return response.object as unknown as we dont know the schema

neoxelox

This comment was marked as resolved.

neoxelox
neoxelox previously approved these changes Sep 30, 2025
@andresgutgon andresgutgon force-pushed the feature/vercel-sdk-v5-zod-4-replace-zsa-server-actions branch 2 times, most recently from bf0ba64 to 78607fa Compare September 30, 2025 15:42
rules = applyProviderRules({ providerType, messages, config: rules.config })
rules = vercelSdkRules(rules, providerType)

const vercelMessages = convertLatitudeMessagesToVercelFormat({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main fix from last attend.

Now this function try to fully translate our messages to Vercel SDK messages before be sent to the AI

ruleMessage: 'Google requires at least one user message',
},
],
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved from createProvider here this rule. Makes more sense at this point

@andresgutgon andresgutgon force-pushed the feature/vercel-sdk-v5-zod-4-replace-zsa-server-actions branch from 78607fa to ea72e0e Compare September 30, 2025 16:26
@andresgutgon andresgutgon force-pushed the feature/vercel-sdk-v5-zod-4-replace-zsa-server-actions branch from ea72e0e to 071919a Compare September 30, 2025 16:45
@andresgutgon andresgutgon merged commit 2645857 into main Oct 1, 2025
7 checks passed
@andresgutgon andresgutgon deleted the feature/vercel-sdk-v5-zod-4-replace-zsa-server-actions branch October 1, 2025 07:10
@github-actions github-actions bot locked and limited conversation to collaborators Oct 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants