forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
[DOCS] Adds cohere service example to the inference API tutorial (ela…
…stic#105904) Co-authored-by: Jonathan Buttner <[email protected]>
1 parent
787fae9
commit ec7da7a
Showing
13 changed files
with
654 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
docs/reference/tab-widgets/inference-api/infer-api-ingest-pipeline-widget.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
++++ | ||
<div class="tabs" data-tab-group="model"> | ||
<div role="tablist" aria-label="model"> | ||
<button role="tab" | ||
aria-selected="true" | ||
aria-controls="infer-api-ingest-cohere-tab" | ||
id="infer-api-ingest-cohere"> | ||
Cohere | ||
</button> | ||
<button role="tab" | ||
aria-selected="false" | ||
aria-controls="infer-api-ingest-openai-tab" | ||
id="infer-api-ingest-openai"> | ||
OpenAI | ||
</button> | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-ingest-cohere-tab" | ||
aria-labelledby="infer-api-ingest-cohere"> | ||
++++ | ||
|
||
include::infer-api-ingest-pipeline.asciidoc[tag=cohere] | ||
|
||
++++ | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-ingest-openai-tab" | ||
aria-labelledby="infer-api-ingest-openai" | ||
hidden=""> | ||
++++ | ||
|
||
include::infer-api-ingest-pipeline.asciidoc[tag=openai] | ||
|
||
++++ | ||
</div> | ||
</div> | ||
++++ |
63 changes: 63 additions & 0 deletions
63
docs/reference/tab-widgets/inference-api/infer-api-ingest-pipeline.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//// | ||
|
||
[source,console] | ||
---- | ||
DELETE _ingest/pipeline/*_embeddings | ||
---- | ||
// TEST | ||
// TEARDOWN | ||
|
||
//// | ||
|
||
// tag::cohere[] | ||
|
||
[source,console] | ||
-------------------------------------------------- | ||
PUT _ingest/pipeline/cohere_embeddings | ||
{ | ||
"processors": [ | ||
{ | ||
"inference": { | ||
"model_id": "cohere_embeddings", <1> | ||
"input_output": { <2> | ||
"input_field": "content", | ||
"output_field": "content_embedding" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
-------------------------------------------------- | ||
<1> The name of the inference configuration you created by using the | ||
<<put-inference-api>>. | ||
<2> Configuration object that defines the `input_field` for the {infer} process | ||
and the `output_field` that will contain the {infer} results. | ||
|
||
// end::cohere[] | ||
|
||
|
||
// tag::openai[] | ||
|
||
[source,console] | ||
-------------------------------------------------- | ||
PUT _ingest/pipeline/openai_embeddings | ||
{ | ||
"processors": [ | ||
{ | ||
"inference": { | ||
"model_id": "openai_embeddings", <1> | ||
"input_output": { <2> | ||
"input_field": "content", | ||
"output_field": "content_embedding" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
-------------------------------------------------- | ||
<1> The name of the inference configuration you created by using the | ||
<<put-inference-api>>. | ||
<2> Configuration object that defines the `input_field` for the {infer} process | ||
and the `output_field` that will contain the {infer} results. | ||
|
||
// end::openai[] |
39 changes: 39 additions & 0 deletions
39
docs/reference/tab-widgets/inference-api/infer-api-mapping-widget.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
++++ | ||
<div class="tabs" data-tab-group="model"> | ||
<div role="tablist" aria-label="model"> | ||
<button role="tab" | ||
aria-selected="true" | ||
aria-controls="infer-api-mapping-cohere-tab" | ||
id="infer-api-mapping-cohere"> | ||
Cohere | ||
</button> | ||
<button role="tab" | ||
aria-selected="false" | ||
aria-controls="infer-api-mapping-openai-tab" | ||
id="infer-api-mapping-openai"> | ||
OpenAI | ||
</button> | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-mapping-cohere-tab" | ||
aria-labelledby="infer-api-mapping-cohere"> | ||
++++ | ||
|
||
include::infer-api-mapping.asciidoc[tag=cohere] | ||
|
||
++++ | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-mapping-openai-tab" | ||
aria-labelledby="infer-api-mapping-openai" | ||
hidden=""> | ||
++++ | ||
|
||
include::infer-api-mapping.asciidoc[tag=openai] | ||
|
||
++++ | ||
</div> | ||
</div> | ||
++++ |
71 changes: 71 additions & 0 deletions
71
docs/reference/tab-widgets/inference-api/infer-api-mapping.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// tag::cohere[] | ||
|
||
[source,console] | ||
-------------------------------------------------- | ||
PUT cohere-embeddings | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"content_embedding": { <1> | ||
"type": "dense_vector", <2> | ||
"dims": 384, <3> | ||
"element_type": "float" | ||
}, | ||
"content": { <4> | ||
"type": "text" <5> | ||
} | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
<1> The name of the field to contain the generated tokens. It must be refrenced | ||
in the {infer} pipeline configuration in the next step. | ||
<2> The field to contain the tokens is a `dense_vector` field. | ||
<3> The output dimensions of the model. Find this value in the | ||
https://docs.cohere.com/reference/embed[Cohere documentation] of the model you | ||
use. | ||
<4> The name of the field from which to create the dense vector representation. | ||
In this example, the name of the field is `content`. It must be referenced in | ||
the {infer} pipeline configuration in the next step. | ||
<5> The field type which is text in this example. | ||
|
||
// end::cohere[] | ||
|
||
|
||
// tag::openai[] | ||
|
||
[source,console] | ||
-------------------------------------------------- | ||
PUT openai-embeddings | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"content_embedding": { <1> | ||
"type": "dense_vector", <2> | ||
"dims": 1536, <3> | ||
"element_type": "float", | ||
"similarity": "dot_product" <4> | ||
}, | ||
"content": { <5> | ||
"type": "text" <6> | ||
} | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
<1> The name of the field to contain the generated tokens. It must be refrenced | ||
in the {infer} pipeline configuration in the next step. | ||
<2> The field to contain the tokens is a `dense_vector` field. | ||
<3> The output dimensions of the model. Find this value in the | ||
https://platform.openai.com/docs/guides/embeddings/embedding-models[OpenAI documentation] | ||
of the model you use. | ||
<4> The faster` dot_product` function can be used to calculate similarity | ||
because OpenAI embeddings are normalised to unit length. You can check the | ||
https://platform.openai.com/docs/guides/embeddings/which-distance-function-should-i-use[OpenAI docs] | ||
about which similarity function to use. | ||
<5> The name of the field from which to create the dense vector representation. | ||
In this example, the name of the field is `content`. It must be referenced in | ||
the {infer} pipeline configuration in the next step. | ||
<6> The field type which is text in this example. | ||
|
||
// end::openai[] |
39 changes: 39 additions & 0 deletions
39
docs/reference/tab-widgets/inference-api/infer-api-reindex-widget.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
++++ | ||
<div class="tabs" data-tab-group="model"> | ||
<div role="tablist" aria-label="model"> | ||
<button role="tab" | ||
aria-selected="true" | ||
aria-controls="infer-api-reindex-cohere-tab" | ||
id="infer-api-reindex-cohere"> | ||
Cohere | ||
</button> | ||
<button role="tab" | ||
aria-selected="false" | ||
aria-controls="infer-api-reindex-openai-tab" | ||
id="infer-api-reindex-openai"> | ||
OpenAI | ||
</button> | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-reindex-cohere-tab" | ||
aria-labelledby="infer-api-reindex-cohere"> | ||
++++ | ||
|
||
include::infer-api-reindex.asciidoc[tag=cohere] | ||
|
||
++++ | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-reindex-openai-tab" | ||
aria-labelledby="infer-api-reindex-openai" | ||
hidden=""> | ||
++++ | ||
|
||
include::infer-api-reindex.asciidoc[tag=openai] | ||
|
||
++++ | ||
</div> | ||
</div> | ||
++++ |
55 changes: 55 additions & 0 deletions
55
docs/reference/tab-widgets/inference-api/infer-api-reindex.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// tag::cohere[] | ||
|
||
[source,console] | ||
---- | ||
POST _reindex?wait_for_completion=false | ||
{ | ||
"source": { | ||
"index": "test-data", | ||
"size": 50 <1> | ||
}, | ||
"dest": { | ||
"index": "cohere-embeddings", | ||
"pipeline": "cohere_embeddings" | ||
} | ||
} | ||
---- | ||
// TEST[skip:TBD] | ||
<1> The default batch size for reindexing is 1000. Reducing `size` to a smaller | ||
number makes the update of the reindexing process quicker which enables you to | ||
follow the progress closely and detect errors early. | ||
|
||
NOTE: The | ||
https://dashboard.cohere.com/billing[rate limit of your Cohere account] | ||
may affect the throughput of the reindexing process. | ||
|
||
// end::cohere[] | ||
|
||
|
||
// tag::openai[] | ||
|
||
[source,console] | ||
---- | ||
POST _reindex?wait_for_completion=false | ||
{ | ||
"source": { | ||
"index": "test-data", | ||
"size": 50 <1> | ||
}, | ||
"dest": { | ||
"index": "openai-embeddings", | ||
"pipeline": "openai_embeddings" | ||
} | ||
} | ||
---- | ||
// TEST[skip:TBD] | ||
<1> The default batch size for reindexing is 1000. Reducing `size` to a smaller | ||
number makes the update of the reindexing process quicker which enables you to | ||
follow the progress closely and detect errors early. | ||
|
||
NOTE: The | ||
https://platform.openai.com/account/limits[rate limit of your OpenAI account] | ||
may affect the throughput of the reindexing process. If this happens, change | ||
`size` to `3` or a similar value in magnitude. | ||
|
||
// end::openai[] |
39 changes: 39 additions & 0 deletions
39
docs/reference/tab-widgets/inference-api/infer-api-requirements-widget.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
++++ | ||
<div class="tabs" data-tab-group="model"> | ||
<div role="tablist" aria-label="model"> | ||
<button role="tab" | ||
aria-selected="true" | ||
aria-controls="infer-api-requirements-cohere-tab" | ||
id="infer-api-requirements-cohere"> | ||
Cohere | ||
</button> | ||
<button role="tab" | ||
aria-selected="false" | ||
aria-controls="infer-api-requirements-openai-tab" | ||
id="infer-api-requirements-openai"> | ||
OpenAI | ||
</button> | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-requirements-cohere-tab" | ||
aria-labelledby="infer-api-requirements-cohere"> | ||
++++ | ||
|
||
include::infer-api-requirements.asciidoc[tag=cohere] | ||
|
||
++++ | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-requirements-openai-tab" | ||
aria-labelledby="infer-api-requirements-openai" | ||
hidden=""> | ||
++++ | ||
|
||
include::infer-api-requirements.asciidoc[tag=openai] | ||
|
||
++++ | ||
</div> | ||
</div> | ||
++++ |
14 changes: 14 additions & 0 deletions
14
docs/reference/tab-widgets/inference-api/infer-api-requirements.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// tag::cohere[] | ||
|
||
A https://cohere.com/[Cohere account] is required to use the {infer} API with | ||
the Cohere service. | ||
|
||
// end::cohere[] | ||
|
||
|
||
// tag::openai[] | ||
|
||
An https://openai.com/[OpenAI account] is required to use the {infer} API with | ||
the OpenAI service. | ||
|
||
// end::openai[] |
39 changes: 39 additions & 0 deletions
39
docs/reference/tab-widgets/inference-api/infer-api-search-widget.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
++++ | ||
<div class="tabs" data-tab-group="model"> | ||
<div role="tablist" aria-label="model"> | ||
<button role="tab" | ||
aria-selected="true" | ||
aria-controls="infer-api-search-cohere-tab" | ||
id="infer-api-search-cohere"> | ||
Cohere | ||
</button> | ||
<button role="tab" | ||
aria-selected="false" | ||
aria-controls="infer-api-search-openai-tab" | ||
id="infer-api-search-openai"> | ||
OpenAI | ||
</button> | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-search-cohere-tab" | ||
aria-labelledby="infer-api-search-cohere"> | ||
++++ | ||
|
||
include::infer-api-search.asciidoc[tag=cohere] | ||
|
||
++++ | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-search-openai-tab" | ||
aria-labelledby="infer-api-search-openai" | ||
hidden=""> | ||
++++ | ||
|
||
include::infer-api-search.asciidoc[tag=openai] | ||
|
||
++++ | ||
</div> | ||
</div> | ||
++++ |
139 changes: 139 additions & 0 deletions
139
docs/reference/tab-widgets/inference-api/infer-api-search.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// tag::cohere[] | ||
|
||
[source,console] | ||
-------------------------------------------------- | ||
GET cohere-embeddings/_search | ||
{ | ||
"knn": { | ||
"field": "content_embedding", | ||
"query_vector_builder": { | ||
"text_embedding": { | ||
"model_id": "cohere_embeddings", | ||
"model_text": "Calculate fuel cost" | ||
} | ||
}, | ||
"k": 10, | ||
"num_candidates": 100 | ||
}, | ||
"_source": [ | ||
"id", | ||
"content" | ||
] | ||
} | ||
-------------------------------------------------- | ||
// TEST[skip:TBD] | ||
|
||
As a result, you receive the top 10 documents that are closest in meaning to the | ||
query from the `cohere-embeddings` index sorted by their proximity to the query: | ||
|
||
[source,consol-result] | ||
-------------------------------------------------- | ||
"hits": [ | ||
{ | ||
"_index": "cohere-embeddings", | ||
"_id": "-eFWCY4BECzWLnMZuI78", | ||
"_score": 0.737484, | ||
"_source": { | ||
"id": 1690948, | ||
"content": "Oxygen is supplied to the muscles via red blood cells. Red blood cells carry hemoglobin which oxygen bonds with as the hemoglobin rich blood cells pass through the blood vessels of the lungs.The now oxygen rich blood cells carry that oxygen to the cells that are demanding it, in this case skeletal muscle cells.ther ways in which muscles are supplied with oxygen include: 1 Blood flow from the heart is increased. 2 Blood flow to your muscles in increased. 3 Blood flow from nonessential organs is transported to working muscles." | ||
} | ||
}, | ||
{ | ||
"_index": "cohere-embeddings", | ||
"_id": "HuFWCY4BECzWLnMZuI_8", | ||
"_score": 0.7176013, | ||
"_source": { | ||
"id": 1692482, | ||
"content": "The thoracic cavity is separated from the abdominal cavity by the diaphragm. This is a broad flat muscle. (muscular) diaphragm The diaphragm is a muscle that separat…e the thoracic from the abdominal cavity. The pelvis is the lowest part of the abdominal cavity and it has no physical separation from it Diaphragm." | ||
} | ||
}, | ||
{ | ||
"_index": "cohere-embeddings", | ||
"_id": "IOFWCY4BECzWLnMZuI_8", | ||
"_score": 0.7154432, | ||
"_source": { | ||
"id": 1692489, | ||
"content": "Muscular Wall Separating the Abdominal and Thoracic Cavities; Thoracic Cavity of a Fetal Pig; In Mammals the Diaphragm Separates the Abdominal Cavity from the" | ||
} | ||
}, | ||
{ | ||
"_index": "cohere-embeddings", | ||
"_id": "C-FWCY4BECzWLnMZuI_8", | ||
"_score": 0.695313, | ||
"_source": { | ||
"id": 1691493, | ||
"content": "Burning, aching, tenderness and stiffness are just some descriptors of the discomfort you may feel in the muscles you exercised one to two days ago.For the most part, these sensations you experience after exercise are collectively known as delayed onset muscle soreness.urning, aching, tenderness and stiffness are just some descriptors of the discomfort you may feel in the muscles you exercised one to two days ago." | ||
} | ||
}, | ||
(...) | ||
] | ||
-------------------------------------------------- | ||
// NOTCONSOLE | ||
|
||
// end::cohere[] | ||
|
||
|
||
// tag::openai[] | ||
|
||
[source,console] | ||
-------------------------------------------------- | ||
GET openai-embeddings/_search | ||
{ | ||
"knn": { | ||
"field": "content_embedding", | ||
"query_vector_builder": { | ||
"text_embedding": { | ||
"model_id": "openai_embeddings", | ||
"model_text": "Calculate fuel cost" | ||
} | ||
}, | ||
"k": 10, | ||
"num_candidates": 100 | ||
}, | ||
"_source": [ | ||
"id", | ||
"content" | ||
] | ||
} | ||
-------------------------------------------------- | ||
// TEST[skip:TBD] | ||
|
||
As a result, you receive the top 10 documents that are closest in meaning to the | ||
query from the `openai-embeddings` index sorted by their proximity to the query: | ||
|
||
[source,consol-result] | ||
-------------------------------------------------- | ||
"hits": [ | ||
{ | ||
"_index": "openai-embeddings", | ||
"_id": "DDd5OowBHxQKHyc3TDSC", | ||
"_score": 0.83704096, | ||
"_source": { | ||
"id": 862114, | ||
"body": "How to calculate fuel cost for a road trip. By Tara Baukus Mello • Bankrate.com. Dear Driving for Dollars, My family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost.It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes.y family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost. It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes." | ||
} | ||
}, | ||
{ | ||
"_index": "openai-embeddings", | ||
"_id": "ajd5OowBHxQKHyc3TDSC", | ||
"_score": 0.8345704, | ||
"_source": { | ||
"id": 820622, | ||
"body": "Home Heating Calculator. Typically, approximately 50% of the energy consumed in a home annually is for space heating. When deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important.This calculator can help you estimate the cost of fuel for different heating appliances.hen deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important. This calculator can help you estimate the cost of fuel for different heating appliances." | ||
} | ||
}, | ||
{ | ||
"_index": "openai-embeddings", | ||
"_id": "Djd5OowBHxQKHyc3TDSC", | ||
"_score": 0.8327426, | ||
"_source": { | ||
"id": 8202683, | ||
"body": "Fuel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel.If you are paying $4 per gallon, the trip would cost you $200.Most boats have much larger gas tanks than cars.uel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel." | ||
} | ||
}, | ||
(...) | ||
] | ||
-------------------------------------------------- | ||
// NOTCONSOLE | ||
|
||
// end::openai[] |
39 changes: 39 additions & 0 deletions
39
docs/reference/tab-widgets/inference-api/infer-api-task-widget.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
++++ | ||
<div class="tabs" data-tab-group="model"> | ||
<div role="tablist" aria-label="model"> | ||
<button role="tab" | ||
aria-selected="true" | ||
aria-controls="infer-api-task-cohere-tab" | ||
id="infer-api-task-cohere"> | ||
Cohere | ||
</button> | ||
<button role="tab" | ||
aria-selected="false" | ||
aria-controls="infer-api-task-openai-tab" | ||
id="infer-api-task-openai"> | ||
OpenAI | ||
</button> | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-task-cohere-tab" | ||
aria-labelledby="infer-api-task-cohere"> | ||
++++ | ||
|
||
include::infer-api-task.asciidoc[tag=cohere] | ||
|
||
++++ | ||
</div> | ||
<div tabindex="0" | ||
role="tabpanel" | ||
id="infer-api-task-openai-tab" | ||
aria-labelledby="infer-api-task-openai" | ||
hidden=""> | ||
++++ | ||
|
||
include::infer-api-task.asciidoc[tag=openai] | ||
|
||
++++ | ||
</div> | ||
</div> | ||
++++ |
56 changes: 56 additions & 0 deletions
56
docs/reference/tab-widgets/inference-api/infer-api-task.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// tag::cohere[] | ||
|
||
[source,console] | ||
------------------------------------------------------------ | ||
PUT _inference/text_embedding/cohere_embeddings <1> | ||
{ | ||
"service": "cohere", | ||
"service_settings": { | ||
"api_key": "<api_key>", <2> | ||
"model_id": "embed-english-light-v3.0", <3> | ||
"embedding_type": "int8" | ||
}, | ||
"task_settings": { | ||
} | ||
} | ||
------------------------------------------------------------ | ||
// TEST[skip:TBD] | ||
<1> The task type is `text_embedding` in the path. | ||
<2> The API key of your Cohere account. You can find your API keys in your | ||
Cohere dashboard under the | ||
https://dashboard.cohere.com/api-keys[API keys section]. You need to provide | ||
your API key only once. The <<get-inference-api>> does not return your API | ||
key. | ||
<3> The name of the embedding model to use. You can find the list of Cohere | ||
embedding models https://docs.cohere.com/reference/embed[here]. | ||
|
||
// end::cohere[] | ||
|
||
|
||
// tag::openai[] | ||
|
||
[source,console] | ||
------------------------------------------------------------ | ||
PUT _inference/text_embedding/openai_embeddings <1> | ||
{ | ||
"service": "openai", | ||
"service_settings": { | ||
"api_key": "<api_key>", <2> | ||
"model_id": "text-embedding-ada-002" <3> | ||
}, | ||
"task_settings": { | ||
} | ||
} | ||
------------------------------------------------------------ | ||
// TEST[skip:TBD] | ||
<1> The task type is `text_embedding` in the path. | ||
<2> The API key of your OpenAI account. You can find your OpenAI API keys in | ||
your OpenAI account under the | ||
https://platform.openai.com/api-keys[API keys section]. You need to provide | ||
your API key only once. The <<get-inference-api>> does not return your API | ||
key. | ||
<3> The name of the embedding model to use. You can find the list of OpenAI | ||
embedding models | ||
https://platform.openai.com/docs/guides/embeddings/embedding-models[here]. | ||
|
||
// end::openai[] |