Add embeddings, models, moderations, and image generation endpoints#2
Open
beta-devin-ai-integration[bot] wants to merge 1 commit into
Open
Add embeddings, models, moderations, and image generation endpoints#2beta-devin-ai-integration[bot] wants to merge 1 commit into
beta-devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- Add createEmbedding() for POST /v1/embeddings
- Add listModels() for GET /v1/models
- Add retrieveModel() for GET /v1/models/{model}
- Add createModeration() for POST /v1/moderations
- Add createImage() for POST /v1/images/generations
- Add makeRequest() helper for GET requests
- Fix double-free bug in chat() error path
- Update README with API reference for all endpoints
Co-Authored-By: ahlback.emil+coggitgrant <me@emil.zip>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for additional OpenAI API endpoints beyond chat completions:
POST /v1/embeddings) viacreateEmbedding()GET /v1/models) vialistModels()GET /v1/models/{model}) viaretrieveModel()POST /v1/moderations) viacreateModeration()POST /v1/images/generations) viacreateImage()Also introduces a
makeRequest()internal helper for GET requests (the existingmakeCall()only supports POST with a body), fixes a double-free bug inchat(), and updates the README with an API reference section.Bugfix:
chat()had bothdefer req.deinit()and an explicitreq.deinit()on the error path, causing a double-free. The explicit call is removed sincedeferalready handles cleanup.Review & Testing Checklist for Human
ModerationCategoriesandModerationCategoryScoresare missing theillicitandillicit/violentfields that the OpenAI API now returns. Sinceignore_unknown_fields = trueis used for deserialization this won't crash, but those categories are silently dropped. Decide whether to add them (with defaults) or leave as-is.EmbeddingPayload.inputonly accepts a single string: The OpenAI embeddings API also accepts[]stringfor batch embedding. This is a functional limitation worth considering.Embedding.embedding: []f64and the moderation structs with@"slash/separated"field names.chat()error path change (removing explicitreq.deinit(), relying ondefer) is correct — thedefer req.deinit()on line 352 already covers cleanup.Notes
makeRequestandmakeCallshare duplicated URI/header construction logic. Could be refactored but kept separate to match the existing code style.build.zig.zonformat changes that are out of scope.Link to Devin session: https://app.beta.devin.ai/sessions/6adf11eb1dc24b5692382ef0591ea15a
Requested by: @FOLLGAD