-
Notifications
You must be signed in to change notification settings - Fork 39
Labels
Description
Implement a method for parsing incoming requests (from Copilot).
Two reasons
- Getting type intellisense for the shape of the request
- Removing Copilot specific keys that cause OpenAI trouble (example)
So maybe it should be two low-level methods. The high-level SDK should do the parsing implicitly and give full type intellisense. And ideally would do the payload clean up transparently as well when passing to a model API other than CAPI.
Example
// `requestBody` can be either a JSON string or an object
const input = parseRequest(requestBody);
// `input` now has full TypeIntellisense
// pass through any input properties safely to OpenAI
const inputCompat = removeCopilotKeysFromRequest(input);
const stream = openai.beta.chat.completions.stream({
messages: [systemMessage, ...input.data.messages],
model: "gpt-4-1106-preview",
stream: true,
});alexisabril