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

Deno Compatibility #188

Open
7flash opened this issue Nov 25, 2023 · 11 comments
Open

Deno Compatibility #188

7flash opened this issue Nov 25, 2023 · 11 comments

Comments

@7flash
Copy link

7flash commented Nov 25, 2023

No description provided.

@7flash
Copy link
Author

7flash commented Nov 25, 2023

It works "deno run main.ts"

main.ts

import { generateText, openai } from "npm:modelfusion";

But when I am trying to build with deno-esbuild, it seems to not support npm specifiers and therefore would be better if I could import modelfusion package directly from deno.land

 const { generateText } = await import("https://deno.land/x/modelfusion/mod.ts");

@7flash
Copy link
Author

7flash commented Nov 25, 2023

As a temporary solution, following works:

    const { generateText } = await import('https://dev.jspm.io/modelfusion');  

@lgrammel
Copy link
Collaborator

@7flash thanks for reporting the issue!

I'm not too familiar with Deno. From your report, my sense is that ideally modelfusion should work with deno-esbuild. Can you tell me the error that you encountered w/ deno-esbuild?

regarding deno.land, is that a separate pkg registry i would need to upload to?

@7flash
Copy link
Author

7flash commented Nov 25, 2023

The issue evanw/esbuild#3506 seemed to be resolved by using jspm and though it works for simple case it fails when trying to register tools because of another issue with zod colinhacks/zod#2991

@7flash thanks for reporting the issue!

I'm not too familiar with Deno. From your report, my sense is that ideally modelfusion should work with deno-esbuild. Can you tell me the error that you encountered w/ deno-esbuild?

regarding deno.land, is that a separate pkg registry i would need to upload to?

@lgrammel
Copy link
Collaborator

lgrammel commented Nov 25, 2023

colinhacks/zod#2991 is not a Zod error. ModelFusion contains something called ZodSchema as well (I want to change the name to disambiguate, but haven't come up with a better name yet).

See https://github.com/lgrammel/modelfusion/blob/main/src/core/schema/ZodSchema.ts

The error message points to a potential issue with zod-to-json-schema - do you know if zod to json schema works in deno? ( https://www.npmjs.com/package/zod-to-json-schema )

@7flash
Copy link
Author

7flash commented Nov 26, 2023

Is there are a way to provide directy my json schema instead of zod? Because I am building kind of visual editor based on modelfusion where user ends up describing his tools in json format anyway

@lgrammel
Copy link
Collaborator

lgrammel commented Nov 26, 2023

@7flash yes, you can use new UncheckedSchema (see https://github.com/lgrammel/modelfusion/blob/main/examples/basic/src/util/schema/generate-structure-unchecked-json-schema-example.ts for an example).

This will not do any validation on the structure of the result tho, just cast it (which could be wrong at runtime).

You can also implement your own schema and json schema acccessor, see https://github.com/lgrammel/modelfusion/blob/main/src/core/schema/Schema.ts and https://github.com/lgrammel/modelfusion/blob/main/src/core/schema/JsonSchemaProducer.ts for the relevant interfaces (they both need to be implemented in a single object / class). That way, you can use other JSON validations like Validbot.

Please note that ModelFusion uses Zod internally for validations that are not related to user-defined schemas.

PS: I've added an uncheckedSchema(...) facade function in v0.83.0 as well as a zodSchema facade function to more clearly distinguish from the zod ZodSchema

@7flash
Copy link
Author

7flash commented Nov 26, 2023

@lgrammel that's amazing, and here just recorded a demo of visual agent editor I am building with modelfusion: https://youtu.be/V-rI_ughijw

@lgrammel
Copy link
Collaborator

@lgrammel that's amazing, and here just recorded a demo of visual agent editor I am building with modelfusion: https://youtu.be/V-rI_ughijw

Pretty cool! Do you have an open source project or a website? I have started a showcase section on the ModelFusion website, when the project is mature and available, this might be a good fit.

@7flash
Copy link
Author

7flash commented Nov 27, 2023

@lgrammel that's amazing, and here just recorded a demo of visual agent editor I am building with modelfusion: https://youtu.be/V-rI_ughijw

Pretty cool! Do you have an open source project or a website? I have started a showcase section on the ModelFusion website, when the project is mature and available, this might be a good fit.

Yes it's here https://github.com/galaxydo/galaxy-polkadot

@lgrammel
Copy link
Collaborator

@lgrammel that's amazing, and here just recorded a demo of visual agent editor I am building with modelfusion: https://youtu.be/V-rI_ughijw

Pretty cool! Do you have an open source project or a website? I have started a showcase section on the ModelFusion website, when the project is mature and available, this might be a good fit.

Yes it's here https://github.com/galaxydo/galaxy-polkadot

Awesome - feel free to send a pull request. The "story teller" example in the showcase shows what needs to be added (section & separate page)

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

No branches or pull requests

2 participants