diff --git a/docs/remote_inference_blueprints/cohere_connector_embedding_blueprint.md b/docs/remote_inference_blueprints/cohere_connector_embedding_blueprint.md new file mode 100644 index 0000000000..da464335ba --- /dev/null +++ b/docs/remote_inference_blueprints/cohere_connector_embedding_blueprint.md @@ -0,0 +1,81 @@ +### Cohere connector blueprint example for embedding: + +#### this blueprint is created from Cohere doc: https://docs.cohere.com/reference/embed + +```json +POST /_plugins/_ml/connectors/_create +{ + "name": "", + "description": "", + "version": "", + "protocol": "http", + "credential": { + "cohere_key": "" + }, + "actions": [ + { + "action_type": "predict", + "method": "POST", + "url": "https://api.cohere.ai/v1/embed", + "headers": { + "Authorization": "Bearer ${credential.cohere_key}" + }, + "request_body": "{ \"texts\": ${parameters.prompt}, \"truncate\": \"END\" }" + } + ] +} +``` +#### Sample response +```json +{ + "connector_id": "XU5UiokBpXT9icfOM0vt" +} +``` + + +### Corresponding Predict request example: + +```json +POST /_plugins/_ml/models//_predict +{ + "parameters": { + "prompt": ["Say this is a test"] + } +} +``` + +#### Sample response +```json +{ + "inference_results": [ + { + "output": [ + { + "name": "response", + "dataAsMap": { + "id": "39097276-d926-4ca1-92e6-d54a3c969d42", + "texts": [ + "Say this is a test" + ], + "embeddings": [ + [ + -0.76953125, + -0.12731934, + -0.52246094, + -1.2714844, + ........ + ........ + ] + ], + "meta": { + "api_version": { + "version": "1" + } + } + } + } + ] + } + ] +} +``` diff --git a/docs/remote_inference_blueprints/cohere_connector_rerank_blueprint.md b/docs/remote_inference_blueprints/cohere_connector_rerank_blueprint.md new file mode 100644 index 0000000000..8a2dd0c703 --- /dev/null +++ b/docs/remote_inference_blueprints/cohere_connector_rerank_blueprint.md @@ -0,0 +1,103 @@ +### Cohere connector blueprint example for rerank: + +#### this blueprint is created from Cohere doc: https://docs.cohere.com/reference/rerank-1 + +```json +POST /_plugins/_ml/connectors/_create +{ + "name": "", + "description": "", + "version": "", + "protocol": "http", + "parameters": { + "endpoint": "api.cohere.ai", + "model": "rerank-english-v2.0", + "top_n": 3, + "return_documents": true + }, + "credential": { + "api_key": "" + }, + "actions": [ + { + "action_type": "predict", + "method": "POST", + "url": "https://${parameters.endpoint}/v1/rerank", + "headers": { + "Authorization": "Bearer ${credential.api_key}" + }, + "request_body": "{ \"model\": \"${parameters.model}\", \"query\" : \"${parameters.query}\", \"documents\" : ${parameters.documents}, \"top_n\" : ${parameters.top_n}, \"return_documents\" : ${parameters.return_documents} }" + } + ] +} +``` +#### Sample response +```json +{ + "connector_id": "XU5UiokBpXT9icfOM0vt" +} +``` + + +### Corresponding Predict request example: + +```json +POST /_plugins/_ml/models//_predict +{ + "parameters": { + "query": "What is the capital of the United States?", + "documents": [ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + ] + } +} +``` + +#### Sample response +```json +{ + "inference_results": [ + { + "output": [ + { + "name": "response", + "dataAsMap": { + "id": "c536e12e-c7fe-414c-9a00-d1c5c6757b34", + "results": [ + { + "document": { + "text": "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district." + }, + "index": 2, + "relevance_score": 0.98005307 + }, + { + "document": { + "text": "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + }, + "index": 3, + "relevance_score": 0.27904198 + }, + { + "document": { + "text": "Carson City is the capital city of the American state of Nevada." + }, + "index": 0, + "relevance_score": 0.10194652 + } + ], + "meta": { + "api_version": { + "version": "1" + } + } + } + } + ] + } + ] +} +``` diff --git a/docs/remote_inference_blueprints/open_ai_connector_chat_blueprint.md b/docs/remote_inference_blueprints/open_ai_connector_chat_blueprint.md new file mode 100644 index 0000000000..3b9d168871 --- /dev/null +++ b/docs/remote_inference_blueprints/open_ai_connector_chat_blueprint.md @@ -0,0 +1,93 @@ +### OpenAI connector blueprint example for chat: + +#### this blueprint is created from OpenAI doc: https://platform.openai.com/docs/api-reference/chat +```json +POST /_plugins/_ml/connectors/_create +{ + "name": "", + "description": "", + "version": "", + "protocol": "http", + "parameters": { + "endpoint": "api.openai.com", + "model": "gpt-3.5-turbo" + }, + "credential": { + "openAI_key": "" + }, + "actions": [ + { + "action_type": "predict", + "method": "POST", + "url": "https://${parameters.endpoint}/v1/chat/completions", + "headers": { + "Authorization": "Bearer ${credential.openAI_key}" + }, + "request_body": "{ \"model\": \"${parameters.model}\", \"messages\": ${parameters.messages} }" + } + ] +} +``` + +#### Sample response +```json +{ + "connector_id": "XU5UiokBpXT9icfOM0vt" +} +``` + +### Corresponding Predict request example: + +```json +POST /_plugins/_ml/models//_predict +{ + "parameters": { + "messages": [ + { + "role": "system", + "content": "You are a helpful assistant." + }, + { + "role": "user", + "content": "Hello!" + } + ] + } +} +``` + +#### Sample response +```json +{ + "inference_results": [ + { + "output": [ + { + "name": "response", + "dataAsMap": { + "id": "chatcmpl-7g0QJH6nuFW94l8tDkJzxm0ntaPNd", + "object": "chat.completion", + "created": 1690245759, + "model": "gpt-3.5-turbo-0613", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "Hello! How can I assist you today?" + }, + "finish_reason": "stop" + } + ], + "usage": { + "prompt_tokens": 19, + "completion_tokens": 9, + "total_tokens": 28 + } + } + } + ] + } + ] +} +``` diff --git a/docs/remote_inference_blueprints/open_ai_connector_completion_blueprint.md b/docs/remote_inference_blueprints/open_ai_connector_completion_blueprint.md new file mode 100644 index 0000000000..6f3886fceb --- /dev/null +++ b/docs/remote_inference_blueprints/open_ai_connector_completion_blueprint.md @@ -0,0 +1,86 @@ +### OpenAI connector blueprint example for completion: + +#### this blueprint is created from OpenAI doc: https://platform.openai.com/docs/api-reference/completions + +```json +POST /_plugins/_ml/connectors/_create +{ + "name": "", + "description": "", + "version": "", + "protocol": "http", + "parameters": { + "endpoint": "api.openai.com", + "max_tokens": 7, + "temperature": 0, + "model": "text-davinci-003" + }, + "credential": { + "openAI_key": "" + }, + "actions": [ + { + "action_type": "predict", + "method": "POST", + "url": "https://${parameters.endpoint}/v1/completions", + "headers": { + "Authorization": "Bearer ${credential.openAI_key}" + }, + "request_body": "{ \"model\": \"${parameters.model}\", \"prompt\": \"${parameters.prompt}\", \"max_tokens\": ${parameters.max_tokens}, \"temperature\": ${parameters.temperature} }" + } + ] +} +``` + +#### Sample response +```json +{ + "connector_id": "XU5UiokBpXT9icfOM0vt" +} +``` + +### Corresponding Predict request example: + +```json +POST /_plugins/_ml/models//_predict +{ + "parameters": { + "prompt": ["Say this is a test"] + } +} +``` + +#### Sample response +```json +{ + "inference_results": [ + { + "output": [ + { + "name": "response", + "dataAsMap": { + "id": "cmpl-7g0NPOJd8IvXTdhecdlR0VGfrLMWE", + "object": "text_completion", + "created": 1690245579, + "model": "text-davinci-003", + "choices": [ + { + "text": """ + + This is indeed a test""", + "index": 0, + "finish_reason": "length" + } + ], + "usage": { + "prompt_tokens": 5, + "completion_tokens": 7, + "total_tokens": 12 + } + } + } + ] + } + ] +} +``` diff --git a/docs/remote_inference_blueprints/sagemaker_connector_blueprint.md b/docs/remote_inference_blueprints/sagemaker_connector_blueprint.md new file mode 100644 index 0000000000..3ba996296d --- /dev/null +++ b/docs/remote_inference_blueprints/sagemaker_connector_blueprint.md @@ -0,0 +1,39 @@ +### Sagemaker connector blueprint example for embedding: + +```json +POST /_plugins/_ml/connectors/_create +{ + "name": "", + "description": "", + "version": "", + "protocol": "aws_sigv4", + "credential": { + "access_key": "", + "secret_key": "", + "session_token": "" + }, + "parameters": { + "region": "", + "service_name": "sagemaker" + }, + "actions": [ + { + "action_type": "predict", + "method": "POST", + "headers": { + "content-type": "application/json" + }, + "url": "", + "request_body": "" + } + ] +} +``` + +#### Sample response +```json +{ + "connector_id": "XU5UiokBpXT9icfOM0vt" +} +``` +