-
Notifications
You must be signed in to change notification settings - Fork 392
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
Add "TypeChat in 5 Minutes" doc #65
Conversation
|
||
## Providing a Model | ||
|
||
TypeChat is mostly model agnostic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "mostly" mean here?
``` | ||
|
||
A translator takes a model, the schema file contents, and the name of the type within the schema file. | ||
That type name effectively acts as the "entry-point" of our schema for the language model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth being explicit that your schema can (obviously) contain multiple types, but you must specify the "entry" type.
Looking forward to this PR |
Thank you @DanielRosenwasser for offering this handy guide on using TypeChat. I was very excited when I first learnt about TypeChat and quickly went through the examples to integrate it with my existing code. During the process, I encountered some challenges when using TypeChat within an ESM module. I'd like to share my findings, as they might be helpful in preventing difficulties for others. I tried to load the schema file but noticed that you cannot simply target it with // Load up the schema file contents.
const schema = fs.readFileSync(path.join(__dirname, "sentimentSchema.ts"), "utf8"); After executing the code, I got the following error:
I was able to solve this problem by mimicking the behavior of import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const texts = path.join(__dirname, 'texts.txt');
const schemaFile = path.join(__dirname, 'sentimentSchema.ts');
// Load up the schema file contents.
const schema = fs.readFileSync(schemaFile, 'utf8'); I encountered another issue when trying to import the schema using the following method: // Load up the type from our schema.
import type { SentimentResponse } from "./sentimentSchema"; I received a
After doing some research, I found that file extensions are mandatory when using ES Modules to resolve relative specifiers. Since // Load up the type from our schema.
import type { SentimentResponse } from "./sentimentSchema.js"; The rest of the description worked perfectly, and I'm very happy about what you and the team are creating here. I'm so happy that I even created a TypeChat video tutorial, and it's not longer than 5 minutes. So, "TypeChat in 5 Minutes" is a reality! 😊 Great job! 👍 Sending my best wishes from Berlin! |
Thanks @bennycode, this is great feedback - I hadn't yet gotten the chance to work on ESM examples, and I knew that there would be some rough patches with |
I read through the entire doc and learned a lot! Can/will this PR be completed? |
32bcd97
to
c114f65
Compare
I'm not sure if this is the appropriate title - but I think this sort of doc would be helpful for users who are looking for a breakdown of our sentiment example.
Some TODOs: