edsl 0.1.48__py3-none-any.whl → 0.1.50__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- edsl/__init__.py +124 -53
- edsl/__version__.py +1 -1
- edsl/agents/agent.py +21 -21
- edsl/agents/agent_list.py +2 -5
- edsl/agents/exceptions.py +119 -5
- edsl/base/__init__.py +10 -35
- edsl/base/base_class.py +71 -36
- edsl/base/base_exception.py +204 -0
- edsl/base/data_transfer_models.py +1 -1
- edsl/base/exceptions.py +94 -0
- edsl/buckets/__init__.py +15 -1
- edsl/buckets/bucket_collection.py +3 -4
- edsl/buckets/exceptions.py +75 -0
- edsl/buckets/model_buckets.py +1 -2
- edsl/buckets/token_bucket.py +11 -6
- edsl/buckets/token_bucket_api.py +1 -2
- edsl/buckets/token_bucket_client.py +9 -7
- edsl/caching/cache.py +7 -2
- edsl/caching/cache_entry.py +10 -9
- edsl/caching/exceptions.py +113 -7
- edsl/caching/remote_cache_sync.py +1 -2
- edsl/caching/sql_dict.py +17 -12
- edsl/cli.py +43 -0
- edsl/config/config_class.py +30 -6
- edsl/conversation/Conversation.py +3 -2
- edsl/conversation/exceptions.py +58 -0
- edsl/conversation/mug_negotiation.py +0 -2
- edsl/coop/__init__.py +20 -1
- edsl/coop/coop.py +129 -38
- edsl/coop/exceptions.py +188 -9
- edsl/coop/price_fetcher.py +3 -6
- edsl/coop/utils.py +4 -6
- edsl/dataset/__init__.py +5 -4
- edsl/dataset/dataset.py +53 -43
- edsl/dataset/dataset_operations_mixin.py +86 -72
- edsl/dataset/dataset_tree.py +9 -5
- edsl/dataset/display/table_display.py +0 -2
- edsl/dataset/display/table_renderers.py +0 -1
- edsl/dataset/exceptions.py +125 -0
- edsl/dataset/file_exports.py +18 -11
- edsl/dataset/r/ggplot.py +13 -6
- edsl/display/__init__.py +27 -0
- edsl/display/core.py +147 -0
- edsl/display/plugin.py +189 -0
- edsl/display/utils.py +52 -0
- edsl/inference_services/__init__.py +9 -1
- edsl/inference_services/available_model_cache_handler.py +1 -1
- edsl/inference_services/available_model_fetcher.py +4 -5
- edsl/inference_services/data_structures.py +9 -6
- edsl/inference_services/exceptions.py +132 -1
- edsl/inference_services/inference_service_abc.py +2 -2
- edsl/inference_services/inference_services_collection.py +2 -6
- edsl/inference_services/registry.py +4 -3
- edsl/inference_services/service_availability.py +2 -1
- edsl/inference_services/services/anthropic_service.py +4 -1
- edsl/inference_services/services/aws_bedrock.py +13 -12
- edsl/inference_services/services/azure_ai.py +12 -10
- edsl/inference_services/services/deep_infra_service.py +1 -4
- edsl/inference_services/services/deep_seek_service.py +1 -5
- edsl/inference_services/services/google_service.py +6 -2
- edsl/inference_services/services/groq_service.py +1 -1
- edsl/inference_services/services/mistral_ai_service.py +4 -2
- edsl/inference_services/services/ollama_service.py +1 -1
- edsl/inference_services/services/open_ai_service.py +7 -5
- edsl/inference_services/services/perplexity_service.py +6 -2
- edsl/inference_services/services/test_service.py +8 -7
- edsl/inference_services/services/together_ai_service.py +2 -3
- edsl/inference_services/services/xai_service.py +1 -1
- edsl/instructions/__init__.py +1 -1
- edsl/instructions/change_instruction.py +3 -2
- edsl/instructions/exceptions.py +61 -0
- edsl/instructions/instruction.py +5 -2
- edsl/instructions/instruction_collection.py +2 -1
- edsl/instructions/instruction_handler.py +4 -9
- edsl/interviews/ReportErrors.py +0 -3
- edsl/interviews/__init__.py +9 -2
- edsl/interviews/answering_function.py +11 -13
- edsl/interviews/exception_tracking.py +14 -7
- edsl/interviews/exceptions.py +79 -0
- edsl/interviews/interview.py +32 -29
- edsl/interviews/interview_status_dictionary.py +4 -2
- edsl/interviews/interview_status_log.py +2 -1
- edsl/interviews/interview_task_manager.py +3 -3
- edsl/interviews/request_token_estimator.py +3 -1
- edsl/interviews/statistics.py +2 -3
- edsl/invigilators/__init__.py +7 -1
- edsl/invigilators/exceptions.py +79 -0
- edsl/invigilators/invigilator_base.py +0 -1
- edsl/invigilators/invigilators.py +8 -12
- edsl/invigilators/prompt_constructor.py +1 -5
- edsl/invigilators/prompt_helpers.py +8 -4
- edsl/invigilators/question_instructions_prompt_builder.py +1 -1
- edsl/invigilators/question_option_processor.py +9 -5
- edsl/invigilators/question_template_replacements_builder.py +3 -2
- edsl/jobs/__init__.py +3 -3
- edsl/jobs/async_interview_runner.py +24 -22
- edsl/jobs/check_survey_scenario_compatibility.py +7 -6
- edsl/jobs/data_structures.py +7 -4
- edsl/jobs/exceptions.py +177 -8
- edsl/jobs/fetch_invigilator.py +1 -1
- edsl/jobs/jobs.py +72 -67
- edsl/jobs/jobs_checks.py +2 -3
- edsl/jobs/jobs_component_constructor.py +2 -2
- edsl/jobs/jobs_pricing_estimation.py +3 -2
- edsl/jobs/jobs_remote_inference_logger.py +5 -4
- edsl/jobs/jobs_runner_asyncio.py +1 -2
- edsl/jobs/jobs_runner_status.py +8 -9
- edsl/jobs/remote_inference.py +26 -23
- edsl/jobs/results_exceptions_handler.py +8 -5
- edsl/key_management/__init__.py +3 -1
- edsl/key_management/exceptions.py +62 -0
- edsl/key_management/key_lookup.py +1 -1
- edsl/key_management/key_lookup_builder.py +37 -14
- edsl/key_management/key_lookup_collection.py +2 -0
- edsl/language_models/__init__.py +1 -1
- edsl/language_models/exceptions.py +302 -14
- edsl/language_models/language_model.py +4 -7
- edsl/language_models/model.py +4 -4
- edsl/language_models/model_list.py +1 -1
- edsl/language_models/price_manager.py +1 -1
- edsl/language_models/raw_response_handler.py +14 -9
- edsl/language_models/registry.py +17 -21
- edsl/language_models/repair.py +0 -6
- edsl/language_models/unused/fake_openai_service.py +0 -1
- edsl/load_plugins.py +69 -0
- edsl/logger.py +146 -0
- edsl/notebooks/notebook.py +1 -1
- edsl/notebooks/notebook_to_latex.py +0 -1
- edsl/plugins/__init__.py +63 -0
- edsl/plugins/built_in/export_example.py +50 -0
- edsl/plugins/built_in/pig_latin.py +67 -0
- edsl/plugins/cli.py +372 -0
- edsl/plugins/cli_typer.py +283 -0
- edsl/plugins/exceptions.py +31 -0
- edsl/plugins/hookspec.py +51 -0
- edsl/plugins/plugin_host.py +128 -0
- edsl/plugins/plugin_manager.py +633 -0
- edsl/plugins/plugins_registry.py +168 -0
- edsl/prompts/__init__.py +2 -0
- edsl/prompts/exceptions.py +107 -5
- edsl/prompts/prompt.py +14 -6
- edsl/questions/HTMLQuestion.py +5 -11
- edsl/questions/Quick.py +0 -1
- edsl/questions/__init__.py +2 -0
- edsl/questions/answer_validator_mixin.py +318 -318
- edsl/questions/compose_questions.py +2 -2
- edsl/questions/descriptors.py +10 -49
- edsl/questions/exceptions.py +278 -22
- edsl/questions/loop_processor.py +7 -5
- edsl/questions/prompt_templates/question_list.jinja +3 -0
- edsl/questions/question_base.py +14 -16
- edsl/questions/question_base_gen_mixin.py +2 -2
- edsl/questions/question_base_prompts_mixin.py +9 -3
- edsl/questions/question_budget.py +9 -5
- edsl/questions/question_check_box.py +3 -5
- edsl/questions/question_dict.py +171 -194
- edsl/questions/question_extract.py +1 -1
- edsl/questions/question_free_text.py +4 -6
- edsl/questions/question_functional.py +4 -3
- edsl/questions/question_list.py +36 -9
- edsl/questions/question_matrix.py +95 -61
- edsl/questions/question_multiple_choice.py +6 -4
- edsl/questions/question_numerical.py +2 -4
- edsl/questions/question_registry.py +4 -2
- edsl/questions/register_questions_meta.py +0 -1
- edsl/questions/response_validator_abc.py +7 -13
- edsl/questions/templates/dict/answering_instructions.jinja +1 -0
- edsl/questions/templates/rank/question_presentation.jinja +1 -1
- edsl/results/__init__.py +1 -1
- edsl/results/exceptions.py +141 -7
- edsl/results/report.py +0 -1
- edsl/results/result.py +4 -5
- edsl/results/results.py +10 -51
- edsl/results/results_selector.py +8 -4
- edsl/scenarios/PdfExtractor.py +2 -2
- edsl/scenarios/construct_download_link.py +69 -35
- edsl/scenarios/directory_scanner.py +33 -14
- edsl/scenarios/document_chunker.py +1 -1
- edsl/scenarios/exceptions.py +238 -14
- edsl/scenarios/file_methods.py +1 -1
- edsl/scenarios/file_store.py +7 -3
- edsl/scenarios/handlers/__init__.py +17 -0
- edsl/scenarios/handlers/docx_file_store.py +0 -5
- edsl/scenarios/handlers/pdf_file_store.py +0 -1
- edsl/scenarios/handlers/pptx_file_store.py +0 -5
- edsl/scenarios/handlers/py_file_store.py +0 -1
- edsl/scenarios/handlers/sql_file_store.py +1 -4
- edsl/scenarios/handlers/sqlite_file_store.py +0 -1
- edsl/scenarios/handlers/txt_file_store.py +1 -1
- edsl/scenarios/scenario.py +0 -1
- edsl/scenarios/scenario_list.py +152 -18
- edsl/scenarios/scenario_list_pdf_tools.py +1 -0
- edsl/scenarios/scenario_selector.py +0 -1
- edsl/surveys/__init__.py +3 -4
- edsl/surveys/dag/__init__.py +4 -2
- edsl/surveys/descriptors.py +1 -1
- edsl/surveys/edit_survey.py +1 -0
- edsl/surveys/exceptions.py +165 -9
- edsl/surveys/memory/__init__.py +5 -3
- edsl/surveys/memory/memory_management.py +1 -0
- edsl/surveys/memory/memory_plan.py +6 -15
- edsl/surveys/rules/__init__.py +5 -3
- edsl/surveys/rules/rule.py +1 -2
- edsl/surveys/rules/rule_collection.py +1 -1
- edsl/surveys/survey.py +12 -24
- edsl/surveys/survey_export.py +6 -3
- edsl/surveys/survey_flow_visualization.py +10 -1
- edsl/tasks/__init__.py +2 -0
- edsl/tasks/question_task_creator.py +3 -3
- edsl/tasks/task_creators.py +1 -3
- edsl/tasks/task_history.py +5 -7
- edsl/tasks/task_status_log.py +1 -2
- edsl/tokens/__init__.py +3 -1
- edsl/tokens/token_usage.py +1 -1
- edsl/utilities/__init__.py +21 -1
- edsl/utilities/decorators.py +1 -2
- edsl/utilities/markdown_to_docx.py +2 -2
- edsl/utilities/markdown_to_pdf.py +1 -1
- edsl/utilities/repair_functions.py +0 -1
- edsl/utilities/restricted_python.py +0 -1
- edsl/utilities/template_loader.py +2 -3
- edsl/utilities/utilities.py +8 -29
- {edsl-0.1.48.dist-info → edsl-0.1.50.dist-info}/METADATA +32 -2
- edsl-0.1.50.dist-info/RECORD +363 -0
- edsl-0.1.50.dist-info/entry_points.txt +3 -0
- edsl/dataset/smart_objects.py +0 -96
- edsl/exceptions/BaseException.py +0 -21
- edsl/exceptions/__init__.py +0 -54
- edsl/exceptions/configuration.py +0 -16
- edsl/exceptions/general.py +0 -34
- edsl/study/ObjectEntry.py +0 -173
- edsl/study/ProofOfWork.py +0 -113
- edsl/study/SnapShot.py +0 -80
- edsl/study/Study.py +0 -520
- edsl/study/__init__.py +0 -6
- edsl/utilities/interface.py +0 -135
- edsl-0.1.48.dist-info/RECORD +0 -347
- {edsl-0.1.48.dist-info → edsl-0.1.50.dist-info}/LICENSE +0 -0
- {edsl-0.1.48.dist-info → edsl-0.1.50.dist-info}/WHEEL +0 -0
edsl/plugins/hookspec.py
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
import pluggy
|
2
|
+
from typing import Dict, Any, Optional
|
3
|
+
|
4
|
+
# Define a hook specification namespace
|
5
|
+
hookspec = pluggy.HookspecMarker("edsl")
|
6
|
+
|
7
|
+
class EDSLPluginSpec:
|
8
|
+
"""Hook specifications for EDSL plugins."""
|
9
|
+
|
10
|
+
@hookspec
|
11
|
+
def plugin_name(self):
|
12
|
+
"""Return the name of the plugin."""
|
13
|
+
|
14
|
+
@hookspec
|
15
|
+
def get_plugin_methods(self):
|
16
|
+
"""Return a dictionary of methods provided by this plugin."""
|
17
|
+
|
18
|
+
@hookspec
|
19
|
+
def plugin_description(self):
|
20
|
+
"""Return a description of the plugin."""
|
21
|
+
|
22
|
+
@hookspec
|
23
|
+
def plugin_return_type(self):
|
24
|
+
"""Return the return type of the plugin."""
|
25
|
+
|
26
|
+
@hookspec
|
27
|
+
def plugin_args(self):
|
28
|
+
"""Return the arguments of the plugin."""
|
29
|
+
|
30
|
+
@hookspec
|
31
|
+
def edsl_plugin(self, plugin_name=None):
|
32
|
+
"""Return a plugin class for integration with edsl.
|
33
|
+
|
34
|
+
Args:
|
35
|
+
plugin_name: Optional name of the specific plugin to return.
|
36
|
+
"""
|
37
|
+
|
38
|
+
@hookspec
|
39
|
+
def exports_to_namespace(self) -> Optional[Dict[str, Any]]:
|
40
|
+
"""
|
41
|
+
Define objects that should be exported to the global namespace.
|
42
|
+
|
43
|
+
Plugins can use this hook to specify objects (classes, functions, etc.)
|
44
|
+
that should be available for direct import from the edsl package.
|
45
|
+
|
46
|
+
Returns:
|
47
|
+
A dictionary mapping names to objects, or None if nothing to export.
|
48
|
+
Example: {'MyClass': MyClass, 'my_function': my_function}
|
49
|
+
"""
|
50
|
+
|
51
|
+
# Legacy conjure_plugin hook removed - all plugins should use edsl_plugin
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# edsl/plugins/plugin_host.py
|
2
|
+
from typing import Optional, List, Dict, Any
|
3
|
+
|
4
|
+
from .plugin_manager import EDSLPluginManager
|
5
|
+
from .exceptions import (
|
6
|
+
PluginException,
|
7
|
+
PluginNotFoundError,
|
8
|
+
PluginInstallationError,
|
9
|
+
GitHubRepoError,
|
10
|
+
InvalidPluginError,
|
11
|
+
PluginMethodError
|
12
|
+
)
|
13
|
+
|
14
|
+
# Singleton instance of the plugin manager for global access
|
15
|
+
_plugin_manager = None
|
16
|
+
|
17
|
+
def get_plugin_manager() -> EDSLPluginManager:
|
18
|
+
"""
|
19
|
+
Get or create the singleton plugin manager instance.
|
20
|
+
|
21
|
+
Returns:
|
22
|
+
The plugin manager instance
|
23
|
+
"""
|
24
|
+
global _plugin_manager
|
25
|
+
if _plugin_manager is None:
|
26
|
+
_plugin_manager = EDSLPluginManager()
|
27
|
+
return _plugin_manager
|
28
|
+
|
29
|
+
class PluginHost:
|
30
|
+
"""Host for plugins, providing method dispatch."""
|
31
|
+
|
32
|
+
def __init__(self, obj):
|
33
|
+
"""Initialize with the object plugins will operate on."""
|
34
|
+
self.obj = obj
|
35
|
+
self.plugin_manager = get_plugin_manager()
|
36
|
+
|
37
|
+
def __getattr__(self, name):
|
38
|
+
"""Route method calls to the appropriate plugin."""
|
39
|
+
method = self.plugin_manager.get_method(name)
|
40
|
+
|
41
|
+
if method:
|
42
|
+
def wrapper(*args, **kwargs):
|
43
|
+
# Pass the survey object as the first argument
|
44
|
+
return method(self.obj, *args, **kwargs)
|
45
|
+
|
46
|
+
return wrapper
|
47
|
+
|
48
|
+
# Fall back to remote plugin if not found locally
|
49
|
+
try:
|
50
|
+
from edsl.coop import RemotePlugin
|
51
|
+
|
52
|
+
def remote_wrapper(*args, **kwargs):
|
53
|
+
method_call = {
|
54
|
+
"method": name,
|
55
|
+
"args": [self.obj] + list(args),
|
56
|
+
"kwargs": kwargs
|
57
|
+
}
|
58
|
+
remote_plugin = RemotePlugin()
|
59
|
+
return remote_plugin(method_call)
|
60
|
+
|
61
|
+
return remote_wrapper
|
62
|
+
except (ImportError, AttributeError):
|
63
|
+
# If RemotePlugin is not available, raise AttributeError for the missing method
|
64
|
+
raise AttributeError(f"Method '{name}' not found in any plugin")
|
65
|
+
|
66
|
+
def list_available_methods(self):
|
67
|
+
"""List all available methods."""
|
68
|
+
return self.plugin_manager.list_methods()
|
69
|
+
|
70
|
+
@staticmethod
|
71
|
+
def install_from_github(github_url: str, branch: Optional[str] = None) -> List[str]:
|
72
|
+
"""
|
73
|
+
Install a plugin from a GitHub repository.
|
74
|
+
|
75
|
+
Args:
|
76
|
+
github_url: URL to the GitHub repository
|
77
|
+
branch: Optional branch to checkout (defaults to main/master)
|
78
|
+
|
79
|
+
Returns:
|
80
|
+
List of installed plugin names
|
81
|
+
|
82
|
+
Raises:
|
83
|
+
GitHubRepoError: If the URL is invalid or the repository cannot be accessed
|
84
|
+
PluginInstallationError: If the installation fails
|
85
|
+
InvalidPluginError: If the repository does not contain valid plugins
|
86
|
+
"""
|
87
|
+
pm = get_plugin_manager()
|
88
|
+
return pm.install_plugin_from_github(github_url, branch)
|
89
|
+
|
90
|
+
@staticmethod
|
91
|
+
def uninstall_plugin(plugin_name: str) -> bool:
|
92
|
+
"""
|
93
|
+
Uninstall a plugin by name.
|
94
|
+
|
95
|
+
Args:
|
96
|
+
plugin_name: Name of the plugin to uninstall
|
97
|
+
|
98
|
+
Returns:
|
99
|
+
True if uninstallation was successful
|
100
|
+
|
101
|
+
Raises:
|
102
|
+
PluginNotFoundError: If the plugin is not installed
|
103
|
+
PluginInstallationError: If uninstallation fails
|
104
|
+
"""
|
105
|
+
pm = get_plugin_manager()
|
106
|
+
return pm.uninstall_plugin(plugin_name)
|
107
|
+
|
108
|
+
@staticmethod
|
109
|
+
def list_plugins() -> Dict[str, Dict[str, Any]]:
|
110
|
+
"""
|
111
|
+
List all installed plugins with their details.
|
112
|
+
|
113
|
+
Returns:
|
114
|
+
Dictionary mapping plugin names to details
|
115
|
+
"""
|
116
|
+
pm = get_plugin_manager()
|
117
|
+
return pm.list_plugins()
|
118
|
+
|
119
|
+
@staticmethod
|
120
|
+
def get_exports() -> Dict[str, Any]:
|
121
|
+
"""
|
122
|
+
Get all objects that plugins export to the global namespace.
|
123
|
+
|
124
|
+
Returns:
|
125
|
+
Dictionary mapping names to exported objects
|
126
|
+
"""
|
127
|
+
pm = get_plugin_manager()
|
128
|
+
return pm.get_exports()
|