Resources reference
Resources provide access to different entities in Giskard Hub through the client, such as projects, datasets, and models.
- class giskard_hub.resources.ChatTestCasesResource(client: SyncClient)[source]
Bases:
APIResource
- create(*, dataset_id: str, messages: List[ChatMessage], demo_output: ChatMessageWithMetadata | None = None, tags: List[str] | None = None, checks: List[CheckConfig] | None = None)[source]
- delete(chat_test_case_id: str | List[str]) None [source]
- list(dataset_id: str) List[ChatTestCase] [source]
- retrieve(chat_test_case_id: str)[source]
- update(chat_test_case_id: str, *, dataset_id: str = NOT_GIVEN, messages: List[ChatMessage] = NOT_GIVEN, demo_output: ChatMessageWithMetadata | None = NOT_GIVEN, tags: List[str] | None = NOT_GIVEN, checks: List[CheckConfig] | None = NOT_GIVEN) ChatTestCase [source]
- class giskard_hub.resources.ConversationsResource(client: SyncClient)[source]
Bases:
APIResource
- create(*, dataset_id: str, messages: List[ChatMessage], demo_output: ChatMessageWithMetadata | None = None, tags: List[str] | None = None, checks: List[CheckConfig] | None = None)[source]
- delete(conversation_id: str | List[str]) None [source]
- list(dataset_id: str) List[Conversation] [source]
- retrieve(conversation_id: str)[source]
- update(conversation_id: str, *, dataset_id: str = NOT_GIVEN, messages: List[ChatMessage] = NOT_GIVEN, demo_output: ChatMessageWithMetadata | None = NOT_GIVEN, tags: List[str] | None = NOT_GIVEN, checks: List[CheckConfig] | None = NOT_GIVEN) Conversation [source]
- class giskard_hub.resources.DatasetsResource(client: SyncClient)[source]
Bases:
APIResource
- create(*, name: str, description: str, project_id: str) giskard.Dataset [source]
- delete(dataset_id: str | List[str]) None [source]
- generate_adversarial(*, model_id: str, dataset_name: str = 'Generated Dataset', description: str = '', categories: List[str] | Any = NOT_GIVEN, n_examples: int = 10) giskard.Dataset [source]
Generate a dataset using the specified model and parameters.
- Parameters:
model_id (str) – The ID of the model to use for generation.
dataset_name (str, optional) – Name of the generated dataset.
description (str, optional) – Description of the dataset.
categories (list, optional) – List of issue categories, each as a dict with ‘id’, ‘name’, ‘desc’.
n_examples (int, optional) – Number of examples to generate in total, regardless of the number of categories.
- Returns:
The generated dataset object.
- Return type:
- generate_document_based(*, model_id: str, knowledge_base_id: str, dataset_name: str = 'Generated Dataset', description: str = '', n_questions: int = 10, topic_ids: List[UUID] | None = None) giskard.Dataset [source]
Generate a dataset from a knowledge base.
- Parameters:
model_id (str) – The ID of the model to use for generation.
knowledge_base_id (str) – The ID of the knowledge base.
dataset_name (str, optional) – Name of the generated dataset.
description (str, optional) – Description of the dataset.
n_questions (int, optional) – Number of questions to generate in total, regardless of the number of topics.
topic_ids (list[UUID], optional) – List of topic IDs to filter.
- Returns:
The generated dataset object.
- Return type:
- list(project_id: str) List[giskard.Dataset] [source]
- retrieve(dataset_id: str)[source]
- update(dataset_id: str, *, name: str = NOT_GIVEN, description: str = NOT_GIVEN, project_id: str = NOT_GIVEN) giskard.Dataset [source]
- class giskard_hub.resources.EvaluationsResource(client: SyncClient)[source]
Bases:
APIResource
- create(*, model_id: str, dataset_id: str, tags: List[str] = NOT_GIVEN, name: str = NOT_GIVEN, run_count: int = 1)[source]
- create_local(*, model: Model, dataset_id: str, tags: List[str] = NOT_GIVEN, name: str = NOT_GIVEN)[source]
- delete(execution_id: str | List[str])[source]
- list(project_id: str)[source]
- list_entries(run_id: str)[source]
- retrieve(run_id: str)[source]
- update_entry(run_id: str, entry_id: str, *, model_output: ModelOutput = NOT_GIVEN, results: List[EvaluatorResult] = NOT_GIVEN)[source]
- class giskard_hub.resources.KnowledgeBasesResource(client: SyncClient)[source]
Bases:
APIResource
Resource for managing knowledge bases.
- create(*, project_id: str, name: str, data: str | List[dict[str, str]], description: str | None = None, document_column: str | NotGiven = NOT_GIVEN, topic_column: str | NotGiven = NOT_GIVEN) KnowledgeBase [source]
Create a new knowledge base.
- Parameters:
project_id (str) – The project ID.
name (str) – The name of the knowledge base.
data (str or list[dict[str, str]]) – Either a filepath (str) to a JSON or JSONL file, or a list of dicts containing “text” and “topic” (optional) keys.
description (str, optional) – Description of the knowledge base.
document_column (str, optional) – Name of the document column.
topic_column (str, optional) – Name of the topic column.
- Returns:
The created knowledge base object.
- Return type:
- delete(knowledge_base_id: str | list[str]) None [source]
Delete one or more knowledge bases.
- list(project_id: str) list[KnowledgeBase] [source]
List knowledge bases, filtered by project.
- list_documents(knowledge_base_id: str, topic_id: str | NotGiven = NOT_GIVEN) list[Document] [source]
List documents for a knowledge base, optionally filtered by topic.
- retrieve(knowledge_base_id: str) KnowledgeBase [source]
Retrieve a knowledge base by ID.
- update(knowledge_base_id: str, *, name: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, project_id: str | NotGiven = NOT_GIVEN) KnowledgeBase [source]
Update a knowledge base.
- class giskard_hub.resources.ModelsResource(client: SyncClient)[source]
Bases:
APIResource
- chat(model_id: str, messages: List[ChatMessage]) ModelOutput [source]
- create(*, name: str, description: str, url: str, supported_languages: List[str], headers: Dict[str, str] = None, project_id: str) Model [source]
- delete(model_id: str | List[str]) None [source]
- list(project_id: str) List[Model] [source]
- retrieve(model_id: str) Model [source]
- update(model_id: str, *, name: str = NOT_GIVEN, description: str = NOT_GIVEN, url: str = NOT_GIVEN, supported_languages: List[str] = NOT_GIVEN, headers: Dict[str, str] = NOT_GIVEN, project_id: str = NOT_GIVEN) Model [source]
- class giskard_hub.resources.ProjectsResource(client: SyncClient)[source]
Bases:
APIResource
- create(*, name: str, description: str = '')[source]
- delete(project_id: str | List[str])[source]
- list()[source]
- retrieve(project_id: str)[source]
- update(project_id: str, *, name: str = NOT_GIVEN, description: str = NOT_GIVEN)[source]
- class giskard_hub.resources.ScheduledEvaluationsResource(client: SyncClient)[source]
Bases:
APIResource
Resource for managing scheduled evaluations.
- create(*, project_id: str, name: str, model_id: str, dataset_id: str, frequency: Literal['daily', 'weekly', 'monthly'] | FrequencyOption, time: str, tags: List[str] | None = None, run_count: int = 1, day_of_week: int | None = None, day_of_month: int | None = None) ScheduledEvaluation [source]
Create a new scheduled evaluation.
- Parameters:
project_id (str) – The ID of the project to create the scheduled evaluation in.
name (str) – The name of the scheduled evaluation.
model_id (str) – The ID of the model to evaluate.
dataset_id (str) – The ID of the dataset to evaluate against.
frequency (str) – The frequency of the scheduled evaluation (daily, weekly, monthly).
time (str) – The time to run the evaluation (HH:MM format).
tags (List[str], optional) – List of tags to filter the conversations that will be evaluated.
run_count (int, optional) – The number of times to run each test case (1-5), by default 1.
day_of_week (int, optional) – The day of the week to run (1-7, 1 is Monday). Required for weekly frequency.
day_of_month (int, optional) – The day of the month to run (1-28). Required for monthly frequency.
- Returns:
The created scheduled evaluation.
- Return type:
ScheduledEvaluation
- delete(scheduled_evaluation_ids: str | List[str]) None [source]
Delete scheduled evaluations.
- Parameters:
scheduled_evaluation_ids (Union[str, List[str]]) – List of scheduled evaluation IDs or a single scheduled evaluation ID to delete.
- list(*, project_id: str) List[ScheduledEvaluation] [source]
List scheduled evaluations for a project.
- Parameters:
project_id (str) – The ID of the project to list scheduled evaluations for.
- Returns:
List of scheduled evaluations.
- Return type:
List[ScheduledEvaluation]
- list_evaluations(scheduled_evaluation_id: str) List[EvaluationRun] [source]
List evaluations linked to a scheduled evaluation.
- Parameters:
scheduled_evaluation_id (str) – The ID of the scheduled evaluation to get evaluations for.
- Returns:
List of evaluations linked to the scheduled evaluation.
- Return type:
List[EvaluationRun]
- retrieve(scheduled_evaluation_id: str) ScheduledEvaluation [source]
Retrieve a scheduled evaluation by ID.
- Parameters:
scheduled_evaluation_id (str) – The ID of the scheduled evaluation to retrieve.
- Returns:
The scheduled evaluation.
- Return type:
ScheduledEvaluation
- update(scheduled_evaluation_id: str, *, name: str | NotGiven = NOT_GIVEN, run_count: int | NotGiven = NOT_GIVEN, frequency: Literal['daily', 'weekly', 'monthly'] | FrequencyOption | NotGiven = NOT_GIVEN, time: str | NotGiven = NOT_GIVEN, day_of_week: int | NotGiven = NOT_GIVEN, day_of_month: int | NotGiven = NOT_GIVEN, paused: bool | NotGiven = NOT_GIVEN) ScheduledEvaluation [source]
Update a scheduled evaluation.
- Parameters:
scheduled_evaluation_id (str) – The ID of the scheduled evaluation to update.
name (str, optional) – The name of the scheduled evaluation.
frequency (str, optional) – The frequency of the scheduled evaluation (daily, weekly, monthly).
time (str, optional) – The time to run the evaluation (HH:MM format).
run_count (int, optional) – The number of times to run each test case (1-5).
day_of_week (int, optional) – The day of the week to run (1-7, 1 is Monday). Required for weekly frequency.
day_of_month (int, optional) – The day of the month to run (1-28). Required for monthly frequency.
paused (bool, optional) – Whether the scheduled evaluation is paused.
- Returns:
The updated scheduled evaluation.
- Return type:
ScheduledEvaluation