ExOpenAI.Searches.create_search
create_search
, go back to ExOpenAI.Searches module for more information.
Specs
create_search(String.t(), String.t(), user: String.t(), return_metadata: boolean(), max_rerank: integer(), file: String.t(), documents: [String.t()] ) :: {:ok, ExOpenAI.Components.CreateSearchResponse.t()} | {:error, any()}
The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them.
To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When file
is set, the search endpoint searches over all the documents in the given file and returns up to the max_rerank
number of documents. These documents will be returned along with their search scores.
The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.
Endpoint: https://api.openai.com/v1/engines/{engine_id}/search
Method: POST
Docs: https://platform.openai.com/docs/api-reference/searches
Required Arguments:
engine_id
Example: davinci
query
: Query to search against the documents.
Example: the president
Optional Arguments:
documents
: Up to 200 documents to search over, provided as a list of strings.
The maximum document length (in tokens) is 2034 minus the number of tokens in the query.
You should specify either documents
or a file
, but not both.
Example: "['White House', 'hospital', 'school']"
file
: The ID of an uploaded file that contains documents to search over.
You should specify either documents
or a file
, but not both.
max_rerank
: The maximum number of documents to be re-ranked and returned by search.
This flag only takes effect when file
is set.
return_metadata
: A special boolean flag for showing metadata. If set totrue
, each document entry in the returned JSON will contain a "metadata" field.
This flag only takes effect when file
is set.
user
: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
Example: "user-1234"