MrJs133 opened a new pull request, #251:
URL: https://github.com/apache/incubator-hugegraph-ai/pull/251
The 'Client' object from the ollama library was reported to not have an
'embed' attribute in some of your environments, leading to an AttributeError.
This issue can arise from mismatches between the ollama version specified in
requirements.txt and the version active in the execution environment.
This commit introduces fallback logic in the `OllamaEmbedding` class methods:
- `get_texts_embeddings`:
- Now first attempts to use `self.client.embed()`.
- If `embed` is not found, it falls back to the deprecated
`self.client.embeddings()`. Since `embeddings` typically handles single
prompts, this fallback involves iterating through the batch of texts and
calling the method for each.
- Raises an AttributeError if neither method is found.
- `get_text_embedding`:
- Similarly attempts `self.client.embed()` first. Response parsing is made
more robust by trying `response["embedding"]` and then
`response["embeddings"][0]` to handle different possible response structures
for single inputs.
- Falls back to `self.client.embeddings()` if `embed` is not found, using
`response["embedding"]`.
- Raises an AttributeError if neither method is found.
These changes aim to improve compatibility with different ollama library
versions and provide a more resilient embedding generation process.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]