-
Notifications
You must be signed in to change notification settings - Fork 55
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
Force Name Parameter #66
Conversation
🦋 Changeset detectedLatest commit: bac8740 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This looks sick - do the stream results show the right ones too? |
Worth double checking. All tests pass. I think we need to figure out how to make sure we or someone else doesn't break these inferences moving forward |
Re: testing types - even though bun will run typescript it won't do any runtime typechecking - so im not sure what good ways to check might be - maybe have a test file that sets something up in a way that depends on the inference, such that if it was wrong the build would fail or something? |
How is there no way to test types other than with vitetest which doesn't support bun Feel like this would be super common for maintain a level of dx |
THIS WORKS!!! https://github.com/loreanvictor/ts-inference-check I don't get how this isn't a common use case with library authors Pretty clean too: Left an issue to make sure there is a reason to not use this... |
export function OAIBuildMessageBasedParams<T extends z.ZodTypeAny>( | ||
definition: ParseParams, | ||
params: Omit<ChatCompletionCreateParamsWithModel<T>, "response_model">, | ||
mode: MODE // This type should be typeof MODE.JSON | typeof MODE.JSON_SCHEMA | typeof MODE.MD_JSON |
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.
https://github.com/instructor-ai/instructor-js/blob/main/src/constants/modes.ts#L9
maybe i did it wrong but I thought keyof typeof gave you the equivalent union type
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.
Or maybe it's just a naming collision, Mode maybe for the type?
responseModel<T>.name
to be requiredresponse_model.name
parameter to all examples and testsz.ZodTypeAny
to force schemas to errorasync
fromchatCompletion
to remove a layer of nestedPromise
'sIs there anyway to test these cases of typechecking? @roodboi
response_model.name is undefined:
If you just have max_retires it also errors (so if you have max_retries you also need response_model but not the other way around)
Type inference still works: