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

Support array values for input key in request body #1

Open
blake-howell-sc opened this issue Nov 2, 2023 · 1 comment
Open

Support array values for input key in request body #1

blake-howell-sc opened this issue Nov 2, 2023 · 1 comment

Comments

@blake-howell-sc
Copy link

Lines 18 and 34 of embedding_server/server.py can be modified to support both arrays and strings

This will match the OpenAI API spec:
https://platform.openai.com/docs/api-reference/embeddings/create

@blake-howell-sc
Copy link
Author

Suggested modifications:

class EmbeddingBody(BaseModel):
    input: str | list[str] = Field(description="Your text string goes here")  # MODIFIED
    model: str | None = Field(
        default=None, title="model name. not in use", max_length=300
    )
async def root(body: EmbeddingBody, Authorization: Optional[str] = Header(None)):
    ...
    sentences = body.input if isinstance(body.input, list) else [body.input]   # MODIFIED

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

No branches or pull requests

1 participant