API Reference¶
Top Level Module¶
aspis
¶
Root for the Aspis application core functionality.
api
¶
Module for the Aspis REST API.
main
¶
Functions for the programmatic API of the Aspis application.
EvaluationResponse
¶
Bases: BaseModel
Response for the evaluation endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
systematized_concept_title |
str
|
The title of the systematized concept this evaluation is for. |
result |
dict[str, Any]
|
The result of the inference of the input text against this systematized concept. |
prompt |
str
|
The prompt that was used to produce the result. |
Source code in src/aspis/api/main.py
evaluate
async
¶
evaluate(
text_to_evaluate=Form(...),
api_key=Form(...),
systematized_concepts_file=File(...),
model=Form(ModelInfo.OPENAI_GPT_4O),
)
Evaluate an input text using systematized concepts from a file.
Returns one evaluation per systematized concept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_to_evaluate
|
str
|
The text to evaluate. |
Form(...)
|
api_key
|
str
|
The API key to use to connect to the model. |
Form(...)
|
model
|
ModelInfo
|
The model to use for this evaluation. Optional,
defaults to |
Form(OPENAI_GPT_4O)
|
systematized_concepts_file
|
UploadFile
|
The file containing the systematized concepts.
It must be a |
File(...)
|
Returns:
| Type | Description |
|---|---|
list[EvaluationResponse]
|
A list of evaluations for the input text, one for each systematized concept in the file. |
Source code in src/aspis/api/main.py
inferencer
¶
Scorer for applications using Aspis as anLLM-as-a-judge.
ModelInfo
¶
Bases: str, Enum
Information about the supported models for inferencing.
Source code in src/aspis/inferencer.py
__new__
¶
Make a new ModelInfo enum object.
The value of the enum will be the model ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
str
|
The ID of the model. |
required |
friendly_name
|
str
|
The friendly name of the model (displayed in the UI). |
required |
api_key_name
|
str
|
The name of the API key to use to connect to the model. |
required |
Source code in src/aspis/inferencer.py
__str__
¶
execute_samples_against_model
¶
Executes a list of samples against a model and returns the model outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples
|
list[Sample]
|
The list of samples to execute against the model. |
required |
model_info
|
ModelInfo
|
The information about the model to execute the samples against. |
required |
api_key
|
str
|
The API key to use to execute the samples against the model. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The model outputs. |
Source code in src/aspis/inferencer.py
evaluate_text
¶
Evaluates input text using the model and the prompt.
Will use get_inference_prompt function to replace placeholders in the prompt
with the input text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_text
|
str
|
The input text to infer. |
required |
prompt_templates
|
list[str]
|
The list of prompt templates to use to infer the input text. |
required |
model_info
|
ModelInfo
|
The information about the model to use to infer the input text. |
required |
api_key
|
str
|
The API key to use to connect to the model. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
The inferred output from the model, parsed from a json to a dictionary. |
Source code in src/aspis/inferencer.py
run_eval
¶
Helper function to run eval on a list of samples with a specific API key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples
|
list[Sample]
|
The list of samples to run the eval on. |
required |
model_info
|
ModelInfo
|
The information about the model to use for the evaluation. |
required |
api_key
|
str
|
The API key to use to run the eval. |
required |
Returns:
| Type | Description |
|---|---|
list[EvalLog]
|
The result of the eval. |
Source code in src/aspis/inferencer.py
get_inference_prompt
¶
Get the inference prompt to be used as input to the model.
It does so by replacing the <text_to_evaluate/> placeholder in the prompt
with <text>{input_text}</text>.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_text
|
str
|
The input text to infer. |
required |
prompt
|
str
|
The prompt to use to infer the input text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The inference prompt. |
Source code in src/aspis/inferencer.py
extract_string_output
¶
Extract the string output from the model output given the model info.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_output
|
Any
|
The model output. |
required |
model_info
|
ModelInfo
|
The model info. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The string output. |
Source code in src/aspis/inferencer.py
logging
¶
Logging setup for the Aspis application.
get_logger_level
¶
Get the logging level from the LOG_LEVEL environment variable.
If not set, the default is INFO.
Returns:
| Type | Description |
|---|---|
int
|
The logging level. |
Source code in src/aspis/logging.py
setup_logger
¶
Sets up the logging for the given runtime, detected dynamically.
The LOG_LEVEL environment variable is used to set the logging level. If not set, the default is INFO.
Returns:
| Type | Description |
|---|---|
Logger
|
The configured logger instance. |
Source code in src/aspis/logging.py
systematization
¶
Functions and classes to ask the systematization question.
SystematizedConcept
dataclass
¶
A systematized concept with a title, body, and prompt template.
Used for LLM measurement.
Source code in src/aspis/systematization.py
get_systematization_questions
¶
Get the systematization questions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_description
|
str
|
The description of the AI-powered product. |
required |
risk_description
|
str
|
The description of the AI risk the product is exposed to. |
required |
api_key
|
str
|
The API key to use the LLM. |
required |
model_info
|
ModelInfo
|
The information about the model to use to generate the systematization questions. |
required |
Returns:
| Type | Description |
|---|---|
list[str] | None
|
The follow up systematization questions. Will be None if the model fails to return a valid JSON. |
Source code in src/aspis/systematization.py
get_systematized_concepts
¶
get_systematized_concepts(
product_description,
risk_description,
questions,
answers,
api_key,
model_info,
)
Generate systematized concepts from the answers to follow-up questions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_description
|
str
|
The description of the AI-powered product. |
required |
risk_description
|
str
|
The description of the AI risk the product is exposed to. |
required |
questions
|
list[str]
|
The follow-up questions that were asked. |
required |
answers
|
list[str]
|
The answers provided by the user. |
required |
api_key
|
str
|
The API key to use the LLM. |
required |
model_info
|
ModelInfo
|
The information about the model to use to generate the systematized concepts. |
required |
Returns:
| Type | Description |
|---|---|
list[SystematizedConcept] | None
|
A list of systematized concepts with titles, bodies, and prompt templates. Will be None if the model fails to return a valid JSON. |
Source code in src/aspis/systematization.py
get_systematization_questions_prompt
¶
Get the systematization questions prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_description
|
str
|
The description of the AI-powered product. |
required |
risk_description
|
str
|
The description of the AI risk the product is exposed to. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The systematization questions prompt. |
Source code in src/aspis/systematization.py
get_systematized_concepts_prompt
¶
Get the systematized concepts prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_description
|
str
|
The description of the AI-powered product. |
required |
risk_description
|
str
|
The description of the AI risk the product is exposed to. |
required |
questions
|
list[str]
|
The follow-up questions that were asked. |
required |
answers
|
list[str]
|
The answers provided by the user. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The systematized concepts prompt. |
Source code in src/aspis/systematization.py
ui
¶
UI module for the Aspis application.
main
¶
UI for the Aspis application.
main
¶
Entry point for the Aspis application.
Source code in src/aspis/ui/main.py
render_landing_page
¶
Render the landing page elements.
Source code in src/aspis/ui/main.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
render_follow_up_questions
¶
Render the follow up questions to be asked to the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
follow_up_questions
|
list[str]
|
The follow up questions. |
required |
Source code in src/aspis/ui/main.py
render_systematized_concepts
¶
Render the systematized concepts with titles and bodies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systematized_concepts
|
list[SystematizedConcept]
|
The list of systematized concepts to display. |
required |
Source code in src/aspis/ui/main.py
render_download_button
¶
Render the download button to save the results.
Source code in src/aspis/ui/main.py
render_upload_button
¶
Render the upload button to load saved results.
Source code in src/aspis/ui/main.py
UI Module¶
aspis.ui.main
¶
UI for the Aspis application.
main
¶
Entry point for the Aspis application.
Source code in src/aspis/ui/main.py
render_landing_page
¶
Render the landing page elements.
Source code in src/aspis/ui/main.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
render_follow_up_questions
¶
Render the follow up questions to be asked to the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
follow_up_questions
|
list[str]
|
The follow up questions. |
required |
Source code in src/aspis/ui/main.py
render_systematized_concepts
¶
Render the systematized concepts with titles and bodies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systematized_concepts
|
list[SystematizedConcept]
|
The list of systematized concepts to display. |
required |
Source code in src/aspis/ui/main.py
render_download_button
¶
Render the download button to save the results.
Source code in src/aspis/ui/main.py
render_upload_button
¶
Render the upload button to load saved results.
Source code in src/aspis/ui/main.py
Systematization Module¶
aspis.systematization
¶
Functions and classes to ask the systematization question.
SystematizedConcept
dataclass
¶
A systematized concept with a title, body, and prompt template.
Used for LLM measurement.
Source code in src/aspis/systematization.py
get_systematization_questions
¶
Get the systematization questions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_description
|
str
|
The description of the AI-powered product. |
required |
risk_description
|
str
|
The description of the AI risk the product is exposed to. |
required |
api_key
|
str
|
The API key to use the LLM. |
required |
model_info
|
ModelInfo
|
The information about the model to use to generate the systematization questions. |
required |
Returns:
| Type | Description |
|---|---|
list[str] | None
|
The follow up systematization questions. Will be None if the model fails to return a valid JSON. |
Source code in src/aspis/systematization.py
get_systematized_concepts
¶
get_systematized_concepts(
product_description,
risk_description,
questions,
answers,
api_key,
model_info,
)
Generate systematized concepts from the answers to follow-up questions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_description
|
str
|
The description of the AI-powered product. |
required |
risk_description
|
str
|
The description of the AI risk the product is exposed to. |
required |
questions
|
list[str]
|
The follow-up questions that were asked. |
required |
answers
|
list[str]
|
The answers provided by the user. |
required |
api_key
|
str
|
The API key to use the LLM. |
required |
model_info
|
ModelInfo
|
The information about the model to use to generate the systematized concepts. |
required |
Returns:
| Type | Description |
|---|---|
list[SystematizedConcept] | None
|
A list of systematized concepts with titles, bodies, and prompt templates. Will be None if the model fails to return a valid JSON. |
Source code in src/aspis/systematization.py
get_systematization_questions_prompt
¶
Get the systematization questions prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_description
|
str
|
The description of the AI-powered product. |
required |
risk_description
|
str
|
The description of the AI risk the product is exposed to. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The systematization questions prompt. |
Source code in src/aspis/systematization.py
get_systematized_concepts_prompt
¶
Get the systematized concepts prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_description
|
str
|
The description of the AI-powered product. |
required |
risk_description
|
str
|
The description of the AI risk the product is exposed to. |
required |
questions
|
list[str]
|
The follow-up questions that were asked. |
required |
answers
|
list[str]
|
The answers provided by the user. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The systematized concepts prompt. |