edsl 0.1.35__py3-none-any.whl → 0.1.36.dev1__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/__version__.py +1 -1
- edsl/agents/Agent.py +38 -14
- edsl/agents/Invigilator.py +2 -1
- edsl/agents/PromptConstructor.py +6 -51
- edsl/jobs/Jobs.py +146 -48
- edsl/jobs/interviews/Interview.py +42 -15
- edsl/jobs/interviews/InterviewExceptionEntry.py +0 -3
- edsl/jobs/tasks/QuestionTaskCreator.py +1 -5
- edsl/language_models/LanguageModel.py +3 -0
- edsl/prompts/Prompt.py +24 -38
- edsl/prompts/__init__.py +1 -1
- edsl/questions/QuestionBasePromptsMixin.py +18 -18
- edsl/questions/descriptors.py +24 -24
- {edsl-0.1.35.dist-info → edsl-0.1.36.dev1.dist-info}/METADATA +1 -1
- {edsl-0.1.35.dist-info → edsl-0.1.36.dev1.dist-info}/RECORD +17 -34
- edsl/jobs/FailedQuestion.py +0 -78
- edsl/jobs/interviews/InterviewStatusMixin.py +0 -33
- edsl/jobs/tasks/task_management.py +0 -13
- edsl/prompts/QuestionInstructionsBase.py +0 -10
- edsl/prompts/library/agent_instructions.py +0 -38
- edsl/prompts/library/agent_persona.py +0 -21
- edsl/prompts/library/question_budget.py +0 -30
- edsl/prompts/library/question_checkbox.py +0 -38
- edsl/prompts/library/question_extract.py +0 -23
- edsl/prompts/library/question_freetext.py +0 -18
- edsl/prompts/library/question_linear_scale.py +0 -24
- edsl/prompts/library/question_list.py +0 -26
- edsl/prompts/library/question_multiple_choice.py +0 -54
- edsl/prompts/library/question_numerical.py +0 -35
- edsl/prompts/library/question_rank.py +0 -25
- edsl/prompts/prompt_config.py +0 -37
- edsl/prompts/registry.py +0 -202
- {edsl-0.1.35.dist-info → edsl-0.1.36.dev1.dist-info}/LICENSE +0 -0
- {edsl-0.1.35.dist-info → edsl-0.1.36.dev1.dist-info}/WHEEL +0 -0
edsl/prompts/Prompt.py
CHANGED
@@ -17,25 +17,23 @@ class PreserveUndefined(Undefined):
|
|
17
17
|
|
18
18
|
|
19
19
|
from edsl.exceptions.prompts import TemplateRenderError
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
|
21
|
+
# from edsl.prompts.prompt_config import (
|
22
|
+
# C2A,
|
23
|
+
# names_to_component_types,
|
24
|
+
# ComponentTypes,
|
25
|
+
# NEGATIVE_INFINITY,
|
26
|
+
# )
|
27
|
+
# from edsl.prompts.registry import RegisterPromptsMeta
|
27
28
|
from edsl.Base import PersistenceMixin, RichPrintingMixin
|
28
29
|
|
29
30
|
MAX_NESTING = 100
|
30
31
|
|
31
32
|
|
32
|
-
class
|
33
|
-
PersistenceMixin, RichPrintingMixin, ABC, metaclass=RegisterPromptsMeta
|
34
|
-
):
|
33
|
+
class Prompt(PersistenceMixin, RichPrintingMixin):
|
35
34
|
"""Class for creating a prompt to be used in a survey."""
|
36
35
|
|
37
36
|
default_instructions: Optional[str] = "Do good things, friendly LLM!"
|
38
|
-
component_type = ComponentTypes.GENERIC
|
39
37
|
|
40
38
|
def _repr_html_(self):
|
41
39
|
"""Return an HTML representation of the Prompt."""
|
@@ -111,12 +109,6 @@ class PromptBase(
|
|
111
109
|
with open(folder_path.joinpath(file_name), "r") as f:
|
112
110
|
text = f.read()
|
113
111
|
return cls(text=text)
|
114
|
-
# Resolve the path to get the absolute path
|
115
|
-
# absolute_path = folder_path.resolve()
|
116
|
-
# env = Environment(loader=FileSystemLoader(absolute_path))
|
117
|
-
# template = env.get_template(file_name)
|
118
|
-
# rendered_text = template.render({})
|
119
|
-
# return cls(text=rendered_text)
|
120
112
|
|
121
113
|
@property
|
122
114
|
def text(self):
|
@@ -281,6 +273,7 @@ class PromptBase(
|
|
281
273
|
try:
|
282
274
|
previous_text = None
|
283
275
|
for _ in range(MAX_NESTING):
|
276
|
+
# breakpoint()
|
284
277
|
rendered_text = env.from_string(text).render(
|
285
278
|
primary_replacement, **additional_replacements
|
286
279
|
)
|
@@ -323,9 +316,8 @@ class PromptBase(
|
|
323
316
|
Prompt(text=\"""Hello, {{person}}\""")
|
324
317
|
|
325
318
|
"""
|
326
|
-
class_name = data["class_name"]
|
327
|
-
|
328
|
-
return cls(text=data["text"])
|
319
|
+
# class_name = data["class_name"]
|
320
|
+
return Prompt(text=data["text"])
|
329
321
|
|
330
322
|
def rich_print(self):
|
331
323
|
"""Display an object as a table."""
|
@@ -346,27 +338,21 @@ class PromptBase(
|
|
346
338
|
return cls(cls.default_instructions)
|
347
339
|
|
348
340
|
|
349
|
-
class Prompt(PromptBase):
|
350
|
-
"""A prompt to be used in a survey."""
|
351
|
-
|
352
|
-
component_type = ComponentTypes.GENERIC
|
353
|
-
|
354
|
-
|
355
341
|
if __name__ == "__main__":
|
356
342
|
print("Running doctests...")
|
357
343
|
import doctest
|
358
344
|
|
359
345
|
doctest.testmod()
|
360
346
|
|
361
|
-
from edsl.prompts.library.question_multiple_choice import *
|
362
|
-
from edsl.prompts.library.agent_instructions import *
|
363
|
-
from edsl.prompts.library.agent_persona import *
|
364
|
-
|
365
|
-
from edsl.prompts.library.question_budget import *
|
366
|
-
from edsl.prompts.library.question_checkbox import *
|
367
|
-
from edsl.prompts.library.question_freetext import *
|
368
|
-
from edsl.prompts.library.question_linear_scale import *
|
369
|
-
from edsl.prompts.library.question_numerical import *
|
370
|
-
from edsl.prompts.library.question_rank import *
|
371
|
-
from edsl.prompts.library.question_extract import *
|
372
|
-
from edsl.prompts.library.question_list import *
|
347
|
+
# from edsl.prompts.library.question_multiple_choice import *
|
348
|
+
# from edsl.prompts.library.agent_instructions import *
|
349
|
+
# from edsl.prompts.library.agent_persona import *
|
350
|
+
|
351
|
+
# from edsl.prompts.library.question_budget import *
|
352
|
+
# from edsl.prompts.library.question_checkbox import *
|
353
|
+
# from edsl.prompts.library.question_freetext import *
|
354
|
+
# from edsl.prompts.library.question_linear_scale import *
|
355
|
+
# from edsl.prompts.library.question_numerical import *
|
356
|
+
# from edsl.prompts.library.question_rank import *
|
357
|
+
# from edsl.prompts.library.question_extract import *
|
358
|
+
# from edsl.prompts.library.question_list import *
|
edsl/prompts/__init__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
from edsl.prompts.registry import get_classes
|
1
|
+
# from edsl.prompts.registry import get_classes
|
2
2
|
from edsl.prompts.Prompt import Prompt
|
@@ -38,29 +38,29 @@ class QuestionBasePromptsMixin:
|
|
38
38
|
# ) as file:
|
39
39
|
# return file.read()
|
40
40
|
|
41
|
-
@classmethod
|
42
|
-
def applicable_prompts(
|
43
|
-
|
44
|
-
) -> list[type["PromptBase"]]:
|
45
|
-
|
41
|
+
# @classmethod
|
42
|
+
# def applicable_prompts(
|
43
|
+
# cls, model: Optional[str] = None
|
44
|
+
# ) -> list[type["PromptBase"]]:
|
45
|
+
# """Get the prompts that are applicable to the question type.
|
46
46
|
|
47
|
-
|
47
|
+
# :param model: The language model to use.
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
# >>> from edsl.questions import QuestionFreeText
|
50
|
+
# >>> QuestionFreeText.applicable_prompts()
|
51
|
+
# [<class 'edsl.prompts.library.question_freetext.FreeText'>]
|
52
52
|
|
53
|
-
|
53
|
+
# :param model: The language model to use. If None, assumes does not matter.
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
# """
|
56
|
+
# from edsl.prompts.registry import get_classes as prompt_lookup
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
# applicable_prompts = prompt_lookup(
|
59
|
+
# component_type="question_instructions",
|
60
|
+
# question_type=cls.question_type,
|
61
|
+
# model=model,
|
62
|
+
# )
|
63
|
+
# return applicable_prompts
|
64
64
|
|
65
65
|
@property
|
66
66
|
def model_instructions(self) -> dict:
|
edsl/questions/descriptors.py
CHANGED
@@ -54,32 +54,32 @@ class BaseDescriptor(ABC):
|
|
54
54
|
def __set__(self, instance, value: Any) -> None:
|
55
55
|
"""Set the value of the attribute."""
|
56
56
|
self.validate(value, instance)
|
57
|
-
from edsl.prompts.registry import get_classes
|
57
|
+
# from edsl.prompts.registry import get_classes
|
58
58
|
|
59
59
|
instance.__dict__[self.name] = value
|
60
|
-
if self.name == "_instructions":
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
60
|
+
# if self.name == "_instructions":
|
61
|
+
# instructions = value
|
62
|
+
# if value is not None:
|
63
|
+
# instance.__dict__[self.name] = instructions
|
64
|
+
# instance.set_instructions = True
|
65
|
+
# else:
|
66
|
+
# potential_prompt_classes = get_classes(
|
67
|
+
# question_type=instance.question_type
|
68
|
+
# )
|
69
|
+
# if len(potential_prompt_classes) > 0:
|
70
|
+
# instructions = potential_prompt_classes[0]().text
|
71
|
+
# instance.__dict__[self.name] = instructions
|
72
|
+
# instance.set_instructions = False
|
73
|
+
# else:
|
74
|
+
# if not hasattr(instance, "default_instructions"):
|
75
|
+
# raise Exception(
|
76
|
+
# "No default instructions found and no matching prompts!"
|
77
|
+
# )
|
78
|
+
# instructions = instance.default_instructions
|
79
|
+
# instance.__dict__[self.name] = instructions
|
80
|
+
# instance.set_instructions = False
|
81
|
+
|
82
|
+
# instance.set_instructions = value != instance.default_instructions
|
83
83
|
|
84
84
|
def __set_name__(self, owner, name: str) -> None:
|
85
85
|
"""Set the name of the attribute."""
|
@@ -2,12 +2,12 @@ edsl/Base.py,sha256=wdFpHWlQlGNL4XfOmYA0AK9YupMDxK3G7mDHCQp60o4,9295
|
|
2
2
|
edsl/BaseDiff.py,sha256=RoVEh52UJs22yMa7k7jv8se01G62jJNWnBzaZngo-Ug,8260
|
3
3
|
edsl/TemplateLoader.py,sha256=sDBlSMt7EfOduM7w3h6v03gvh_Rzn9hVrlS-iLSQdZA,849
|
4
4
|
edsl/__init__.py,sha256=UZcx9RHSi3Dslh2lWvCOeppdMW9Xzw_YLs-kFaNW1MU,1770
|
5
|
-
edsl/__version__.py,sha256=
|
6
|
-
edsl/agents/Agent.py,sha256=
|
5
|
+
edsl/__version__.py,sha256=yS7SjTPwUGI_RFJspMUKx7G1-n8hVfU0zsPUxn0IprE,28
|
6
|
+
edsl/agents/Agent.py,sha256=dG3SbCm4IpHpObcWm-OejfYHtVXa5NlxGKYKOc-dUxQ,29311
|
7
7
|
edsl/agents/AgentList.py,sha256=qo8VK3Ov0YOSbsBcHmlwLZBH81CcDfy5IEcx9AVH78M,10963
|
8
|
-
edsl/agents/Invigilator.py,sha256=
|
8
|
+
edsl/agents/Invigilator.py,sha256=m4T-z4aNCGd4LKjLXVNI2VszYW-pQeScfcFAxkb0pWc,9080
|
9
9
|
edsl/agents/InvigilatorBase.py,sha256=qIdAiriXAbnJH_SN9w2UAXHcDgQvk8Ar3QerKFjtPwM,10341
|
10
|
-
edsl/agents/PromptConstructor.py,sha256=
|
10
|
+
edsl/agents/PromptConstructor.py,sha256=1k_Xni5T_ZB5_3hGFLzYiD1fPK4911IIatVHz9qD1s8,13006
|
11
11
|
edsl/agents/__init__.py,sha256=B1dWfV4QWOo8cc2KeuetdFGeNhZ8XHc0Q8YhQW9k7BE,136
|
12
12
|
edsl/agents/descriptors.py,sha256=m8ND3-2-JbgNX1HGakBNLIeemwsgYa1mQxYO9GW33hw,2934
|
13
13
|
edsl/agents/prompt_helpers.py,sha256=rHUxM_F0kCOkJmnhCyK-amFKViAYvpRRLD8LHFLGqQw,5023
|
@@ -87,34 +87,31 @@ edsl/inference_services/rate_limits_cache.py,sha256=HYslviz7mxF9U4CUTPAkoyBsiXjS
|
|
87
87
|
edsl/inference_services/registry.py,sha256=CwdaQ-A5PTb5lFKMQdOfl8IqCw2SVJ8HlC-_2uZf11k,1141
|
88
88
|
edsl/inference_services/write_available.py,sha256=NNwhATlaMp8IYY635MSx-oYxt5X15acjAfaqYCo_I1Y,285
|
89
89
|
edsl/jobs/Answers.py,sha256=c4LpigQjdnMr7iJu8571C4FggGPVudfT7hbJgmgKW40,1821
|
90
|
-
edsl/jobs/
|
91
|
-
edsl/jobs/Jobs.py,sha256=oryxhrBuXs9Ba8mt5BSIjX3gT37hdzothL5xH0ygrkU,37227
|
90
|
+
edsl/jobs/Jobs.py,sha256=t37-_8PemRGfQABTyuXPYW53-4sevPWkvF6qeq8oLxc,40183
|
92
91
|
edsl/jobs/__init__.py,sha256=aKuAyd_GoalGj-k7djOoVwEbFUE2XLPlikXaA1_8yAg,32
|
93
92
|
edsl/jobs/buckets/BucketCollection.py,sha256=11CRisE1WAPcAlI3YJK3DVvu0AqSvv8KskXo4Q1waSk,2286
|
94
93
|
edsl/jobs/buckets/ModelBuckets.py,sha256=hxw_tzc0V42CiB7mh5jIxlgwDVJ-zFZhlLtKrHEg8ho,2419
|
95
94
|
edsl/jobs/buckets/TokenBucket.py,sha256=7fG4omzTcj5xC2iJLO9bfBkdAGs6Y3weXzlA3BgPr0E,9090
|
96
|
-
edsl/jobs/interviews/Interview.py,sha256=
|
95
|
+
edsl/jobs/interviews/Interview.py,sha256=epaxVw53gplPpDpj1n_ahL3Pibs8vqCasF9QjXve1do,24963
|
97
96
|
edsl/jobs/interviews/InterviewExceptionCollection.py,sha256=Ez8BCZUD3odqoY9h-gzYKKM8yaHynQ-eYw2uMDh7t98,3279
|
98
|
-
edsl/jobs/interviews/InterviewExceptionEntry.py,sha256=
|
97
|
+
edsl/jobs/interviews/InterviewExceptionEntry.py,sha256=2ZQOrhoHvfZJx9p357BQUZCfMXGkuU4xITYLyFGK9sg,4806
|
99
98
|
edsl/jobs/interviews/InterviewStatistic.py,sha256=hY5d2EkIJ96NilPpZAvZZzZoxLXM7ss3xx5MIcKtTPs,1856
|
100
99
|
edsl/jobs/interviews/InterviewStatisticsCollection.py,sha256=_ZZ0fnZBQiIywP9Q_wWjpWhlfcPe2cn32GKut10t5RI,788
|
101
100
|
edsl/jobs/interviews/InterviewStatusDictionary.py,sha256=MSyys4hOWe1d8gfsUvAPbcKrs8YiPnz8jpufBSJL7SU,2485
|
102
101
|
edsl/jobs/interviews/InterviewStatusLog.py,sha256=6u0F8gf5tha39VQL-IK_QPkCsQAYVOx_IesX7TDDX_A,3252
|
103
|
-
edsl/jobs/interviews/InterviewStatusMixin.py,sha256=VV0Pel-crUsLoGpTifeIIkXsLGj0bfuO--UtpRnH-dU,1251
|
104
102
|
edsl/jobs/interviews/ReportErrors.py,sha256=RSzDU2rWwtjfztj7sqaMab0quCiY-X2bG3AEOxhTim8,1745
|
105
103
|
edsl/jobs/interviews/interview_status_enum.py,sha256=KJ-1yLAHdX-p8TiFnM0M3v1tnBwkq4aMCuBX6-ytrI8,229
|
106
104
|
edsl/jobs/runners/JobsRunnerAsyncio.py,sha256=SXWFTgTYQzqIaBjPQ2mRrxR3aGFMQyw2eD9wX8tZNkQ,12850
|
107
105
|
edsl/jobs/runners/JobsRunnerStatus.py,sha256=4eCh9sRpswGdKeSMW9pCGCAjJZa-OrWUPI7tsxIy_g4,12112
|
108
106
|
edsl/jobs/runners/JobsRunnerStatusData.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
109
|
-
edsl/jobs/tasks/QuestionTaskCreator.py,sha256=
|
107
|
+
edsl/jobs/tasks/QuestionTaskCreator.py,sha256=K-xATHIXMWPTMOnms5UDW30eTIlIfebf7oOEfwrh1ME,10072
|
110
108
|
edsl/jobs/tasks/TaskCreators.py,sha256=XqAbNU33378Z4PQncokbfJwnKt3KHR9aqa5fKYRDpfg,2694
|
111
109
|
edsl/jobs/tasks/TaskHistory.py,sha256=xRSo22ipyUSJ15w_k2Jc3dZ04VLwft8zfvm3smAIYrA,14227
|
112
110
|
edsl/jobs/tasks/TaskStatusLog.py,sha256=bqH36a32F12fjX-M-4lNOhHaK2-WLFzKE-r0PxZPRjI,546
|
113
|
-
edsl/jobs/tasks/task_management.py,sha256=KMToZuXzMlnHRHUF_VHL0-lHMTGhklf2GHVuwEEHtzA,301
|
114
111
|
edsl/jobs/tasks/task_status_enum.py,sha256=DOyrz61YlIS8R1W7izJNphcLrJ7I_ReUlfdRmk23h0Q,5333
|
115
112
|
edsl/jobs/tokens/InterviewTokenUsage.py,sha256=u_6-IHpGFwZ6qMEXr24-jyLVUSSp4dSs_4iAZsBv7O4,1100
|
116
113
|
edsl/jobs/tokens/TokenUsage.py,sha256=odj2-wDNEbHl9noyFAQ0DSKV0D9cv3aDOpmXufKZ8O4,1323
|
117
|
-
edsl/language_models/LanguageModel.py,sha256=
|
114
|
+
edsl/language_models/LanguageModel.py,sha256=7kXi42P6m8kku-_UxstTapIzI-3N8a3Ks3_IRJEgxpc,25395
|
118
115
|
edsl/language_models/ModelList.py,sha256=GhjRV7y1jRvP_Yjgwv6fxksTVb8sFPBiiRRfdqW-hgg,2852
|
119
116
|
edsl/language_models/RegisterLanguageModelsMeta.py,sha256=eMtBSAnlRnC4c-0_o2QkSNyzv-uAce4BEGMXq2PLj2E,7523
|
120
117
|
edsl/language_models/__init__.py,sha256=bvY7Gy6VkX1gSbNkRbGPS-M1kUnb0EohL0FSagaEaTs,109
|
@@ -126,26 +123,12 @@ edsl/language_models/unused/ReplicateBase.py,sha256=J1oqf7mEyyKhRwNUomnptVqAsVFY
|
|
126
123
|
edsl/language_models/utilities.py,sha256=GWON2ahCpB-_-hhqmQ5Yi7_rKB4cd8GlucWuq6EnGZQ,2280
|
127
124
|
edsl/notebooks/Notebook.py,sha256=xi9xkxmkQ6-DwhqbjjMLpYKB0VJV20AtwEonJ6mnqjo,7739
|
128
125
|
edsl/notebooks/__init__.py,sha256=VNUA3nNq04slWNbYaNrzOhQJu3AZANpvBniyCJSzJ7U,45
|
129
|
-
edsl/prompts/Prompt.py,sha256=
|
130
|
-
edsl/prompts/
|
131
|
-
edsl/prompts/__init__.py,sha256=Z0ywyJfnV0i-sR1SCdK4mHhgECT5cXpHVA-pKuBTifc,85
|
132
|
-
edsl/prompts/library/agent_instructions.py,sha256=_2kCDYvh3ZOF72VvcIH5jhmHjM6AAgQdkWrHvR52Yhg,1100
|
133
|
-
edsl/prompts/library/agent_persona.py,sha256=jEl1LjlOP67vOPiRW0S_-TRMz3n6Tp3mPRvltM2r2_k,516
|
134
|
-
edsl/prompts/library/question_budget.py,sha256=RAc7pmQRbs_-xksU52yYl8iqJ7HejPY4sQOlCSQLGWs,1190
|
135
|
-
edsl/prompts/library/question_checkbox.py,sha256=NIGcdnfkJ8_XbGsdq9toeWA_phQVx5FIBOAe0mReXJw,1462
|
136
|
-
edsl/prompts/library/question_extract.py,sha256=QxNiNBjUk25Ss_Pax0iDgmgTYXEycpWJk2z0evmqsP0,775
|
137
|
-
edsl/prompts/library/question_freetext.py,sha256=_I7hcniRfVwmZr2wXAasfbZ0GTu41ZIKfcoixGhzZUI,510
|
138
|
-
edsl/prompts/library/question_linear_scale.py,sha256=sQpgjSvqJU-uQti-DCxOzLzj05ENkpyxmH-qTFq39x0,778
|
139
|
-
edsl/prompts/library/question_list.py,sha256=KYi3gtcWyDzRLyAb2-k7C-QJ9TAfbLGPkWVvVmdT6xg,731
|
140
|
-
edsl/prompts/library/question_multiple_choice.py,sha256=_2LUM9bOInODoFyaTrKfMkcb5Z7RDj_odq5iAnD7KVQ,1617
|
141
|
-
edsl/prompts/library/question_numerical.py,sha256=ZdWnDbTU0gQdMMqcWHw_eIHEZkJ_kuE-XWrnCYFR07w,1456
|
142
|
-
edsl/prompts/library/question_rank.py,sha256=WDgXyph0EKWJrSgsW2eqcx3xdU-WA1LEvB2jvQFOQ8s,882
|
143
|
-
edsl/prompts/prompt_config.py,sha256=O3Y5EvBsCeKs9m9IjXiRXOcHWlWvQV0yqsNb2oSR1ow,974
|
144
|
-
edsl/prompts/registry.py,sha256=XOsqGsvNOmIG83jqoszqI72yNZkkszKR4FrEhwSzj_Q,8093
|
126
|
+
edsl/prompts/Prompt.py,sha256=qZCFj_cu2Gu23VLe0TQ-HZ42n3DOk1fQyj8Wa_boFms,11382
|
127
|
+
edsl/prompts/__init__.py,sha256=wrtkH7JW72U93_pnmTvqQx_NoadH5OPRNfrZ5AaD7Co,87
|
145
128
|
edsl/questions/AnswerValidatorMixin.py,sha256=t_ABep50KP02GSc48Y8VAEjp35drVOngfrWXU5aVhgk,11505
|
146
129
|
edsl/questions/QuestionBase.py,sha256=QsdYFHnWYh04JpCdx3o3WGgohBfE5X_7idQRRYrx_SA,21169
|
147
130
|
edsl/questions/QuestionBaseGenMixin.py,sha256=CPxjWZjrxuSO8YWelz6dbp7fm788gN7-T8z7jXStboQ,6017
|
148
|
-
edsl/questions/QuestionBasePromptsMixin.py,sha256=
|
131
|
+
edsl/questions/QuestionBasePromptsMixin.py,sha256=tInTg27KtmyO-hX4ZZdzgPTy4a8LZzbssUC_tAhRsxU,9552
|
149
132
|
edsl/questions/QuestionBudget.py,sha256=TJgPsyqafJdJw5if0zVxh7zHloourINUqUWfWIlRq9Y,8131
|
150
133
|
edsl/questions/QuestionCheckBox.py,sha256=wC_doEdNZi4y8Uz-tXZyQ2GYS5wQKOWhbVUnyVLoACU,12840
|
151
134
|
edsl/questions/QuestionExtract.py,sha256=PlXwMeZgPAFBXIHSXpFMYTToag-HwA9C7u6-Z3bQMek,6103
|
@@ -167,7 +150,7 @@ edsl/questions/derived/QuestionLinearScale.py,sha256=tj_RszK9WumaKRVMS1Fy63-Q6ip
|
|
167
150
|
edsl/questions/derived/QuestionTopK.py,sha256=HT8NlbT8YBTmVNVPVIP1EyqGsiN3bu4SbFp29CVT0a4,3212
|
168
151
|
edsl/questions/derived/QuestionYesNo.py,sha256=KWJyaXSNPNxELtK0nWvIqNtpAF05MMAC0ILUjxXkVwo,2735
|
169
152
|
edsl/questions/derived/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
170
|
-
edsl/questions/descriptors.py,sha256=
|
153
|
+
edsl/questions/descriptors.py,sha256=t9AFQPHewgqeC1OZ3I3kP-i2ToXRJUAcJsP7CZIrOgY,16447
|
171
154
|
edsl/questions/prompt_templates/question_budget.jinja,sha256=-ekZYCa_KRc-xLcpf3j-YmXV0WSyIK_laOp2x3li-tA,737
|
172
155
|
edsl/questions/prompt_templates/question_checkbox.jinja,sha256=V-Dn2VJhfXyIILWIhMviTfQ5WuXh1YZerwicaA6Okzc,1136
|
173
156
|
edsl/questions/prompt_templates/question_extract.jinja,sha256=27b8iMJaA2h5UOrHPMiBCapMnJou4vSkZzkZndK2s1U,343
|
@@ -289,7 +272,7 @@ edsl/utilities/interface.py,sha256=AaKpWiwWBwP2swNXmnFlIf3ZFsjfsR5bjXQAW47tD-8,1
|
|
289
272
|
edsl/utilities/repair_functions.py,sha256=tftmklAqam6LOQQu_-9U44N-llycffhW8LfO63vBmNw,929
|
290
273
|
edsl/utilities/restricted_python.py,sha256=5-_zUhrNbos7pLhDl9nr8d24auRlquR6w-vKkmNjPiA,2060
|
291
274
|
edsl/utilities/utilities.py,sha256=gqMtWWNEZkWLiRR9vHW-VRNy2bStEPlJ-I2aK9CwFiQ,11367
|
292
|
-
edsl-0.1.
|
293
|
-
edsl-0.1.
|
294
|
-
edsl-0.1.
|
295
|
-
edsl-0.1.
|
275
|
+
edsl-0.1.36.dev1.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
|
276
|
+
edsl-0.1.36.dev1.dist-info/METADATA,sha256=dTcbX2Paflg5gnjssUQVafoVYWs2FDACLaSf2ngOAc8,4476
|
277
|
+
edsl-0.1.36.dev1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
278
|
+
edsl-0.1.36.dev1.dist-info/RECORD,,
|
edsl/jobs/FailedQuestion.py
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
from edsl.questions import QuestionBase
|
2
|
-
from edsl import Question, Scenario, Model, Agent
|
3
|
-
|
4
|
-
from edsl.language_models.LanguageModel import LanguageModel
|
5
|
-
|
6
|
-
|
7
|
-
class FailedQuestion:
|
8
|
-
# tests/jobs/test_Interview.py::test_handle_model_exceptions
|
9
|
-
|
10
|
-
# (Pdb) dir(self.exception.__traceback__)
|
11
|
-
# ['tb_frame', 'tb_lasti', 'tb_lineno', 'tb_next']
|
12
|
-
|
13
|
-
def __init__(
|
14
|
-
self, question, scenario, model, agent, raw_model_response, exception, prompts
|
15
|
-
):
|
16
|
-
self.question = question
|
17
|
-
self.scenario = scenario
|
18
|
-
self.model = model
|
19
|
-
self.agent = agent
|
20
|
-
self.raw_model_response = raw_model_response # JSON
|
21
|
-
self.exception = exception
|
22
|
-
self.prompts = prompts
|
23
|
-
|
24
|
-
def to_dict(self):
|
25
|
-
return {
|
26
|
-
"question": self.question._to_dict(),
|
27
|
-
"scenario": self.scenario._to_dict(),
|
28
|
-
"model": self.model._to_dict(),
|
29
|
-
"agent": self.agent._to_dict(),
|
30
|
-
"raw_model_response": self.raw_model_response,
|
31
|
-
"exception": self.exception.__class__.__name__, # self.exception,
|
32
|
-
"prompts": self.prompts,
|
33
|
-
}
|
34
|
-
|
35
|
-
@classmethod
|
36
|
-
def from_dict(cls, data):
|
37
|
-
question = QuestionBase.from_dict(data["question"])
|
38
|
-
scenario = Scenario.from_dict(data["scenario"])
|
39
|
-
model = LanguageModel.from_dict(data["model"])
|
40
|
-
agent = Agent.from_dict(data["agent"])
|
41
|
-
raw_model_response = data["raw_model_response"]
|
42
|
-
exception = data["exception"]
|
43
|
-
prompts = data["prompts"]
|
44
|
-
return cls(
|
45
|
-
question, scenario, model, agent, raw_model_response, exception, prompts
|
46
|
-
)
|
47
|
-
|
48
|
-
def __repr__(self):
|
49
|
-
return f"{self.__class__.__name__}(question={repr(self.question)}, scenario={repr(self.scenario)}, model={repr(self.model)}, agent={repr(self.agent)}, raw_model_response={repr(self.raw_model_response)}, exception={repr(self.exception)})"
|
50
|
-
|
51
|
-
@property
|
52
|
-
def jobs(self):
|
53
|
-
return self.question.by(self.scenario).by(self.agent).by(self.model)
|
54
|
-
|
55
|
-
def rerun(self):
|
56
|
-
results = self.jobs.run()
|
57
|
-
return results
|
58
|
-
|
59
|
-
def help(self):
|
60
|
-
pass
|
61
|
-
|
62
|
-
@classmethod
|
63
|
-
def example(cls):
|
64
|
-
from edsl.language_models.utilities import create_language_model
|
65
|
-
from edsl.language_models.utilities import create_survey
|
66
|
-
|
67
|
-
survey = create_survey(2, chained=False, take_scenario=False)
|
68
|
-
fail_at_number = 1
|
69
|
-
model = create_language_model(ValueError, fail_at_number)()
|
70
|
-
from edsl import Survey
|
71
|
-
|
72
|
-
results = survey.by(model).run()
|
73
|
-
return results.failed_questions[0][0]
|
74
|
-
|
75
|
-
|
76
|
-
if __name__ == "__main__":
|
77
|
-
fq = FailedQuestion.example()
|
78
|
-
new_fq = FailedQuestion.from_dict(fq.to_dict())
|
@@ -1,33 +0,0 @@
|
|
1
|
-
from edsl.jobs.interviews.InterviewStatusLog import InterviewStatusLog
|
2
|
-
from edsl.jobs.tokens.InterviewTokenUsage import InterviewTokenUsage
|
3
|
-
|
4
|
-
from edsl.jobs.interviews.InterviewStatusDictionary import InterviewStatusDictionary
|
5
|
-
|
6
|
-
|
7
|
-
class InterviewStatusMixin:
|
8
|
-
@property
|
9
|
-
def has_exceptions(self) -> bool:
|
10
|
-
"""Return True if there are exceptions."""
|
11
|
-
return len(self.exceptions) > 0
|
12
|
-
|
13
|
-
@property
|
14
|
-
def task_status_logs(self) -> InterviewStatusLog:
|
15
|
-
"""Return the task status logs for the interview.
|
16
|
-
|
17
|
-
The keys are the question names; the values are the lists of status log changes for each task.
|
18
|
-
"""
|
19
|
-
for task_creator in self.task_creators.values():
|
20
|
-
self._task_status_log_dict[
|
21
|
-
task_creator.question.question_name
|
22
|
-
] = task_creator.status_log
|
23
|
-
return self._task_status_log_dict
|
24
|
-
|
25
|
-
@property
|
26
|
-
def token_usage(self) -> InterviewTokenUsage:
|
27
|
-
"""Determine how many tokens were used for the interview."""
|
28
|
-
return self.task_creators.token_usage
|
29
|
-
|
30
|
-
@property
|
31
|
-
def interview_status(self) -> InterviewStatusDictionary:
|
32
|
-
"""Return a dictionary mapping task status codes to counts."""
|
33
|
-
return self.task_creators.interview_status
|
@@ -1,13 +0,0 @@
|
|
1
|
-
from collections import UserDict
|
2
|
-
|
3
|
-
|
4
|
-
class TokensUsed(UserDict):
|
5
|
-
""" "Container for tokens used by a task."""
|
6
|
-
|
7
|
-
def __init__(self, cached_tokens, new_tokens):
|
8
|
-
d = {"cached_tokens": cached_tokens, "new_tokens": new_tokens}
|
9
|
-
super().__init__(d)
|
10
|
-
|
11
|
-
|
12
|
-
if __name__ == "__main__":
|
13
|
-
pass
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"""Class for creating question instructions to be used in a survey."""
|
2
|
-
|
3
|
-
from edsl.prompts.Prompt import PromptBase
|
4
|
-
from edsl.prompts.prompt_config import ComponentTypes
|
5
|
-
|
6
|
-
|
7
|
-
class QuestionInstuctionsBase(PromptBase):
|
8
|
-
"""Class for creating question instructions to be used in a survey."""
|
9
|
-
|
10
|
-
component_type = ComponentTypes.QUESTION_INSTRUCTIONS
|
@@ -1,38 +0,0 @@
|
|
1
|
-
"""Agent instructions for a human agent."""
|
2
|
-
|
3
|
-
import textwrap
|
4
|
-
|
5
|
-
from edsl.prompts.Prompt import PromptBase
|
6
|
-
from edsl.prompts.prompt_config import ComponentTypes
|
7
|
-
|
8
|
-
# from edsl.enums import LanguageModelType
|
9
|
-
|
10
|
-
|
11
|
-
class AgentInstruction(PromptBase):
|
12
|
-
"""Agent instructions for a human agent."""
|
13
|
-
|
14
|
-
# model = LanguageModelType.GPT_3_5_Turbo.value
|
15
|
-
# from edsl import Model
|
16
|
-
# model = Model().model
|
17
|
-
model = "gpt-3.5-turbo"
|
18
|
-
component_type = ComponentTypes.AGENT_INSTRUCTIONS
|
19
|
-
default_instructions = textwrap.dedent(
|
20
|
-
"""\
|
21
|
-
You are playing the role of a human answering survey questions.
|
22
|
-
Do not break character.
|
23
|
-
"""
|
24
|
-
)
|
25
|
-
|
26
|
-
|
27
|
-
# class AgentInstructionLlama(PromptBase):
|
28
|
-
# """Agent instructions for a human agent."""
|
29
|
-
|
30
|
-
# model = LanguageModelType.LLAMA_2_70B_CHAT_HF.value
|
31
|
-
# component_type = ComponentTypes.AGENT_INSTRUCTIONS
|
32
|
-
# default_instructions = textwrap.dedent(
|
33
|
-
# """\
|
34
|
-
# You are playing the role of a human answering questions.
|
35
|
-
# Do not break character.
|
36
|
-
# Only respond in JSON, with one answer formatted as specified.
|
37
|
-
# """
|
38
|
-
# )
|
@@ -1,21 +0,0 @@
|
|
1
|
-
"""Agent persona for a human agent."""
|
2
|
-
|
3
|
-
import textwrap
|
4
|
-
|
5
|
-
from edsl.prompts.Prompt import PromptBase
|
6
|
-
from edsl.prompts.prompt_config import ComponentTypes
|
7
|
-
|
8
|
-
# from edsl.enums import LanguageModelType
|
9
|
-
|
10
|
-
|
11
|
-
class AgentPersona(PromptBase):
|
12
|
-
"""Agent persona for a human agent."""
|
13
|
-
|
14
|
-
model = "gpt-4-1106-preview"
|
15
|
-
component_type = ComponentTypes.AGENT_PERSONA
|
16
|
-
default_instructions = textwrap.dedent(
|
17
|
-
"""\
|
18
|
-
You are an agent with the following persona:
|
19
|
-
{{ traits }}
|
20
|
-
"""
|
21
|
-
)
|
@@ -1,30 +0,0 @@
|
|
1
|
-
"""Budget question instructions."""
|
2
|
-
|
3
|
-
import textwrap
|
4
|
-
|
5
|
-
from edsl.prompts.QuestionInstructionsBase import QuestionInstuctionsBase
|
6
|
-
|
7
|
-
|
8
|
-
class Budget(QuestionInstuctionsBase):
|
9
|
-
"""Budget question instructions."""
|
10
|
-
|
11
|
-
question_type = "budget"
|
12
|
-
model = "gpt-4-1106-preview"
|
13
|
-
default_instructions = textwrap.dedent(
|
14
|
-
"""\
|
15
|
-
You are being asked the following question: {{question_text}}
|
16
|
-
The options are
|
17
|
-
{% for option in question_options %}
|
18
|
-
{{ loop.index0 }}: {{option}}
|
19
|
-
{% endfor %}
|
20
|
-
Return a valid JSON formatted as follows, with a dictionary for your "answer"
|
21
|
-
where the keys are the option numbers and the values are the amounts you want
|
22
|
-
to allocate to the options, and the sum of the values is {{budget_sum}}:
|
23
|
-
{"answer": {<put dict of option numbers and allocation amounts here>},
|
24
|
-
"comment": "<put explanation here>"}
|
25
|
-
Example response for a budget of 100 and 4 options:
|
26
|
-
{"answer": {"0": 25, "1": 25, "2": 25, "3": 25},
|
27
|
-
"comment": "I allocated 25 to each option."}
|
28
|
-
There must be an allocation listed for each item (including 0).
|
29
|
-
"""
|
30
|
-
)
|
@@ -1,38 +0,0 @@
|
|
1
|
-
"""Checkbox question type."""
|
2
|
-
|
3
|
-
import textwrap
|
4
|
-
from edsl.prompts.QuestionInstructionsBase import QuestionInstuctionsBase
|
5
|
-
|
6
|
-
|
7
|
-
class CheckBox(QuestionInstuctionsBase):
|
8
|
-
"""Checkbox question type."""
|
9
|
-
|
10
|
-
question_type = "checkbox"
|
11
|
-
model = "gpt-4-1106-preview"
|
12
|
-
default_instructions = textwrap.dedent(
|
13
|
-
"""\
|
14
|
-
You are being asked the following question: {{question_text}}
|
15
|
-
The options are
|
16
|
-
{% for option in question_options %}
|
17
|
-
{{ loop.index0 }}: {{option}}
|
18
|
-
{% endfor %}
|
19
|
-
Return a valid JSON formatted like this, selecting only the number of the option:
|
20
|
-
{"answer": [<put comma-separated list of answer codes here>], "comment": "<put explanation here>"}
|
21
|
-
{% if min_selections != None and max_selections != None and min_selections == max_selections %}
|
22
|
-
You must select exactly {{min_selections}} options.
|
23
|
-
{% elif min_selections != None and max_selections != None %}
|
24
|
-
Minimum number of options that must be selected: {{min_selections}}.
|
25
|
-
Maximum number of options that must be selected: {{max_selections}}.
|
26
|
-
{% elif min_selections != None %}
|
27
|
-
Minimum number of options that must be selected: {{min_selections}}.
|
28
|
-
{% elif max_selections != None %}
|
29
|
-
Maximum number of options that must be selected: {{max_selections}}.
|
30
|
-
{% endif %}
|
31
|
-
"""
|
32
|
-
)
|
33
|
-
|
34
|
-
|
35
|
-
class TopK(CheckBox):
|
36
|
-
"""Top K question type."""
|
37
|
-
|
38
|
-
question_type = "top_k"
|
@@ -1,23 +0,0 @@
|
|
1
|
-
"""Extract question type."""
|
2
|
-
|
3
|
-
import textwrap
|
4
|
-
|
5
|
-
from edsl.prompts.QuestionInstructionsBase import QuestionInstuctionsBase
|
6
|
-
|
7
|
-
|
8
|
-
class Extract(QuestionInstuctionsBase):
|
9
|
-
"""Extract question type."""
|
10
|
-
|
11
|
-
question_type = "extract"
|
12
|
-
model = "gpt-4-1106-preview"
|
13
|
-
default_instructions = textwrap.dedent(
|
14
|
-
"""\
|
15
|
-
You are given the following input: "{{question_text}}".
|
16
|
-
Create an ANSWER should be formatted like this: "{{ answer_template }}",
|
17
|
-
and it should have the same keys but values extracted from the input.
|
18
|
-
If the value of a key is not present in the input, fill with "null".
|
19
|
-
Return a valid JSON formatted like this:
|
20
|
-
{"answer": <put your ANSWER here>}
|
21
|
-
ONLY RETURN THE JSON, AND NOTHING ELSE.
|
22
|
-
"""
|
23
|
-
)
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"""Free text question type."""
|
2
|
-
|
3
|
-
import textwrap
|
4
|
-
from edsl.prompts.QuestionInstructionsBase import QuestionInstuctionsBase
|
5
|
-
|
6
|
-
|
7
|
-
class FreeText(QuestionInstuctionsBase):
|
8
|
-
"""Free text question type."""
|
9
|
-
|
10
|
-
question_type = "free_text"
|
11
|
-
model = "gpt-4-1106-preview"
|
12
|
-
default_instructions = textwrap.dedent(
|
13
|
-
"""\
|
14
|
-
You are being asked the following question: {{question_text}}
|
15
|
-
Return a valid JSON formatted like this:
|
16
|
-
{"answer": "<put free text answer here>"}
|
17
|
-
"""
|
18
|
-
)
|