Skip to content

feat: add key=value parameter parsing to OpenAI embedder#711

Merged
qin-ctx merged 2 commits intovolcengine:mainfrom
ZaynJarvis:feat/fix-openai-multi-params
Mar 18, 2026
Merged

feat: add key=value parameter parsing to OpenAI embedder#711
qin-ctx merged 2 commits intovolcengine:mainfrom
ZaynJarvis:feat/fix-openai-multi-params

Conversation

@ZaynJarvis
Copy link
Copy Markdown
Collaborator

@ZaynJarvis ZaynJarvis commented Mar 17, 2026

Clean implementation that adds support for multiple parameters in query_param and document_param using key=value format.

✅ Based on merged PR #702 - This enhancement builds on the merged is_query parameter API from main branch.

Changes

  • Add _parse_param_string() method for key=value parsing
  • Enhance _build_extra_body() to support multiple parameters with the is_query flag
  • Update docstrings and examples to show new API
  • Maintain full backward compatibility

API Integration

  • Uses is_query parameter from the embed() method signature (now merged in main)
  • Clean enhancement of existing _build_extra_body() method
  • No breaking changes - all existing usage continues to work

Usage Examples

Simple Format (Backward Compatible)

embedder = OpenAIDenseEmbedder(
    query_param='query',
    document_param='passage'
)

# Query embedding
result = embedder.embed('search text', is_query=True)
# → extra_body: {'input_type': 'query'}

# Document embedding  
result = embedder.embed('document text', is_query=False)
# → extra_body: {'input_type': 'passage'}

Enhanced Format (Multiple Parameters)

embedder = OpenAIDenseEmbedder(
    query_param='input_type=query,task=search,domain=finance',
    document_param='input_type=passage,task=index,domain=finance'
)

# Query embedding with multiple parameters
result = embedder.embed('financial query', is_query=True)
# → extra_body: {'input_type': 'query', 'task': 'search', 'domain': 'finance'}

# Document embedding with multiple parameters
result = embedder.embed('financial document', is_query=False)
# → extra_body: {'input_type': 'passage', 'task': 'index', 'domain': 'finance'}

Benefits

Testing

All functionality tested with both simple and enhanced parameter formats. Ready for review! 🚀

@ZaynJarvis
Copy link
Copy Markdown
Collaborator Author

other non-symmetric embedders usually only need the simple format. OpenAI can possibly support many different embedders, hence the update.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 17, 2026

CLA assistant check
All committers have signed the CLA.

@ZaynJarvis ZaynJarvis changed the title feat: add key=value parameter parsing to OpenAI embedder feat: add key=value parameter parsing to OpenAI embedder (builds on PR #702) Mar 17, 2026
Clean implementation on latest main (post PR volcengine#702 merge):
- Add _parse_param_string() method for key=value parsing
- Enhance _build_extra_body() to support multiple parameters
- Maintain backward compatibility with simple string format
- Update docstrings and examples

Usage:
- Simple: query_param='query' → {'input_type': 'query'}
- Enhanced: query_param='input_type=query,task=search' → {'input_type': 'query', 'task': 'search'}

Supports OpenAI-compatible servers with custom parameters while
maintaining clean integration with PR volcengine#702's is_query API.
@ZaynJarvis ZaynJarvis force-pushed the feat/fix-openai-multi-params branch from 0850f18 to 28be83d Compare March 17, 2026 16:21
@ZaynJarvis ZaynJarvis changed the title feat: add key=value parameter parsing to OpenAI embedder (builds on PR #702) feat: add key=value parameter parsing to OpenAI embedder Mar 17, 2026
@qin-ctx qin-ctx merged commit 3536531 into volcengine:main Mar 18, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants