NotDiamond package
notdiamond.callbacks
notdiamond.exceptions
- exception notdiamond.exceptions.ApiError[source]
Bases:
Exception
The exception class for any ApiError
Bases:
Exception
The exception class raised when notdiamond[create] is not available
- exception notdiamond.exceptions.InvalidApiKey[source]
Bases:
Exception
The exception class for InvalidApiKey
- exception notdiamond.exceptions.MissingApiKey[source]
Bases:
Exception
The exception class for MissingApiKey
notdiamond.settings
notdiamond.types
- class notdiamond.types.FeedbackRequestPayload(*, session_id: str, provider: Dict[str, Any], feedback: Dict[str, int])[source]
Bases:
BaseModel
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
session_id (str)
provider (Dict[str, Any])
feedback (Dict[str, int])
- feedback: Dict[str, int]
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'feedback': FieldInfo(annotation=Dict[str, int], required=True), 'provider': FieldInfo(annotation=Dict[str, Any], required=True), 'session_id': FieldInfo(annotation=str, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- provider: Dict[str, Any]
- session_id: str
- class notdiamond.types.ModelSelectRequestPayload(*, prompt_template: str, formatted_prompt: str, components: Dict[str, Dict], llm_configs: List[Dict], metric: str, max_model_depth: int)[source]
Bases:
BaseModel
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
prompt_template (str)
formatted_prompt (str)
components (Dict[str, Dict])
llm_configs (List[Dict])
metric (str)
max_model_depth (int)
- components: Dict[str, Dict]
- formatted_prompt: str
- llm_configs: List[Dict]
- max_model_depth: int
- metric: str
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'components': FieldInfo(annotation=Dict[str, Dict], required=True), 'formatted_prompt': FieldInfo(annotation=str, required=True), 'llm_configs': FieldInfo(annotation=List[Dict], required=True), 'max_model_depth': FieldInfo(annotation=int, required=True), 'metric': FieldInfo(annotation=str, required=True), 'prompt_template': FieldInfo(annotation=str, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- prompt_template: str
- class notdiamond.types.NDApiKeyValidator(*, api_key: str)[source]
Bases:
BaseModel
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
api_key (str)
- api_key: str
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'api_key': FieldInfo(annotation=str, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
notdiamond.prompts
- notdiamond.prompts._curly_escape(text: str) str [source]
Escape curly braces in the text, but only for single occurrences of alphabetic characters. This function will not escape double curly braces or non-alphabetic characters.
- Parameters:
text (str)
- Return type:
str
- notdiamond.prompts.inject_system_prompt(messages: List[Dict[str, str]], system_prompt: str) List[Dict[str, str]] [source]
Add a system prompt to an OpenAI-style message list. If a system prompt is already present, replace it.
- Parameters:
messages (List[Dict[str, str]])
system_prompt (str)
- Return type:
List[Dict[str, str]]