from isaacus import Isaacus
# Create an Isaacus API client.
client = Isaacus(api_key="PASTE_YOUR_API_KEY_HERE")
# Define a query and a list of texts to rerank.
query = "What are the essential elements required to establish a negligence claim?"
texts = [
"To form a contract, there must be an offer, acceptance, consideration, "
"and mutual intent to be bound.",
"Criminal cases involve a completely different standard, requiring proof "
"beyond a reasonable doubt.",
"In a negligence claim, the plaintiff must prove duty, breach, causation, "
"and damages.",
"Negligence in tort law requires establishing a duty of care that the "
"defendant owed to the plaintiff.",
"The concept of negligence is central to tort law, with courts assessing "
"whether a breach of duty caused harm."
]
# Rerank the texts.
reranking = client.rerankings.create(
model="kanon-universal-classifier",
query=query,
texts=texts,
)
# Unpack the results.
results = [{
"index": result.index,
"text": texts[result.index],
"score": result.score,
} for result in reranking.results]
# Print the reranked results.
for result in results:
print(
'-' * 10,
f'index = {result["index"]} | score = {result["score"]:.2f}',
'-' * 10,
'\n',
result["text"],
end='\n\n',
)