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

should we read interface as a text file? #142

Open
dcsan opened this issue Nov 18, 2023 · 2 comments
Open

should we read interface as a text file? #142

dcsan opened this issue Nov 18, 2023 · 2 comments
Labels
Question Further information is requested

Comments

@dcsan
Copy link

dcsan commented Nov 18, 2023

looking at the examples:

https://github.com/microsoft/TypeChat/blob/main/examples/calendar/src/main.ts#L11C25-L11C25
https://github.com/microsoft/TypeChat/blob/main/examples/restaurant/src/main.ts#L15

const schema = fs.readFileSync(path.join(__dirname, "calendarActionsSchema.ts"), "utf8");

I find it odd that we read in the typescript schema as a text file.
after the code is transpiled, those .ts files won't exist.

I guess I could manually copy over to the /dist after building but that seems a hack

Is there a method to just import the schema or pass a typescript type?

@gchartier
Copy link

Seems like one argument for keeping reading it as a text file is to enable the use of comments alongside the types for added context to guide the model.

But I agree, it's kind of inelegant.

@DanielRosenwasser
Copy link
Member

The current approach here is to make sure the .ts file is ingestible via either

  1. copying the .ts file into the output directory, or
  2. using a runner like ts-node or tsx to execute your TypeScript directly.

We're also looking at another approach, using a runtime type validation library called Zod - you can see more at @ahejlsberg's PR at #147.

@DanielRosenwasser DanielRosenwasser added the Question Further information is requested label Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants