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

Fix validator not returning parsed value #257

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions packages/lms-client/src/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ export class Chat extends MaybeMutable<ChatHistoryData> {
*/
export type ChatLike = ChatInput | string | Chat | ChatMessageInput | ChatHistoryData;
export const chatHistoryLikeSchema = z.union([
z.instanceof(Chat as any),
chatHistoryDataSchema,
z.string(),
chatHistoryInputSchema,
chatMessageInputSchema,
z.instanceof(Chat as any),
]) as ZodSchema<ChatLike>;

/**
Expand Down Expand Up @@ -772,8 +772,8 @@ export class ChatMessage extends MaybeMutable<ChatMessageData> {
*/
export type ChatMessageLike = ChatMessageInput | string | ChatMessage | ChatMessageData;
export const chatMessageLikeSchema = z.union([
z.instanceof(ChatMessage as any),
chatMessageInputSchema,
z.string(),
z.instanceof(ChatMessage as any),
chatMessageDataSchema,
]) as ZodSchema<ChatMessageLike>;
4 changes: 3 additions & 1 deletion packages/lms-client/src/llm/LLMDynamicHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export interface LLMRespondOpts<TStructuredOutputType = unknown>
*/
onMessage?: (message: ChatMessage) => void;
}
const llmRespondOptsSchema = llmPredictionOptsSchema;
const llmRespondOptsSchema = llmPredictionOptsSchema.extend({
onMessage: z.function().optional(),
});

type LLMRespondExtraOpts<TStructuredOutputType = unknown> = Omit<
LLMRespondOpts<TStructuredOutputType>,
Expand Down
2 changes: 1 addition & 1 deletion packages/lms-common/src/Validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class Validator {
index,
}));
if (errors.length === 0) {
return values as T;
return results.map(result => (result as any).data) as T;
} else {
const erroredValues = new Set(errors.map(({ index }) => index));
const lead = leadProducer(erroredValues);
Expand Down