Skip to content

Parse requests from Copilot #13

@gr2m

Description

@gr2m

Implement a method for parsing incoming requests (from Copilot).

Two reasons

  1. Getting type intellisense for the shape of the request
  2. 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,
});

Sub-issues

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions