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

Embedding API endpoint not working with langchain or OpenAI as mentioned on the EPAM DIAL API Docs #405

Open
YuryZhylko opened this issue Jul 25, 2024 · 2 comments

Comments

@YuryZhylko
Copy link

When using the code snippets for langchain and OpenAI described in the API docs here: https://epam-rail.com/dial_api#/paths/~1openai~1deployments~1%7BDeployment%20Name%7D~1embeddings/post, the code fails to execute and we get 2 distinct errors.
For langchain, it throws a 500 internal server error.

Unable to find source-code formatter for language: bash. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yamlInternalServerError: Error code: 500 - {'error': {'message': '2 validation errors for EmbeddingsRequest\ninput\n str type expected (type=type_error.str)\ninput -> 0\n str type expected (type=type_error.str)', 'type': 'internal_server_error'}}

For OpenAI, it throws 422 error.

Unable to find source-code formatter for language: bash. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yamlUnprocessableEntityError: Error code: 422 - {'error': {'message': 'Base64 encoding format is not supported', 'type': 'invalid_request_error', 'code': 'invalid_argument'}}

The code does not work with semantic-router library as well. https://github.com/aurelio-labs/semantic-router
It is important for the embeddings feature to work with 3rd party packages for adoption of GSL during development. If needed, break down the bug story into 3 tasks.
If there are other packages the teams are using and they run into issues, similar bug stories will be raised.

Test the embedding API endpoint with different adapters to ensure it works and if possible, create a cookbook similar to the foundational models cookbook present here: https://docs.epam-rail.com/Cookbook/dial-cookbook/examples/how_to_call_text_to_text_applications/

@sdryapko
Copy link

sdryapko commented Jul 26, 2024

Fix is in this pool request and waiting for final review which is going to happen today most probably: epam/ai-dial-adapter-bedrock#127

And we have workaround for this issue so you may not wait for this pull request:

You can update your langchain_openai to version >=0.1.5 and call embeddings this way:

model = AzureOpenAIEmbeddings(
    openai_api_version="2023-12-01-preview",
    azure_deployment="text-embedding-ada-002",
    azure_endpoint="https://chat.<company>.com",
    api_key="DIAL_API_KEY",
+   check_embedding_ctx_length=False,
+   model_kwargs={"encoding_format": "float"}
)

2/ For OpenAI, it throws 422 error.

and for this issue you can work with this example

client = AzureOpenAI(
    api_version="2023-12-01-preview",
    azure_endpoint="https://chat.<company>.com",
    api_key="DIAL_API_KEY",
+   encoding_format="float"
)

@sdryapko
Copy link

Please note that this workarounds started to work from latest release. bedrock adapter >= 0.13.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants