Skip to content

feat: passthrough oai embed response without opening body#1053

Merged
VisargD merged 3 commits into
mainfrom
feat/passthough-oai-embed-without-opening-body
Apr 23, 2025
Merged

feat: passthrough oai embed response without opening body#1053
VisargD merged 3 commits into
mainfrom
feat/passthough-oai-embed-without-opening-body

Conversation

@VisargD
Copy link
Copy Markdown
Collaborator

@VisargD VisargD commented Apr 22, 2025

Code Quality type: new feature

Author Description

(optional)

  • Detailed change 1
  • Detailed change 2

Description

🔄 What Changed

This PR implements a performance optimization for OpenAI embedding responses by avoiding unnecessary JSON parsing when no synchronous hooks are present. The code now checks for the presence of sync hooks and only parses the response body when needed, otherwise passing through the response directly.

🔍 Impact of the Change

This change improves performance for embedding API calls by reducing unnecessary JSON parsing operations, particularly beneficial for high-volume embedding requests.

📁 Total Files Changed

5 files modified with 42 additions and 13 deletions.

🧪 Test Added

N/A - No explicit tests were added in this PR.

🔒 Security Vulnerabilities

No security vulnerabilities were introduced.

Motivation

To improve performance by avoiding unnecessary JSON parsing operations for OpenAI embedding responses when no synchronous hooks are active.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing

Screenshots (if applicable)

N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

N/A

Quality Recommendations

  1. Add unit tests to verify the new passthrough behavior works correctly

  2. Add error handling for the case where JSON parsing fails but is required

  3. Add documentation comments explaining the purpose of the areSyncHooksAvailable flag

  4. Consider adding logging to track when responses are passed through vs parsed

@VisargD VisargD marked this pull request as ready for review April 22, 2025 17:00
@VisargD VisargD requested a review from narengogi April 22, 2025 17:04
@VisargD VisargD merged commit 0a34704 into main Apr 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants