Semantic Search
Semantic search provides the ability to query/search over a set of documents based off the meaning of the documents (as opposed to keyword-based search).
Questions? Contact Us
Semantic Query POST
Request Parameters
import requests
key = '<api-key>'
url = 'https://api.sapling.ai/api/v1/semsearch'
data = {
'key': key,
'query': 'Who was Rin Tin Tin?',
}
try:
resp = requests.post(url, json=data)
resp_json = resp.json()
if 200 <= resp.status_code < 300:
results = resp_json
print('Results: ', results)
else:
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
https://api.sapling.ai/api/v1/semsearch
HTTP method: POST
With return http status 400 with feedback in the msg
field if the request is invalid e.g if the key is missing or incorrect.
key: String
32-character API key
query: String
Query to to match against documents in the response bank.
part: String
Either prompt
or both
. Whether to match against both documents and prompts or just prompts.
Response Parameters
results: JSON, sorted array of semantic search results of the following structure.
{
"doc": <str>, // Text of document matching query
"id": <str>, // Random string ID
"score": <float> // Score of query. Higher is better.
}
Create Entry POST
https://api.sapling.ai/api/v1/semsearch/create
HTTP method: POST
Request Parameters
key: String
32-character API key
team_id: String (UUID)
ID of the team to associate the entry with.
entry: JSON
Of the form:
{
"title": "Entry title",
"prompt": "Entry prompt",
"plain_text": 'Entry document text"
}
Response Parameters
HTTP status code 201.
Delete Entry DELETE
https://api.sapling.ai/api/v1/semsearch/<entry_id>
Deletes entry with the ID entry_id
assuming entry exists and user has permissions.
Request Parameters
<entry_id>: String (UUID)
ID of search entry.
key: String
32-character API key
Response Parameters
Empty, HTTP status code 204.