-
Notifications
You must be signed in to change notification settings - Fork 39
Clarify LanguageModelResponseSchema interface #102
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
Comments
The main intention here is to centralize the preprocessing of the schema up front. If I understand correctly, this includes both validation (which you mention), but also transforming the schema from a JS object into something more native to the language model's representation. @sushraja-msft can give more details. In other words, my understanding is that this: function getBooleanFromSession(session, question) {
return session.prompt(question, { responseJSONSchema: { type: "boolean" } });
} will be slightly slower than this: const booleanSchema = new LanguageModelResponseSchema({ type: "boolean" });
function getBooleanFromSession(session, question) {
return session.prompt(question, { responseJSONSchema: booleanSchema });
} because the first version requires processing the schema object into something suitable for the language model, whereas the latter version does that once and then reuses the result each time. With regards to other schema formats, #91 discusses how that would impact the API. I think we would not use |
In my testing creating the schema object takes something like 1-5ms, so may not be worth having an API around to avoid this cost (on the impl side we can also do things like LRU cache for schemas that should catch this case anyway). I tend to think we may want to get rid of LanguageModelResponseSchema altogether, and just pass the schema as a raw JS object. We can always add LanguageModelResponseSchema later if needed right? |
Yeah, I'm supportive of that. Since it sounds like that's what our colleagues at Microsoft have implemented so far anyway, I'll post a PR to get rid of it shortly, unless @sushraja-msft or others have objections. |
Closes #102. As discussed there, it probably isn't necessary, the naming is potentially confusing, and it can be added back later if we want it.
Closes #102. As discussed there, it probably isn't necessary, the naming is potentially confusing, and it can be added back later if we want it.
I'm confused about the utility and use of the
LanguageModelResponseSchema
interface.Can the explainer add some clarity about this interface?
prompt
). How will callers verify their schema is valid? Does the LanguageModelResponseSchema ctor throw an exception, or should it have some validation method or validity property?The text was updated successfully, but these errors were encountered: