You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "MrJs133 (via GitHub)" <gi...@apache.org> on 2025/05/23 03:11:56 UTC

[PR] fix(llm): Handle AttributeError for ollama client 'embed' method [incubator-hugegraph-ai]

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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(llm): Handle AttributeError for ollama client 'embed' method [incubator-hugegraph-ai]

Posted by "MrJs133 (via GitHub)" <gi...@apache.org>.
MrJs133 closed pull request #251: fix(llm): Handle AttributeError for ollama client 'embed' method
URL: https://github.com/apache/incubator-hugegraph-ai/pull/251


-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org