opensearch-project / ml-commons

ml-commons provides a set of common machine learning algorithms, e.g. k-means, or linear regression, to help developers build ML related features within OpenSearch.
Apache License 2.0
99 stars 138 forks source link

[BUG] Add more validation checks for message API #3250

Open mingshl opened 15 hours ago

mingshl commented 15 hours ago

What is the bug?

In testing the message API,

We need to add validation and throw proper exceptions.

How can one reproduce the bug?

POST /_plugins/_ml/memory/
{
  "name": "Conversation for a RAG pipeline"
}

POST /_plugins/_ml/memory/-IyfjZMBQoVk1Lk93xvv/messages
{

}

GET /_plugins/_ml/memory/message/-YyljZMBQoVk1Lk99BtH

##returnning  new message -YyljZMBQoVk1Lk99BtH  with fields in null values.  
{
  "memory_id": "-IyfjZMBQoVk1Lk93xvv",
  "message_id": "-YyljZMBQoVk1Lk99BtH",
  "create_time": "2024-12-03T17:51:23.713738264Z",
  "input": null,
  "prompt_template": null,
  "response": null,
  "origin": null,
  "additional_info": {}
}

POST /_plugins/_ml/memory/-IyfjZMBQoVk1Lk93xvv/messages
{
   "message":{"role":"system","content":"Hi!"}
}

GET /_plugins/_ml/memory/message/giiijZMBjeltLmSpmHa5
##returnning message giiijZMBjeltLmSpmHa5  with fields in null values.  
{
  "memory_id": "-IyfjZMBQoVk1Lk93xvv",
  "message_id": "giiijZMBjeltLmSpmHa5",
  "create_time": "2024-12-03T17:47:43.667740682Z",
  "input": null,
  "prompt_template": null,
  "response": null,
  "origin": null,
  "additional_info": {}
}

What is the expected behavior? throw proper exception to guide users to send in valid messages.

What is your host/environment?

Do you have any screenshots? If applicable, add screenshots to help explain your problem.

Do you have any additional context? Add any other context about the problem.

rithin-pullela-aws commented 14 hours ago

@dhrubo-os, can you please assign this issue to me.