Skip to content

Conversation

@anotherjesse
Copy link
Contributor

@anotherjesse anotherjesse commented May 9, 2025

Summary by mrge

Added a new generateObject LLM API and builder node for generating structured JSON objects from prompts and schemas, with backend validation and example usage in recipes.

  • New Features

    • Added generateObject API endpoint and handler for LLM-backed JSON object generation.
    • Introduced generateObject builder node and client support.
    • Added schema validation using Ajv on the backend.
    • Provided example usage in seeder/json.tsx and updated counter recipe for JSON mode.
  • Dependencies

    • Added Ajv and related packages for JSON schema validation.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 22 issues across 15 files. Review them in mrge.io

Copy link
Contributor

Choose a reason for hiding this comment

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

Using 'any' as default type parameter reduces type safety. Consider using a more specific default type.

Copy link
Contributor

Choose a reason for hiding this comment

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

The function returns { object, spanId } but doesn't include the 'id' field required by LLMGenerateObjectResponse

Copy link
Contributor

Choose a reason for hiding this comment

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

The method returns only the 'object' property from the response but the return type includes an 'id' field which is not being returned

Copy link
Contributor

Choose a reason for hiding this comment

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

The imported generateObject function references an undefined variable 'prompt' in the llm.ts file

Copy link
Contributor

Choose a reason for hiding this comment

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

Using z.any() in schema validation reduces type safety and can lead to unexpected runtime errors

Copy link
Contributor

Choose a reason for hiding this comment

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

No error handling for LLM call failures

Copy link
Contributor

Choose a reason for hiding this comment

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

JSON.stringify used directly for UI display without proper formatting

Copy link
Contributor

Choose a reason for hiding this comment

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

Parameter name shadows type name causing potential confusion

Copy link
Contributor

Choose a reason for hiding this comment

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

Unused imported 'ifElse' function

Copy link
Collaborator

Choose a reason for hiding this comment

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

use commontools for all of these imports including h

Copy link
Collaborator

Choose a reason for hiding this comment

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

CompilerError: [ERROR] Module '"commontools"' has no exported member 'generateObject'. [/numbersjson.tsx:4:3]

generateObject definition (~virtual, see other builtins) must be added to @commontools/api, and its types generated via cd packages/static && deno task compile-api-types

deno.lock Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

are these changes to the lock intentional?

@anotherjesse
Copy link
Contributor Author

@jsantell thx for review - I'm updating it now to work with all the changes!

@anotherjesse anotherjesse changed the title wip of generateObject new builtin: generateObject Jun 19, 2025
@anotherjesse anotherjesse merged commit 88e89da into main Jun 19, 2025
6 checks passed
@anotherjesse anotherjesse deleted the json-mode-redux branch June 19, 2025 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants