Skip to content

Make Gemini embedding calls non-blocking in async embedder paths - #6

Merged
Harsh-Codes-77 merged 2 commits into
mainfrom
copilot/fix-code-review-comment
Jun 3, 2026
Merged

Make Gemini embedding calls non-blocking in async embedder paths#6
Harsh-Codes-77 merged 2 commits into
mainfrom
copilot/fix-code-review-comment

Conversation

Copilot AI commented May 30, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the single review comment on backend/engines/embedder.py: embed_text and embed_text_query were async functions invoking synchronous Gemini SDK calls, which could block the event loop. The change keeps behavior intact while moving the blocking SDK work off the event loop thread.

  • Scope (targeted to one review comment)

    • Updated only the embedding call sites in:
      • embed_text(...)
      • embed_text_query(...)
  • Implementation

    • Added asyncio import.
    • Replaced direct genai.embed_content(...) calls with await asyncio.to_thread(...) so embedding runs in a worker thread while preserving existing retry/fallback logic and return shape.
  • Code example

    result = await asyncio.to_thread(
        genai.embed_content,
        model=model_name,
        content=text,
        task_type="retrieval_document",  # retrieval_query in query path
    )

@vercel

vercel Bot commented May 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stock-iq Ready Ready Preview, Comment May 30, 2026 3:48am

Copilot AI changed the title [WIP] Fix code as per review comment Make Gemini embedding calls non-blocking in async embedder paths May 30, 2026
Copilot AI requested a review from Harsh-Codes-77 May 30, 2026 03:49
@Harsh-Codes-77 Harsh-Codes-77 reopened this Jun 3, 2026
@Harsh-Codes-77
Harsh-Codes-77 marked this pull request as ready for review June 3, 2026 03:25
@Harsh-Codes-77
Harsh-Codes-77 merged commit 6a8392c into main Jun 3, 2026
2 checks passed
@Harsh-Codes-77
Harsh-Codes-77 deleted the copilot/fix-code-review-comment branch June 3, 2026 18:11
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