Pythia API has a straightforward syntax for each purpose. Each API endpoint serves a different functionality for advanced hallucination detection in LLMs.
This guide is designed to help you integrate Pythia in your workflows using the Wisecube Python SDK.
1. Get the API key
Submit the API request form with your active email address and the purpose of the API request. You’ll receive an API key in your inbox.
2. Install Wisecube SDK
Install the latest Wisecube SDK in your Python environment:
pip install wisecube==1.0.0
3. Authenticate API key
Import WisecubeClient
from wisecube
and pass your API key to it as in the example below:
from wisecube_sdk.client import WisecubeClient
API_KEY = "YOUR_API_KEY" #replace with your API key
client = WisecubeClient(API_KEY).client
4. API usage
After you’ve authenticated the API key, you can make API calls to detect hallucinations and retrieve relevant information. This involves calling the Python SDK API endpoints with suitable parameters.
QA
Description
.qa()returns summary information for the question passed as a parameter. This summary also includes relevant documents linked to the question.
Call
client.qa(question)
Parameters
question (String): the input must be a question you want the answer to
Documents
Description
The documents call returns insights and relevant documents related to the question.
Call
client.documents(question)
Parameters
question (String): The input must be a question to get the documents.
Search Graph
Description
This API returns results in the form of a subgraph containing nodes and edges.
Call
client.search_graph(graphIds, nr=20)
Parameters
graphIds ([String]): The input must be a list of IDs, including the ID of the starting node in the graph.
maxNeighbors(Int): Represented by nr: optional variable, default is 10. It indicates the maximum number of neighbor nodes to retrieve.
Search Text
Description
The API returns a list of entities related to the search term.
Call
client.search_text(searchText)
Parameters
searchText (String): The string you want to search.
Advanced Search
Description
This API returns the entities retrieved from the Wikidata database based on the provided query to fulfil the advanced biomedical research requirements.
Call
client.advance_search(query)
Parameters
query (String): Advanced search query.
Predicate Graph
Description
The API retrieves information about predicates linked to a given label.
Call
client.get_predicates(labels)
Parameters
labels (String): Represents the label of a predicate.
Execute Vector Function
Description
The API returns vector embeddings for the given entities.
Call
client.execute_vector_function(graphIds)
Parameters
graphIds [String]: Variable used to specify a list of graph IDs.
Execute Score Function
Description
This API returns the score for each triple.
Call
client.execute_score_function(triples)
Parameters
triples [[String]]: Variable representing a list of lists of strings, each containing three elements.
Admet Prediction
Description
This API returnss prediction using ADMET models and sagemaker.
List of models: [BBB, logS, CYP2CI9i, LogD7, PGPi, PGPs, HIA, F20, F30, PPB, VD, CYPIA2i, CYPIA2s, CYP3A4i, CYP3A4s, CYP2C9i, CYP2C9s, CYP2C19s, CYP2D6i, CYP2D6s, CL, Ames, DILI, SkinS, Caco2, THALF, hERG, HHT ]
Call
client.get_admet_prediction(smiles=smiles, model=model.BBB)
Parameters
smiles [String]: Specification in the form of a line notation for describing the structure of chemical.
model (String): Represents the model name.
Nl to sparql
Description
This API converts text to sparql.
Call
client.nl_to_sparql(question)
Parameters
question (String): The input must be a question.
Ask Pythia
Description
This API obtains information about the input reference, response and question. It also generates LLM performance based on the deviation of responses from input reference.
Call
client.ask_pythia(reference,response,question)
Parameters
question (String): the input must be a question
reference ([String]): information related to a medical report
response(String): response related to a medical report