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

ML commons client generate embedding method does not work with Amazon OpenSearch service #393

Closed
mohdaliiqbal opened this issue Jun 20, 2024 · 0 comments

Comments

@mohdaliiqbal
Copy link

ML commons client generate embedding method is failing. I believe it is path issue - path should be

path = '_plugins/_ml/models/'+model_id+'/_predict'

Following is the error message that I get.

RequestError: RequestError(400, 'no handler found for uri [/_plugins/_ml/_predict/text_embedding/] and method [POST]', 'no handler found for uri [/_plugins/_ml/_predict/text_embedding/] and method [POST]')

Following is the line that is throwing exception.

https://github.com/opensearch-project/opensearch-py-ml/blob/ec7e0235d9092cb26fe3d889d8ab7fae28dccefe/opensearch_py_ml/ml_commons/ml_commons_client.py#L514C1-L515C1

      1 input_sentences = ["wine for my food"]
----> 2 embedding_output = ml_client.generate_embedding(f"{model_id}", input_sentences)
      3 embed = json.loads(embedding_output)['inference_results'][0]['output'][0]['data']
      4 print(embed[:10])

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/opensearch_py_ml/ml_commons/ml_commons_client.py:490, in MLCommonClient.generate_embedding(self, model_id, sentences)
    486 API_URL = f"{ML_BASE_URI}/_predict/text_embedding/{model_id}"
    488 API_BODY = {"text_docs": sentences, "target_response": ["sentence_embedding"]}
--> 490 return self._client.transport.perform_request(
    491     method="POST",
    492     url=API_URL,
    493     body=API_BODY,
    494 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant