Skip to content
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

Parse requests from Copilot #13

Closed
gr2m opened this issue Aug 29, 2024 · 4 comments · Fixed by #34
Closed

Parse requests from Copilot #13

gr2m opened this issue Aug 29, 2024 · 4 comments · Fixed by #34
Assignees
Labels
feature New feature or request released

Comments

@gr2m
Copy link
Collaborator

gr2m commented Aug 29, 2024

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,
});
@gr2m gr2m added the feature New feature or request label Aug 29, 2024
@alexisabril
Copy link

I'm definitely in favor of the ability to type an incoming request shape. I'm agnostic, but not opposed, to the removeCopilotKeysFromRequest method as we may continue to add properties to the incoming request object. As a result, this method may need to have a higher level of upkeep and may be considered coupled (a bit) to OpenAI. For instance, Anthropic may consider the entire shape to be invalid, rendering this translation method moot.

verifyAndParse having a potential avenue across other APIs brings value to replicating this pattern here. For me personally, I'm a fan of two separate methods that can be composed:

verify(parse)(req)

The only thought to keeping the separate I have is if the consumer chooses an architecture where verification happens earlier and separately from any additional request handling.

@gr2m
Copy link
Collaborator Author

gr2m commented Aug 29, 2024

good point on making removeCopilotKeysFromRequest specific to OpenAI, I think we should do that.

@gr2m gr2m changed the title Add method to parse requests from Copilot Parse requests from Copilot Aug 29, 2024
@gr2m gr2m self-assigned this Aug 29, 2024
@gr2m
Copy link
Collaborator Author

gr2m commented Sep 1, 2024

I added one more issue

I'm sure a similar function would be useful for function calling, but I get there when I get there. I need to experiment more with

Copy link

github-actions bot commented Sep 1, 2024

🎉 This issue has been resolved in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request released
Projects
None yet
2 participants