edsl 0.1.31.dev4__py3-none-any.whl → 0.1.33__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/Base.py +9 -3
- edsl/TemplateLoader.py +24 -0
- edsl/__init__.py +8 -3
- edsl/__version__.py +1 -1
- edsl/agents/Agent.py +40 -8
- edsl/agents/AgentList.py +43 -0
- edsl/agents/Invigilator.py +136 -221
- edsl/agents/InvigilatorBase.py +148 -59
- edsl/agents/{PromptConstructionMixin.py → PromptConstructor.py} +154 -85
- edsl/agents/__init__.py +1 -0
- edsl/auto/AutoStudy.py +117 -0
- edsl/auto/StageBase.py +230 -0
- edsl/auto/StageGenerateSurvey.py +178 -0
- edsl/auto/StageLabelQuestions.py +125 -0
- edsl/auto/StagePersona.py +61 -0
- edsl/auto/StagePersonaDimensionValueRanges.py +88 -0
- edsl/auto/StagePersonaDimensionValues.py +74 -0
- edsl/auto/StagePersonaDimensions.py +69 -0
- edsl/auto/StageQuestions.py +73 -0
- edsl/auto/SurveyCreatorPipeline.py +21 -0
- edsl/auto/utilities.py +224 -0
- edsl/config.py +48 -47
- edsl/conjure/Conjure.py +6 -0
- edsl/coop/PriceFetcher.py +58 -0
- edsl/coop/coop.py +50 -7
- edsl/data/Cache.py +35 -1
- edsl/data/CacheHandler.py +3 -4
- edsl/data_transfer_models.py +73 -38
- edsl/enums.py +8 -0
- edsl/exceptions/general.py +10 -8
- edsl/exceptions/language_models.py +25 -1
- edsl/exceptions/questions.py +62 -5
- edsl/exceptions/results.py +4 -0
- edsl/inference_services/AnthropicService.py +13 -11
- edsl/inference_services/AwsBedrock.py +112 -0
- edsl/inference_services/AzureAI.py +214 -0
- edsl/inference_services/DeepInfraService.py +4 -3
- edsl/inference_services/GoogleService.py +16 -12
- edsl/inference_services/GroqService.py +5 -4
- edsl/inference_services/InferenceServiceABC.py +58 -3
- edsl/inference_services/InferenceServicesCollection.py +13 -8
- edsl/inference_services/MistralAIService.py +120 -0
- edsl/inference_services/OllamaService.py +18 -0
- edsl/inference_services/OpenAIService.py +55 -56
- edsl/inference_services/TestService.py +80 -0
- edsl/inference_services/TogetherAIService.py +170 -0
- edsl/inference_services/models_available_cache.py +25 -0
- edsl/inference_services/registry.py +19 -1
- edsl/jobs/Answers.py +10 -12
- edsl/jobs/FailedQuestion.py +78 -0
- edsl/jobs/Jobs.py +137 -41
- edsl/jobs/buckets/BucketCollection.py +24 -15
- edsl/jobs/buckets/TokenBucket.py +105 -18
- edsl/jobs/interviews/Interview.py +393 -83
- edsl/jobs/interviews/{interview_exception_tracking.py → InterviewExceptionCollection.py} +22 -18
- edsl/jobs/interviews/InterviewExceptionEntry.py +167 -0
- edsl/jobs/runners/JobsRunnerAsyncio.py +152 -160
- edsl/jobs/runners/JobsRunnerStatus.py +331 -0
- edsl/jobs/tasks/QuestionTaskCreator.py +30 -23
- edsl/jobs/tasks/TaskCreators.py +1 -1
- edsl/jobs/tasks/TaskHistory.py +205 -126
- edsl/language_models/LanguageModel.py +297 -177
- edsl/language_models/ModelList.py +2 -2
- edsl/language_models/RegisterLanguageModelsMeta.py +14 -29
- edsl/language_models/fake_openai_call.py +15 -0
- edsl/language_models/fake_openai_service.py +61 -0
- edsl/language_models/registry.py +25 -8
- edsl/language_models/repair.py +0 -19
- edsl/language_models/utilities.py +61 -0
- edsl/notebooks/Notebook.py +20 -2
- edsl/prompts/Prompt.py +52 -2
- edsl/questions/AnswerValidatorMixin.py +23 -26
- edsl/questions/QuestionBase.py +330 -249
- edsl/questions/QuestionBaseGenMixin.py +133 -0
- edsl/questions/QuestionBasePromptsMixin.py +266 -0
- edsl/questions/QuestionBudget.py +99 -42
- edsl/questions/QuestionCheckBox.py +227 -36
- edsl/questions/QuestionExtract.py +98 -28
- edsl/questions/QuestionFreeText.py +47 -31
- edsl/questions/QuestionFunctional.py +7 -0
- edsl/questions/QuestionList.py +141 -23
- edsl/questions/QuestionMultipleChoice.py +159 -66
- edsl/questions/QuestionNumerical.py +88 -47
- edsl/questions/QuestionRank.py +182 -25
- edsl/questions/Quick.py +41 -0
- edsl/questions/RegisterQuestionsMeta.py +31 -12
- edsl/questions/ResponseValidatorABC.py +170 -0
- edsl/questions/__init__.py +3 -4
- edsl/questions/decorators.py +21 -0
- edsl/questions/derived/QuestionLikertFive.py +10 -5
- edsl/questions/derived/QuestionLinearScale.py +15 -2
- edsl/questions/derived/QuestionTopK.py +10 -1
- edsl/questions/derived/QuestionYesNo.py +24 -3
- edsl/questions/descriptors.py +43 -7
- edsl/questions/prompt_templates/question_budget.jinja +13 -0
- edsl/questions/prompt_templates/question_checkbox.jinja +32 -0
- edsl/questions/prompt_templates/question_extract.jinja +11 -0
- edsl/questions/prompt_templates/question_free_text.jinja +3 -0
- edsl/questions/prompt_templates/question_linear_scale.jinja +11 -0
- edsl/questions/prompt_templates/question_list.jinja +17 -0
- edsl/questions/prompt_templates/question_multiple_choice.jinja +33 -0
- edsl/questions/prompt_templates/question_numerical.jinja +37 -0
- edsl/questions/question_registry.py +6 -2
- edsl/questions/templates/__init__.py +0 -0
- edsl/questions/templates/budget/__init__.py +0 -0
- edsl/questions/templates/budget/answering_instructions.jinja +7 -0
- edsl/questions/templates/budget/question_presentation.jinja +7 -0
- edsl/questions/templates/checkbox/__init__.py +0 -0
- edsl/questions/templates/checkbox/answering_instructions.jinja +10 -0
- edsl/questions/templates/checkbox/question_presentation.jinja +22 -0
- edsl/questions/templates/extract/__init__.py +0 -0
- edsl/questions/templates/extract/answering_instructions.jinja +7 -0
- edsl/questions/templates/extract/question_presentation.jinja +1 -0
- edsl/questions/templates/free_text/__init__.py +0 -0
- edsl/questions/templates/free_text/answering_instructions.jinja +0 -0
- edsl/questions/templates/free_text/question_presentation.jinja +1 -0
- edsl/questions/templates/likert_five/__init__.py +0 -0
- edsl/questions/templates/likert_five/answering_instructions.jinja +10 -0
- edsl/questions/templates/likert_five/question_presentation.jinja +12 -0
- edsl/questions/templates/linear_scale/__init__.py +0 -0
- edsl/questions/templates/linear_scale/answering_instructions.jinja +5 -0
- edsl/questions/templates/linear_scale/question_presentation.jinja +5 -0
- edsl/questions/templates/list/__init__.py +0 -0
- edsl/questions/templates/list/answering_instructions.jinja +4 -0
- edsl/questions/templates/list/question_presentation.jinja +5 -0
- edsl/questions/templates/multiple_choice/__init__.py +0 -0
- edsl/questions/templates/multiple_choice/answering_instructions.jinja +9 -0
- edsl/questions/templates/multiple_choice/html.jinja +0 -0
- edsl/questions/templates/multiple_choice/question_presentation.jinja +12 -0
- edsl/questions/templates/numerical/__init__.py +0 -0
- edsl/questions/templates/numerical/answering_instructions.jinja +8 -0
- edsl/questions/templates/numerical/question_presentation.jinja +7 -0
- edsl/questions/templates/rank/__init__.py +0 -0
- edsl/questions/templates/rank/answering_instructions.jinja +11 -0
- edsl/questions/templates/rank/question_presentation.jinja +15 -0
- edsl/questions/templates/top_k/__init__.py +0 -0
- edsl/questions/templates/top_k/answering_instructions.jinja +8 -0
- edsl/questions/templates/top_k/question_presentation.jinja +22 -0
- edsl/questions/templates/yes_no/__init__.py +0 -0
- edsl/questions/templates/yes_no/answering_instructions.jinja +6 -0
- edsl/questions/templates/yes_no/question_presentation.jinja +12 -0
- edsl/results/Dataset.py +20 -0
- edsl/results/DatasetExportMixin.py +58 -30
- edsl/results/DatasetTree.py +145 -0
- edsl/results/Result.py +32 -5
- edsl/results/Results.py +135 -46
- edsl/results/ResultsDBMixin.py +3 -3
- edsl/results/Selector.py +118 -0
- edsl/results/tree_explore.py +115 -0
- edsl/scenarios/FileStore.py +71 -10
- edsl/scenarios/Scenario.py +109 -24
- edsl/scenarios/ScenarioImageMixin.py +2 -2
- edsl/scenarios/ScenarioList.py +546 -21
- edsl/scenarios/ScenarioListExportMixin.py +24 -4
- edsl/scenarios/ScenarioListPdfMixin.py +153 -4
- edsl/study/SnapShot.py +8 -1
- edsl/study/Study.py +32 -0
- edsl/surveys/Rule.py +15 -3
- edsl/surveys/RuleCollection.py +21 -5
- edsl/surveys/Survey.py +707 -298
- edsl/surveys/SurveyExportMixin.py +71 -9
- edsl/surveys/SurveyFlowVisualizationMixin.py +2 -1
- edsl/surveys/SurveyQualtricsImport.py +284 -0
- edsl/surveys/instructions/ChangeInstruction.py +47 -0
- edsl/surveys/instructions/Instruction.py +34 -0
- edsl/surveys/instructions/InstructionCollection.py +77 -0
- edsl/surveys/instructions/__init__.py +0 -0
- edsl/templates/error_reporting/base.html +24 -0
- edsl/templates/error_reporting/exceptions_by_model.html +35 -0
- edsl/templates/error_reporting/exceptions_by_question_name.html +17 -0
- edsl/templates/error_reporting/exceptions_by_type.html +17 -0
- edsl/templates/error_reporting/interview_details.html +116 -0
- edsl/templates/error_reporting/interviews.html +10 -0
- edsl/templates/error_reporting/overview.html +5 -0
- edsl/templates/error_reporting/performance_plot.html +2 -0
- edsl/templates/error_reporting/report.css +74 -0
- edsl/templates/error_reporting/report.html +118 -0
- edsl/templates/error_reporting/report.js +25 -0
- edsl/utilities/utilities.py +40 -1
- {edsl-0.1.31.dev4.dist-info → edsl-0.1.33.dist-info}/METADATA +8 -2
- edsl-0.1.33.dist-info/RECORD +295 -0
- edsl/jobs/interviews/InterviewTaskBuildingMixin.py +0 -271
- edsl/jobs/interviews/retry_management.py +0 -37
- edsl/jobs/runners/JobsRunnerStatusMixin.py +0 -303
- edsl/utilities/gcp_bucket/simple_example.py +0 -9
- edsl-0.1.31.dev4.dist-info/RECORD +0 -204
- {edsl-0.1.31.dev4.dist-info → edsl-0.1.33.dist-info}/LICENSE +0 -0
- {edsl-0.1.31.dev4.dist-info → edsl-0.1.33.dist-info}/WHEEL +0 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
<div class="question">question_name: {{ question }}</div>
|
2
|
+
|
3
|
+
|
4
|
+
<h2>Exception details</h2>
|
5
|
+
|
6
|
+
{% for exception_message in exceptions %}
|
7
|
+
<div class="exception-detail">
|
8
|
+
<div class="exception-header">
|
9
|
+
<span class="exception-exception">Exception: {{ exception_message.name }}</span>
|
10
|
+
<button class="toggle-btn">▼</button>
|
11
|
+
</div>
|
12
|
+
<div class="exception-content">
|
13
|
+
<table border="1">
|
14
|
+
<tr>
|
15
|
+
<th>Key</th>
|
16
|
+
<th>Value</th>
|
17
|
+
</tr>
|
18
|
+
<tr>
|
19
|
+
<td>Interview ID (index in results)</td>
|
20
|
+
<td>{{ index }}</td>
|
21
|
+
</tr>
|
22
|
+
<tr>
|
23
|
+
<td>Question name (question_name)</td>
|
24
|
+
<td>{{ question }}</td>
|
25
|
+
</tr>
|
26
|
+
|
27
|
+
<tr>
|
28
|
+
<td>Question type (question_type)</td>
|
29
|
+
<td>{{ exception_message.question_type }}</td>
|
30
|
+
</tr>
|
31
|
+
|
32
|
+
<tr>
|
33
|
+
<td>Human-readable question</td>
|
34
|
+
<td>{{ interview.survey.get_question(question).html(
|
35
|
+
scenario = interview.scenario,
|
36
|
+
agent = interview.agent,
|
37
|
+
answers = exception_message.answers)
|
38
|
+
|
39
|
+
}}</td>
|
40
|
+
</tr>
|
41
|
+
<tr>
|
42
|
+
<td>Scenario</td>
|
43
|
+
<td>{{ interview.scenario._repr_html_() }}</td>
|
44
|
+
</tr>
|
45
|
+
<tr>
|
46
|
+
<td>Agent</td>
|
47
|
+
<td>{{ interview.agent._repr_html_() }}</td>
|
48
|
+
</tr>
|
49
|
+
<tr>
|
50
|
+
<td>Model name</td>
|
51
|
+
<td>{{ interview.model.model }}</td>
|
52
|
+
</tr>
|
53
|
+
<tr>
|
54
|
+
<td>Inference service</td>
|
55
|
+
<td>{{ interview.model._inference_service_ }}</td>
|
56
|
+
</tr>
|
57
|
+
<tr>
|
58
|
+
<td>Model parameters</td>
|
59
|
+
<td>{{ interview.model._repr_html_() }}</td>
|
60
|
+
</tr>
|
61
|
+
<tr>
|
62
|
+
<td>User Prompt</td>
|
63
|
+
<td><pre>{{ exception_message.rendered_prompts['user_prompt'] }}</pre></td>
|
64
|
+
</tr>
|
65
|
+
<tr>
|
66
|
+
<td>System Prompt</td>
|
67
|
+
<td><pre>{{ exception_message.rendered_prompts['system_prompt'] }}</pre></td>
|
68
|
+
</tr>
|
69
|
+
<tr>
|
70
|
+
<td>Raw model response</td>
|
71
|
+
<td><pre>{{ exception_message.raw_model_response }}</pre>
|
72
|
+
</td>
|
73
|
+
</tr>
|
74
|
+
<tr>
|
75
|
+
<td>Generated token string (at {{ exception_message.key_sequence }}) in raw response</td>
|
76
|
+
<td><pre>{{ exception_message.generated_token_string }}</pre>
|
77
|
+
</td>
|
78
|
+
</tr>
|
79
|
+
<tr>
|
80
|
+
<td>Code to (likely) reproduce the error</td>
|
81
|
+
<td>
|
82
|
+
<textarea id="codeToCopy" rows="10" cols="90">{{ exception_message.code_to_reproduce }}</textarea>
|
83
|
+
<button onclick="copyCode()">Copy</button>
|
84
|
+
</td>
|
85
|
+
</tr>
|
86
|
+
|
87
|
+
</table>
|
88
|
+
|
89
|
+
|
90
|
+
{% if exception_message.exception.__class__.__name__ == 'QuestionAnswerValidationError' %}
|
91
|
+
<h3>Answer validation details</h3>
|
92
|
+
<table border="1">
|
93
|
+
<tr>
|
94
|
+
<th>Field</th>
|
95
|
+
<th>Value</th>
|
96
|
+
</tr>
|
97
|
+
{% for field, (explanation, open_tag, close_tag, value) in exception_message.exception.to_html_dict().items() %}
|
98
|
+
|
99
|
+
<tr>
|
100
|
+
<td>{{ field }}: ({{ explanation }})</td>
|
101
|
+
<td><{{open_tag}}> {{ value | escape }} <{{close_tag}}></td>
|
102
|
+
</tr>
|
103
|
+
{% endfor %}
|
104
|
+
</table>
|
105
|
+
{% endif %}
|
106
|
+
|
107
|
+
<div class="exception-time">Time: {{ exception_message.time }}</div>
|
108
|
+
<div class="exception-traceback">Traceback:
|
109
|
+
<text>
|
110
|
+
<pre>{{ exception_message.traceback }}</pre>
|
111
|
+
</text>
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
{% endfor %}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{% for index, interview in interviews.items() %}
|
2
|
+
{% if interview.exceptions != {} %}
|
3
|
+
<div class="interview">Interview: {{ index }} </div>
|
4
|
+
Model: {{ interview.model.model }}
|
5
|
+
<h1>Failing questions</h1>
|
6
|
+
{% endif %}
|
7
|
+
{% for question, exceptions in interview.exceptions.items() %}
|
8
|
+
{% include 'interview_details.html' %}
|
9
|
+
{% endfor %}
|
10
|
+
{% endfor %}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<h1>Overview</h1>
|
2
|
+
<p>There were {{ interviews|length }} total interview(s). An 'interview' is the result of one survey, taken by one agent, with one model, with one scenario.</p>
|
3
|
+
The number of interviews with any exceptions was {{ num_exceptions }}.</p>
|
4
|
+
<p>For advice on dealing with exceptions on Expected Parrot,
|
5
|
+
see <a href="https://docs.expectedparrot.com/en/latest/exceptions.html">here</a>.</p>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
body {
|
2
|
+
font-family: Arial, sans-serif;
|
3
|
+
line-height: 1.6;
|
4
|
+
background-color: #f9f9f9;
|
5
|
+
color: #333;
|
6
|
+
margin: 20px;
|
7
|
+
}
|
8
|
+
|
9
|
+
.interview {
|
10
|
+
font-size: 1.5em;
|
11
|
+
margin-bottom: 10px;
|
12
|
+
padding: 10px;
|
13
|
+
background-color: #e3f2fd;
|
14
|
+
border-left: 5px solid #2196f3;
|
15
|
+
}
|
16
|
+
|
17
|
+
.question {
|
18
|
+
font-size: 1.2em;
|
19
|
+
margin-bottom: 10px;
|
20
|
+
padding: 10px;
|
21
|
+
background-color: #fff9c4;
|
22
|
+
border-left: 5px solid #ffeb3b;
|
23
|
+
}
|
24
|
+
|
25
|
+
.exception-detail {
|
26
|
+
margin-bottom: 10px;
|
27
|
+
background-color: #ffebee;
|
28
|
+
border-left: 5px solid #f44336;
|
29
|
+
}
|
30
|
+
|
31
|
+
.exception-header {
|
32
|
+
padding: 10px;
|
33
|
+
cursor: pointer;
|
34
|
+
display: flex;
|
35
|
+
justify-content: space-between;
|
36
|
+
align-items: center;
|
37
|
+
}
|
38
|
+
|
39
|
+
.exception-content {
|
40
|
+
padding: 10px;
|
41
|
+
display: none;
|
42
|
+
}
|
43
|
+
|
44
|
+
.exception-content.show {
|
45
|
+
display: block;
|
46
|
+
}
|
47
|
+
|
48
|
+
.question-detail {
|
49
|
+
border: 3px solid black;
|
50
|
+
padding: 10px;
|
51
|
+
}
|
52
|
+
|
53
|
+
.exception-exception {
|
54
|
+
font-weight: bold;
|
55
|
+
color: #d32f2f;
|
56
|
+
}
|
57
|
+
|
58
|
+
.exception-time,
|
59
|
+
.exception-traceback {
|
60
|
+
font-style: italic;
|
61
|
+
color: #555;
|
62
|
+
}
|
63
|
+
|
64
|
+
.toggle-btn {
|
65
|
+
background: none;
|
66
|
+
border: none;
|
67
|
+
font-size: 1.2em;
|
68
|
+
cursor: pointer;
|
69
|
+
transition: transform 0.3s;
|
70
|
+
}
|
71
|
+
|
72
|
+
.toggle-btn.rotated {
|
73
|
+
transform: rotate(180deg);
|
74
|
+
}
|
@@ -0,0 +1,118 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>Exception Details</title>
|
7
|
+
<style>
|
8
|
+
{{ css }}
|
9
|
+
</style>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h1>Overview</h1>
|
13
|
+
<p>There were {{ interviews|length }} total interviews. The number of interviews with exceptions was {{ num_exceptions }}.</p>
|
14
|
+
<p>The models used were: {{ models_used }}.</p>
|
15
|
+
<p>For documentation on dealing with exceptions on Expected Parrot,
|
16
|
+
see <a href="https://docs.expectedparrot.com/en/latest/exceptions.html">here</a>.</p>
|
17
|
+
|
18
|
+
<h2>Exceptions by Type</h2>
|
19
|
+
<table>
|
20
|
+
<thead>
|
21
|
+
<tr>
|
22
|
+
<th>Exception Type</th>
|
23
|
+
<th>Number</th>
|
24
|
+
</tr>
|
25
|
+
</thead>
|
26
|
+
<tbody>
|
27
|
+
{% for exception_type, exceptions in exceptions_by_type.items() %}
|
28
|
+
<tr>
|
29
|
+
<td>{{ exception_type }}</td>
|
30
|
+
<td>{{ exceptions }}</td>
|
31
|
+
</tr>
|
32
|
+
{% endfor %}
|
33
|
+
</tbody>
|
34
|
+
</table>
|
35
|
+
|
36
|
+
|
37
|
+
<h2>Exceptions by Model</h2>
|
38
|
+
<table>
|
39
|
+
<thead>
|
40
|
+
<tr>
|
41
|
+
<th>Model</th>
|
42
|
+
<th>Number</th>
|
43
|
+
</tr>
|
44
|
+
</thead>
|
45
|
+
<tbody>
|
46
|
+
{% for model, exceptions in exceptions_by_model.items() %}
|
47
|
+
<tr>
|
48
|
+
<td>{{ model }}</td>
|
49
|
+
<td>{{ exceptions }}</td>
|
50
|
+
</tr>
|
51
|
+
{% endfor %}
|
52
|
+
</tbody>
|
53
|
+
</table>
|
54
|
+
|
55
|
+
|
56
|
+
<h2>Exceptions by Question Name</h2>
|
57
|
+
<table>
|
58
|
+
<thead>
|
59
|
+
<tr>
|
60
|
+
<th>Question Name</th>
|
61
|
+
<th>Number of Exceptions</th>
|
62
|
+
</tr>
|
63
|
+
</thead>
|
64
|
+
<tbody>
|
65
|
+
{% for question_name, exception_count in exceptions_by_question_name.items() %}
|
66
|
+
<tr>
|
67
|
+
<td>{{ question_name }}</td>
|
68
|
+
<td>{{ exception_count }}</td>
|
69
|
+
</tr>
|
70
|
+
{% endfor %}
|
71
|
+
</tbody>
|
72
|
+
</table>
|
73
|
+
|
74
|
+
|
75
|
+
{% for index, interview in interviews.items() %}
|
76
|
+
{% if interview.exceptions != {} %}
|
77
|
+
<div class="interview">Interview: {{ index }} </div>
|
78
|
+
<h1>Failing questions</h1>
|
79
|
+
{% endif %}
|
80
|
+
{% for question, exceptions in interview.exceptions.items() %}
|
81
|
+
<div class="question">question_name: {{ question }}</div>
|
82
|
+
|
83
|
+
<h2>Question</h2>
|
84
|
+
<div class="question-detail">
|
85
|
+
{{ interview.survey.get_question(question).html() }}
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<h2>Scenario</h2>
|
89
|
+
<div class="scenario">
|
90
|
+
{{ interview.scenario._repr_html_() }}
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<h2>Agent</h2>
|
94
|
+
<div class="agent">
|
95
|
+
{{ interview.agent._repr_html_() }}
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<h2>Model</h2>
|
99
|
+
<div class="model">
|
100
|
+
{{ interview.model._repr_html_() }}
|
101
|
+
</div>
|
102
|
+
|
103
|
+
<h2>Exception details</h2>
|
104
|
+
|
105
|
+
{% for exception_message in exceptions %}
|
106
|
+
<div class="exception-detail">
|
107
|
+
<div class="exception-exception">Exception: {{ exception_message.exception }}</div>
|
108
|
+
<div class="exception-time">Time: {{ exception_message.time }}</div>
|
109
|
+
<div class="exception-traceback">Traceback: <pre>{{ exception_message.traceback }} </pre></div>
|
110
|
+
</div>
|
111
|
+
{% endfor %}
|
112
|
+
{% endfor %}
|
113
|
+
{% endfor %}
|
114
|
+
|
115
|
+
<h1>Performance Plot</h1>
|
116
|
+
{{ performance_plot_html }}
|
117
|
+
</body>
|
118
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function() {
|
2
|
+
const collapsibleSections = document.querySelectorAll('.exception-detail, .raw-model-response');
|
3
|
+
|
4
|
+
collapsibleSections.forEach(section => {
|
5
|
+
const header = section.querySelector('.exception-header, .response-header');
|
6
|
+
const content = section.querySelector('.exception-content, .response-content');
|
7
|
+
const toggleBtn = section.querySelector('.toggle-btn');
|
8
|
+
|
9
|
+
header.addEventListener('click', function() {
|
10
|
+
content.classList.toggle('show');
|
11
|
+
toggleBtn.classList.toggle('rotated');
|
12
|
+
});
|
13
|
+
});
|
14
|
+
|
15
|
+
});
|
16
|
+
|
17
|
+
function copyCode() {
|
18
|
+
const textarea = document.getElementById('codeToCopy');
|
19
|
+
textarea.select();
|
20
|
+
textarea.setSelectionRange(0, 99999); // For mobile devices
|
21
|
+
document.execCommand("copy");
|
22
|
+
|
23
|
+
// Optionally, you can display an alert or change the button text to indicate success
|
24
|
+
alert("Code copied to clipboard!");
|
25
|
+
}
|
edsl/utilities/utilities.py
CHANGED
@@ -20,6 +20,14 @@ from html import escape
|
|
20
20
|
from typing import Callable, Union
|
21
21
|
|
22
22
|
|
23
|
+
class CustomEncoder(json.JSONEncoder):
|
24
|
+
def default(self, obj):
|
25
|
+
try:
|
26
|
+
return json.JSONEncoder.default(self, obj)
|
27
|
+
except TypeError:
|
28
|
+
return str(obj)
|
29
|
+
|
30
|
+
|
23
31
|
def time_it(func):
|
24
32
|
@wraps(func)
|
25
33
|
def wrapper(*args, **kwargs):
|
@@ -61,6 +69,37 @@ def extract_json_from_string(text):
|
|
61
69
|
return None
|
62
70
|
|
63
71
|
|
72
|
+
def fix_partial_correct_response(text: str) -> dict:
|
73
|
+
# Find the start position of the key "answer"
|
74
|
+
answer_key_start = text.find('"answer"')
|
75
|
+
|
76
|
+
if answer_key_start == -1:
|
77
|
+
return {"error": "No 'answer' key found in the text"}
|
78
|
+
|
79
|
+
# Define regex to find the complete JSON object starting with "answer"
|
80
|
+
json_pattern = r'(\{[^\{\}]*"answer"[^\{\}]*\})'
|
81
|
+
match = re.search(json_pattern, text)
|
82
|
+
|
83
|
+
if not match:
|
84
|
+
return {"error": "No valid JSON object found"}
|
85
|
+
|
86
|
+
# Extract the matched JSON object
|
87
|
+
json_object = match.group(0)
|
88
|
+
|
89
|
+
# Find the start and stop positions of the JSON object in the original text
|
90
|
+
start_pos = text.find(json_object)
|
91
|
+
stop_pos = start_pos + len(json_object)
|
92
|
+
|
93
|
+
# Parse the JSON object to validate it
|
94
|
+
try:
|
95
|
+
parsed_json = json.loads(json_object)
|
96
|
+
except json.JSONDecodeError:
|
97
|
+
return {"error": "Failed to parse JSON object"}
|
98
|
+
|
99
|
+
# Return the result as a dictionary with positions
|
100
|
+
return {"start": start_pos, "stop": stop_pos, "extracted_json": json_object}
|
101
|
+
|
102
|
+
|
64
103
|
def clean_json(bad_json_str):
|
65
104
|
"""
|
66
105
|
Clean JSON string by replacing single quotes with double quotes
|
@@ -93,7 +132,7 @@ def data_to_html(data, replace_new_lines=False):
|
|
93
132
|
from pygments.formatters import HtmlFormatter
|
94
133
|
from IPython.display import HTML
|
95
134
|
|
96
|
-
json_str = json.dumps(data, indent=4)
|
135
|
+
json_str = json.dumps(data, indent=4, cls=CustomEncoder)
|
97
136
|
formatted_json = highlight(
|
98
137
|
json_str,
|
99
138
|
JsonLexer(),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: edsl
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.33
|
4
4
|
Summary: Create and analyze LLM-based surveys
|
5
5
|
Home-page: https://www.expectedparrot.com/
|
6
6
|
License: MIT
|
@@ -18,15 +18,20 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
18
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
19
19
|
Requires-Dist: aiohttp (>=3.9.1,<4.0.0)
|
20
20
|
Requires-Dist: anthropic (>=0.23.1,<0.24.0)
|
21
|
+
Requires-Dist: azure-ai-inference (>=1.0.0b3,<2.0.0)
|
21
22
|
Requires-Dist: black[jupyter] (>=24.4.2,<25.0.0)
|
23
|
+
Requires-Dist: boto3 (>=1.34.161,<2.0.0)
|
22
24
|
Requires-Dist: groq (>=0.9.0,<0.10.0)
|
23
25
|
Requires-Dist: jinja2 (>=3.1.2,<4.0.0)
|
26
|
+
Requires-Dist: json-repair (>=0.28.4,<0.29.0)
|
24
27
|
Requires-Dist: jupyter (>=1.0.0,<2.0.0)
|
25
28
|
Requires-Dist: markdown2 (>=2.4.11,<3.0.0)
|
26
29
|
Requires-Dist: matplotlib (>=3.8,<3.9)
|
30
|
+
Requires-Dist: mistralai (>=1.0.2,<2.0.0)
|
27
31
|
Requires-Dist: nest-asyncio (>=1.5.9,<2.0.0)
|
28
32
|
Requires-Dist: numpy (>=1.22,<2.0)
|
29
33
|
Requires-Dist: openai (>=1.4.0,<2.0.0)
|
34
|
+
Requires-Dist: openpyxl (>=3.1.5,<4.0.0)
|
30
35
|
Requires-Dist: pandas (>=2.1.4,<3.0.0)
|
31
36
|
Requires-Dist: pydot (>=2.0.0,<3.0.0)
|
32
37
|
Requires-Dist: pygments (>=2.17.2,<3.0.0)
|
@@ -40,6 +45,7 @@ Requires-Dist: setuptools (<72.0)
|
|
40
45
|
Requires-Dist: simpleeval (>=0.9.13,<0.10.0)
|
41
46
|
Requires-Dist: sqlalchemy (>=2.0.23,<3.0.0)
|
42
47
|
Requires-Dist: tenacity (>=8.2.3,<9.0.0)
|
48
|
+
Requires-Dist: urllib3 (>=1.25.4,<1.27)
|
43
49
|
Project-URL: Documentation, https://docs.expectedparrot.com
|
44
50
|
Description-Content-Type: text/markdown
|
45
51
|
|
@@ -64,7 +70,7 @@ A quick example:
|
|
64
70
|
|
65
71
|
```python
|
66
72
|
# Import a question type
|
67
|
-
from edsl
|
73
|
+
from edsl import QuestionMultipleChoice
|
68
74
|
|
69
75
|
# Construct a question using the question type template
|
70
76
|
q = QuestionMultipleChoice(
|