Factory
src.utils.factory.PromptBuilderFactory
Source code in src/utils/factory.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
get_prompt_builder(vendor)
staticmethod
Get a prompt builder instance for the specified vendor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vendor
|
str
|
Vendor identifier (e.g., 'openai', 'anthropic', 'watsonx', 'mistral_ai') |
required |
Returns:
Name | Type | Description |
---|---|---|
BasePromptBuilder |
BasePromptBuilder
|
Appropriate prompt builder instance |
Raises:
Type | Description |
---|---|
ValueError
|
If no prompt builder is available for the specified vendor |
Source code in src/utils/factory.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
src.utils.factory.FormatType
Bases: Enum
Enumeration of supported tool call format types.
Attributes:
Name | Type | Description |
---|---|---|
JSON |
For JSON-formatted tool calls. |
|
NON_JSON |
For non-JSON formatted tool calls. |
Source code in src/utils/factory.py
66 67 68 69 70 71 72 73 74 |
|
src.utils.factory.ToolCallParserFactory
Factory for creating tool call parser instances.
Manages the creation of parsers for different tool call formats, including JSON and non-JSON formats.
Attributes:
Name | Type | Description |
---|---|---|
registry |
Dict
|
Mapping of format types to their parser classes. |
Example
parser = ToolCallParserFactory.get_parser(
FormatType.JSON,
config={"clean_tokens": []}
)
Source code in src/utils/factory.py
77 78 79 80 81 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 |
|
get_parser(format_type, config)
staticmethod
Get appropriate parser for the specified format type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
format_type
|
FormatType
|
Type of format to parse. |
required |
config
|
Dict[str, Any]
|
Configuration for the parser. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseToolCallParser |
Instance of appropriate parser. |
Raises:
Type | Description |
---|---|
ValueError
|
If format type is not supported. |
Source code in src/utils/factory.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|