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

Add ML Controller APIs #779

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `POST /_plugins/_ml/memory`, `POST /_plugins/_ml/memory/_search`, `{memory_id}/_search`, `{memory_id}/messages`, `PUT /_plugins/_ml/memory/{memory_id}`, `message/{message_id}`, `GET /_plugins/_ml/memory`, `GET /_plugins/_ml/memory/{memory_id}`, `_search`, `message/{message_id}`, `{memory_id}/messages`, `{memory_id}/_search`, `message/{message_id}/traces`, and `DELETE /_plugins/_ml/memory/{memory_id}` ([#771](https://github.com/opensearch-project/opensearch-api-specification/pull/771))
- Added support for evaluating response payloads in prologues and epilogues ([#772](https://github.com/opensearch-project/opensearch-api-specification/pull/772))
- Added `GET /_plugins/_ml/models/{model_id}`, `POST /_plugins/_ml/models/_search`, `POST /_plugins/_ml/models/_unload`, `_undeploy`, `_upload`, `meta`, `_register_meta`, `POST /_plugins/_ml/models/{model_id}/_load`, `_predict`, `_unload`, `chunk/{chunk_number}`, `upload_chunk/{chunk_number}`, and `PUT /_plugins/_ml/models/{model_id}` ([#733](https://github.com/opensearch-project/opensearch-api-specification/pull/733))
- Added `GET`, `POST`, `PUT`, `DELETE /_plugins/_ml/controllers/{model_id}` ([#779](https://github.com/opensearch-project/opensearch-api-specification/pull/779))

### Removed
- Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,335 @@
[INFO] Authenticating with admin ...
[INFO] Connecting to https://localhost:9200 ... (1/20)
[INFO] Evaluating ml/agents.yaml ...
[INFO] => POST /_plugins/_ml/agents/_register ({}) [application/json] {
"name": "Test_Agent_For_RAG",
"type": "flow",
"description": "this is a test agent",
"tools": [
{
"type": "VectorDBTool",
"parameters": {
"model_id": "YOUR_TEXT_EMBEDDING_MODEL_ID",
"index": "my_test_data",
"embedding_field": "embedding",
"source_field": [
"text"
],
"input": "test_question"
}
},
{
"type": "MLModelTool",
"description": "A general tool to answer any question",
"parameters": {
"model_id": "YOUR_LLM_MODEL_ID"
}
}
]
}
[INFO] <= 200 (application/json; charset=UTF-8) | {
"agent_id": "KejBUZQBaqMO3uIYKp67"
}
[INFO] $ {
"outputs": {
"test_agent_id": "KejBUZQBaqMO3uIYKp67"
}
}
[INFO] => DELETE /_plugins/_ml/agents/KejBUZQBaqMO3uIYKp67 ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"_index": ".plugins-ml-agent",
"_id": "KejBUZQBaqMO3uIYKp67",
"_version": 2,
"result": "deleted",
"forced_refresh": true,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 19,
"_primary_term": 6
}
[INFO] => DELETE /_plugins/_ml/agents/KejBUZQBaqMO3uIYKp67 ({}) [application/json]
[INFO] <= 404 (application/json) | {
"error": {
"root_cause": [
{
"type": "status_exception",
"reason": "Failed to find agent with the provided agent id: KejBUZQBaqMO3uIYKp67"
}
],
"type": "status_exception",
"reason": "Failed to find agent with the provided agent id: KejBUZQBaqMO3uIYKp67"
},
"status": 404
}
[INFO] Evaluating ml/connectors.yaml ...
[INFO] => POST /_plugins/_ml/connectors/_create ({}) [application/json] {
"name": "OpenAI Chat Connector",
"description": "The connector to public OpenAI model service for GPT 3.5",
"version": 1,
"protocol": "http",
"parameters": {
"endpoint": "api.openai.com",
"model": "gpt-3.5-turbo"
},
"credential": {
"openAI_key": "test_api_key"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"headers": {
"Authorization": "Bearer Key"
},
"request_body": "{ \"model\": \"model\", \"messages\": \"messages\" }"
}
]
}
[INFO] <= 200 (application/json; charset=UTF-8) | {
"connector_id": "KujBUZQBaqMO3uIYK57K"
}
[INFO] $ {
"outputs": {
"test_connector_id": "KujBUZQBaqMO3uIYK57K"
}
}
[INFO] => GET /_plugins/_ml/connectors/KujBUZQBaqMO3uIYK57K ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"name": "OpenAI Chat Connector",
"version": "1",
"description": "The connector to public OpenAI model service for GPT 3.5",
"protocol": "http",
"parameters": {
"endpoint": "api.openai.com",
"model": "gpt-3.5-turbo"
},
"actions": [
{
"action_type": "PREDICT",
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"headers": {
"Authorization": "Bearer Key"
},
"request_body": "{ \"model\": \"model\", \"messages\": \"messages\" }"
}
],
"created_time": 1736538401737,
"last_updated_time": 1736538401737
}
[INFO] => DELETE /_plugins/_ml/connectors/KujBUZQBaqMO3uIYK57K ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"_index": ".plugins-ml-connector",
"_id": "KujBUZQBaqMO3uIYK57K",
"_version": 2,
"result": "deleted",
"forced_refresh": true,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 40,
"_primary_term": 6
}
[INFO] => DELETE /_plugins/_ml/connectors/KujBUZQBaqMO3uIYK57K ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"_index": ".plugins-ml-connector",
"_id": "KujBUZQBaqMO3uIYK57K",
"_version": 3,
"result": "not_found",
"forced_refresh": true,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 41,
"_primary_term": 6
}
[INFO] Evaluating ml/model_groups.yaml ...
[INFO] => POST /_plugins/_ml/model_groups/_register ({}) [application/json] {
"name": "NLP_Group",
"description": "Model group for NLP models."
}
[INFO] <= 200 (application/json; charset=UTF-8) | {
"model_group_id": "K-jBUZQBaqMO3uIYLJ5u",
"status": "CREATED"
}
[INFO] $ {
"outputs": {
"test_model_group_id": "K-jBUZQBaqMO3uIYLJ5u"
}
}
[INFO] => GET /_plugins/_ml/model_groups/K-jBUZQBaqMO3uIYLJ5u ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"name": "NLP_Group",
"latest_version": 0,
"description": "Model group for NLP models.",
"owner": {
"name": "admin",
"backend_roles": [
"admin"
],
"roles": [
"own_index",
"all_access"
],
"custom_attribute_names": [],
"user_requested_tenant": null
},
"access": "private",
"created_time": 1736538401901,
"last_updated_time": 1736538401901
}
[INFO] => DELETE /_plugins/_ml/model_groups/K-jBUZQBaqMO3uIYLJ5u ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"_index": ".plugins-ml-model-group",
"_id": "K-jBUZQBaqMO3uIYLJ5u",
"_version": 2,
"result": "deleted",
"forced_refresh": true,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 236,
"_primary_term": 6
}
[INFO] => DELETE /_plugins/_ml/model_groups/K-jBUZQBaqMO3uIYLJ5u ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"_index": ".plugins-ml-model-group",
"_id": "K-jBUZQBaqMO3uIYLJ5u",
"_version": 3,
"result": "not_found",
"forced_refresh": true,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 237,
"_primary_term": 6
}
[INFO] Evaluating ml/models.yaml ...
[INFO] => POST /_plugins/_ml/models/_register ({}) [application/json] {
"name": "huggingface/sentence-transformers/msmarco-distilbert-base-tas-b",
"version": "1.0.1",
"model_format": "TORCH_SCRIPT"
}
[INFO] <= 200 (application/json; charset=UTF-8) | {
"task_id": "LOjBUZQBaqMO3uIYLJ6y",
"status": "CREATED"
}
[INFO] $ {
"outputs": {
"task_id": "LOjBUZQBaqMO3uIYLJ6y"
}
}
[INFO] => GET /_plugins/_ml/tasks/LOjBUZQBaqMO3uIYLJ6y ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"task_type": "REGISTER_MODEL",
"function_name": "TEXT_EMBEDDING",
"state": "CREATED",
"worker_node": [
"ZcCsgpwPQsOq347BXU79jQ"
],
"create_time": 1736538401970,
"last_update_time": 1736538401970,
"is_async": true
}
[INFO] {
"task_type": "REGISTER_MODEL",
"function_name": "TEXT_EMBEDDING",
"state": "CREATED",
"worker_node": [
"ZcCsgpwPQsOq347BXU79jQ"
],
"create_time": 1736538401970,
"last_update_time": 1736538401970,
"is_async": true
}
[INFO] Failed, retrying, 5 retries left ...
[INFO] => GET /_plugins/_ml/tasks/LOjBUZQBaqMO3uIYLJ6y ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"task_type": "REGISTER_MODEL",
"function_name": "TEXT_EMBEDDING",
"state": "FAILED",
"worker_node": [
"ZcCsgpwPQsOq347BXU79jQ"
],
"create_time": 1736538401970,
"last_update_time": 1736538407919,
"error": "/usr/share/opensearch/data/ml_cache/models_cache/register/slnBUZQBdUaAr33ZL44-/57/huggingface/sentence-transformers/msmarco-distilbert-base-tas-b.zip",
"is_async": true
}
[INFO] {
"task_type": "REGISTER_MODEL",
"function_name": "TEXT_EMBEDDING",
"state": "FAILED",
"worker_node": [
"ZcCsgpwPQsOq347BXU79jQ"
],
"create_time": 1736538401970,
"last_update_time": 1736538407919,
"error": "/usr/share/opensearch/data/ml_cache/models_cache/register/slnBUZQBdUaAr33ZL44-/57/huggingface/sentence-transformers/msmarco-distilbert-base-tas-b.zip",
"is_async": true
}
[INFO] Failed, retrying, 4 retries left ...
[INFO] => GET /_plugins/_ml/tasks/LOjBUZQBaqMO3uIYLJ6y ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"task_type": "REGISTER_MODEL",
"function_name": "TEXT_EMBEDDING",
"state": "FAILED",
"worker_node": [
"ZcCsgpwPQsOq347BXU79jQ"
],
"create_time": 1736538401970,
"last_update_time": 1736538407919,
"error": "/usr/share/opensearch/data/ml_cache/models_cache/register/slnBUZQBdUaAr33ZL44-/57/huggingface/sentence-transformers/msmarco-distilbert-base-tas-b.zip",
"is_async": true
}
[INFO] {
"task_type": "REGISTER_MODEL",
"function_name": "TEXT_EMBEDDING",
"state": "FAILED",
"worker_node": [
"ZcCsgpwPQsOq347BXU79jQ"
],
"create_time": 1736538401970,
"last_update_time": 1736538407919,
"error": "/usr/share/opensearch/data/ml_cache/models_cache/register/slnBUZQBdUaAr33ZL44-/57/huggingface/sentence-transformers/msmarco-distilbert-base-tas-b.zip",
"is_async": true
}
[INFO] Failed, retrying, 3 retries left ...
[INFO] => GET /_plugins/_ml/tasks/LOjBUZQBaqMO3uIYLJ6y ({}) [application/json]
[INFO] <= 200 (application/json; charset=UTF-8) | {
"task_type": "REGISTER_MODEL",
"function_name": "TEXT_EMBEDDING",
"state": "FAILED",
"worker_node": [
"ZcCsgpwPQsOq347BXU79jQ"
],
"create_time": 1736538401970,
"last_update_time": 1736538407919,
"error": "/usr/share/opensearch/data/ml_cache/models_cache/register/slnBUZQBdUaAr33ZL44-/57/huggingface/sentence-transformers/msmarco-distilbert-base-tas-b.zip",
"is_async": true
}
[INFO] {
"task_type": "REGISTER_MODEL",
"function_name": "TEXT_EMBEDDING",
"state": "FAILED",
"worker_node": [
"ZcCsgpwPQsOq347BXU79jQ"
],
"create_time": 1736538401970,
"last_update_time": 1736538407919,
"error": "/usr/share/opensearch/data/ml_cache/models_cache/register/slnBUZQBdUaAr33ZL44-/57/huggingface/sentence-transformers/msmarco-distilbert-base-tas-b.zip",
"is_async": true
}
[INFO] Failed, retrying, 2 retries left ...
Loading
Loading