edsl 0.1.33.dev2__py3-none-any.whl → 0.1.33.dev3__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.
Files changed (63) hide show
  1. edsl/Base.py +9 -3
  2. edsl/__init__.py +1 -0
  3. edsl/__version__.py +1 -1
  4. edsl/agents/Agent.py +6 -6
  5. edsl/agents/Invigilator.py +6 -3
  6. edsl/agents/InvigilatorBase.py +8 -27
  7. edsl/agents/{PromptConstructionMixin.py → PromptConstructor.py} +101 -29
  8. edsl/config.py +26 -34
  9. edsl/coop/coop.py +11 -2
  10. edsl/data_transfer_models.py +27 -73
  11. edsl/enums.py +2 -0
  12. edsl/inference_services/GoogleService.py +1 -1
  13. edsl/inference_services/InferenceServiceABC.py +44 -13
  14. edsl/inference_services/OpenAIService.py +7 -4
  15. edsl/inference_services/TestService.py +24 -15
  16. edsl/inference_services/TogetherAIService.py +170 -0
  17. edsl/inference_services/registry.py +2 -0
  18. edsl/jobs/Jobs.py +18 -8
  19. edsl/jobs/buckets/BucketCollection.py +24 -15
  20. edsl/jobs/buckets/TokenBucket.py +64 -10
  21. edsl/jobs/interviews/Interview.py +115 -47
  22. edsl/jobs/interviews/{interview_exception_tracking.py → InterviewExceptionCollection.py} +16 -0
  23. edsl/jobs/interviews/InterviewExceptionEntry.py +2 -0
  24. edsl/jobs/runners/JobsRunnerAsyncio.py +86 -161
  25. edsl/jobs/runners/JobsRunnerStatus.py +331 -0
  26. edsl/jobs/tasks/TaskHistory.py +17 -0
  27. edsl/language_models/LanguageModel.py +26 -31
  28. edsl/language_models/registry.py +13 -9
  29. edsl/questions/QuestionBase.py +64 -16
  30. edsl/questions/QuestionBudget.py +93 -41
  31. edsl/questions/QuestionFreeText.py +6 -0
  32. edsl/questions/QuestionMultipleChoice.py +11 -26
  33. edsl/questions/QuestionNumerical.py +5 -4
  34. edsl/questions/Quick.py +41 -0
  35. edsl/questions/ResponseValidatorABC.py +6 -5
  36. edsl/questions/derived/QuestionLinearScale.py +4 -1
  37. edsl/questions/derived/QuestionTopK.py +4 -1
  38. edsl/questions/derived/QuestionYesNo.py +8 -2
  39. edsl/questions/templates/budget/__init__.py +0 -0
  40. edsl/questions/templates/budget/answering_instructions.jinja +7 -0
  41. edsl/questions/templates/budget/question_presentation.jinja +7 -0
  42. edsl/questions/templates/extract/__init__.py +0 -0
  43. edsl/questions/templates/rank/__init__.py +0 -0
  44. edsl/results/DatasetExportMixin.py +5 -1
  45. edsl/results/Result.py +1 -1
  46. edsl/results/Results.py +4 -1
  47. edsl/scenarios/FileStore.py +71 -10
  48. edsl/scenarios/Scenario.py +86 -21
  49. edsl/scenarios/ScenarioImageMixin.py +2 -2
  50. edsl/scenarios/ScenarioList.py +13 -0
  51. edsl/scenarios/ScenarioListPdfMixin.py +150 -4
  52. edsl/study/Study.py +32 -0
  53. edsl/surveys/Rule.py +10 -1
  54. edsl/surveys/RuleCollection.py +19 -3
  55. edsl/surveys/Survey.py +7 -0
  56. edsl/templates/error_reporting/interview_details.html +6 -1
  57. edsl/utilities/utilities.py +9 -1
  58. {edsl-0.1.33.dev2.dist-info → edsl-0.1.33.dev3.dist-info}/METADATA +2 -1
  59. {edsl-0.1.33.dev2.dist-info → edsl-0.1.33.dev3.dist-info}/RECORD +61 -55
  60. edsl/jobs/interviews/retry_management.py +0 -39
  61. edsl/jobs/runners/JobsRunnerStatusMixin.py +0 -333
  62. {edsl-0.1.33.dev2.dist-info → edsl-0.1.33.dev3.dist-info}/LICENSE +0 -0
  63. {edsl-0.1.33.dev2.dist-info → edsl-0.1.33.dev3.dist-info}/WHEEL +0 -0
@@ -1,8 +1,60 @@
1
1
  from __future__ import annotations
2
- import random
3
- from typing import Any, Optional, Union
2
+ from typing import Any, Optional, Union, List
3
+
4
+ from pydantic import Field, BaseModel, validator
5
+
4
6
  from edsl.questions.QuestionBase import QuestionBase
5
7
  from edsl.questions.descriptors import IntegerDescriptor, QuestionOptionsDescriptor
8
+ from edsl.questions.ResponseValidatorABC import ResponseValidatorABC
9
+
10
+
11
+ class BudgewResponseValidator(ResponseValidatorABC):
12
+ valid_examples = []
13
+
14
+ invalid_examples = []
15
+
16
+ def fix(self, response, verbose=False):
17
+ if verbose:
18
+ print(f"Fixing list response: {response}")
19
+ answer = str(response.get("answer") or response.get("generated_tokens", ""))
20
+ if len(answer.split(",")) > 0:
21
+ return (
22
+ {"answer": answer.split(",")} | {"comment": response.get("comment")}
23
+ if "comment" in response
24
+ else {}
25
+ )
26
+
27
+
28
+ def create_budget_model(
29
+ budget_sum: float, permissive: bool, question_options: List[str]
30
+ ):
31
+ class BudgetResponse(BaseModel):
32
+ answer: List[float] = Field(
33
+ ...,
34
+ description="List of non-negative numbers representing budget allocation",
35
+ min_items=len(question_options),
36
+ max_items=len(question_options),
37
+ )
38
+ comment: Optional[str] = None
39
+ generated_tokens: Optional[str] = None
40
+
41
+ @validator("answer")
42
+ def validate_answer(cls, v):
43
+ if len(v) != len(question_options):
44
+ raise ValueError(f"Must provide {len(question_options)} values")
45
+ if any(x < 0 for x in v):
46
+ raise ValueError("All values must be non-negative")
47
+ total = sum(v)
48
+ if not permissive and total != budget_sum:
49
+ raise ValueError(f"Sum of numbers must equal {budget_sum}")
50
+ elif permissive and total > budget_sum:
51
+ raise ValueError(f"Sum of numbers cannot exceed {budget_sum}")
52
+ return v
53
+
54
+ class Config:
55
+ extra = "forbid"
56
+
57
+ return BudgetResponse
6
58
 
7
59
 
8
60
  class QuestionBudget(QuestionBase):
@@ -12,7 +64,7 @@ class QuestionBudget(QuestionBase):
12
64
  budget_sum: int = IntegerDescriptor(none_allowed=False)
13
65
  question_options: list[str] = QuestionOptionsDescriptor(q_budget=True)
14
66
  _response_model = None
15
- response_validator_class = None
67
+ response_validator_class = BudgewResponseValidator
16
68
 
17
69
  def __init__(
18
70
  self,
@@ -20,8 +72,10 @@ class QuestionBudget(QuestionBase):
20
72
  question_text: str,
21
73
  question_options: list[str],
22
74
  budget_sum: int,
75
+ include_comment: bool = True,
23
76
  question_presentation: Optional[str] = None,
24
77
  answering_instructions: Optional[str] = None,
78
+ permissive: bool = False,
25
79
  ):
26
80
  """Instantiate a new QuestionBudget.
27
81
 
@@ -36,20 +90,17 @@ class QuestionBudget(QuestionBase):
36
90
  self.budget_sum = budget_sum
37
91
  self.question_presentation = question_presentation
38
92
  self.answering_instructions = answering_instructions
93
+ self.permissive = permissive
94
+ self.include_comment = include_comment
39
95
 
40
- ################
41
- # Answer methods
42
- ################
43
- def _validate_answer(self, answer: dict[str, Any]) -> dict[str, Union[int, str]]:
44
- """Validate the answer."""
45
- self._validate_answer_template_basic(answer)
46
- self._validate_answer_key_value(answer, "answer", dict)
47
- self._validate_answer_budget(answer)
48
- return answer
96
+ def create_response_model(self):
97
+ return create_budget_model(
98
+ self.budget_sum, self.permissive, self.question_options
99
+ )
49
100
 
50
101
  def _translate_answer_code_to_answer(
51
- self, answer_codes: dict[str, int], scenario: "Scenario" = None
52
- ):
102
+ self, answer_code, combined_dict
103
+ ) -> list[dict]:
53
104
  """
54
105
  Translate the answer codes to the actual answers.
55
106
 
@@ -58,35 +109,35 @@ class QuestionBudget(QuestionBase):
58
109
  This code will translate that to "a".
59
110
  """
60
111
  translated_codes = []
61
- for answer_code, response in answer_codes.items():
62
- translated_codes.append({self.question_options[int(answer_code)]: response})
112
+ for answer_code, question_option in zip(answer_code, self.question_options):
113
+ translated_codes.append({question_option: answer_code})
63
114
 
64
115
  return translated_codes
65
116
 
66
- def _simulate_answer(self, human_readable=True):
67
- """Simulate a valid answer for debugging purposes (what the validator expects)."""
68
- from edsl.utilities.utilities import random_string
69
-
70
- if human_readable:
71
- keys = self.question_options
72
- else:
73
- keys = range(len(self.question_options))
74
- remaining_budget = self.budget_sum
75
- values = []
76
- for _ in range(len(self.question_options)):
77
- if _ == len(self.question_options) - 1:
78
- # Assign remaining budget to the last value
79
- values.append(remaining_budget)
80
- else:
81
- # Generate a random value between 0 and remaining budget
82
- value = random.randint(0, remaining_budget)
83
- values.append(value)
84
- remaining_budget -= value
85
- answer = dict(zip(keys, values))
86
- return {
87
- "answer": answer,
88
- "comment": random_string(),
89
- }
117
+ # def _simulate_answer(self, human_readable=True):
118
+ # """Simulate a valid answer for debugging purposes (what the validator expects)."""
119
+ # from edsl.utilities.utilities import random_string
120
+
121
+ # if human_readable:
122
+ # keys = self.question_options
123
+ # else:
124
+ # keys = range(len(self.question_options))
125
+ # remaining_budget = self.budget_sum
126
+ # values = []
127
+ # for _ in range(len(self.question_options)):
128
+ # if _ == len(self.question_options) - 1:
129
+ # # Assign remaining budget to the last value
130
+ # values.append(remaining_budget)
131
+ # else:
132
+ # # Generate a random value between 0 and remaining budget
133
+ # value = random.randint(0, remaining_budget)
134
+ # values.append(value)
135
+ # remaining_budget -= value
136
+ # answer = dict(zip(keys, values))
137
+ # return {
138
+ # "answer": answer,
139
+ # "comment": random_string(),
140
+ # }
90
141
 
91
142
  @property
92
143
  def question_html_content(self) -> str:
@@ -133,13 +184,14 @@ class QuestionBudget(QuestionBase):
133
184
  # Helpful methods
134
185
  ################
135
186
  @classmethod
136
- def example(cls) -> QuestionBudget:
187
+ def example(cls, include_comment: bool = True) -> QuestionBudget:
137
188
  """Return an example of a budget question."""
138
189
  return cls(
139
190
  question_name="food_budget",
140
191
  question_text="How would you allocate $100?",
141
192
  question_options=["Pizza", "Ice Cream", "Burgers", "Salad"],
142
193
  budget_sum=100,
194
+ include_comment=include_comment,
143
195
  )
144
196
 
145
197
 
@@ -36,6 +36,12 @@ class FreeTextResponseValidator(ResponseValidatorABC):
36
36
  ),
37
37
  ]
38
38
 
39
+ def fix(self, response, verbose=False):
40
+ return {
41
+ "answer": str(response.get("generated_tokens")),
42
+ "generated_tokens": str(response.get("generated_tokens")),
43
+ }
44
+
39
45
 
40
46
  class QuestionFreeText(QuestionBase):
41
47
  """This question prompts the agent to respond with free text."""
@@ -1,22 +1,14 @@
1
1
  from __future__ import annotations
2
- from typing import Union, Literal, Optional
3
- from jinja2 import Template
2
+ from typing import Union, Literal, Optional, List, Any
4
3
 
4
+ from jinja2 import Template
5
5
  from pydantic import BaseModel, Field
6
- from typing import Optional, Literal
7
6
 
7
+ from edsl.scenarios.Scenario import Scenario
8
8
  from edsl.questions.QuestionBase import QuestionBase
9
9
  from edsl.questions.descriptors import QuestionOptionsDescriptor
10
10
  from edsl.questions.decorators import inject_exception
11
-
12
11
  from edsl.questions.ResponseValidatorABC import ResponseValidatorABC
13
- from edsl.questions.ResponseValidatorABC import BaseResponse
14
-
15
- from edsl.exceptions import QuestionAnswerValidationError
16
-
17
- from pydantic import BaseModel, Field, create_model
18
-
19
- from typing import List, Any, Literal
20
12
 
21
13
 
22
14
  def create_response_model(choices: List[str], permissive: bool = False):
@@ -27,7 +19,6 @@ def create_response_model(choices: List[str], permissive: bool = False):
27
19
  :param permissive: If True, any value will be accepted as an answer.
28
20
  :return: A new Pydantic model class.
29
21
  """
30
- # Convert the choices list to a tuple for use with Literal
31
22
  choice_tuple = tuple(choices)
32
23
 
33
24
  if not permissive:
@@ -66,16 +57,6 @@ def create_response_model(choices: List[str], permissive: bool = False):
66
57
  return ChoiceResponse
67
58
 
68
59
 
69
- def fix_multiple_choice(response, question_options, use_code, verbose=False):
70
- """Fix the response to a multiple choice question.
71
- Respnse is a dictionary with keys:
72
- - answer: the answer code
73
- - generated_tokens: the generated tokens
74
- - comment: the comment
75
- """
76
- pass
77
-
78
-
79
60
  class MultipleChoiceResponseValidator(ResponseValidatorABC):
80
61
  required_params = ["question_options", "use_code"]
81
62
 
@@ -139,9 +120,9 @@ class QuestionMultipleChoice(QuestionBase):
139
120
 
140
121
  question_type = "multiple_choice"
141
122
  purpose = "When options are known and limited"
142
- question_options: Union[
143
- list[str], list[list], list[float], list[int]
144
- ] = QuestionOptionsDescriptor()
123
+ question_options: Union[list[str], list[list], list[float], list[int]] = (
124
+ QuestionOptionsDescriptor()
125
+ )
145
126
  _response_model = None
146
127
  response_validator_class = MultipleChoiceResponseValidator
147
128
 
@@ -161,6 +142,11 @@ class QuestionMultipleChoice(QuestionBase):
161
142
  :param question_name: The name of the question.
162
143
  :param question_text: The text of the question.
163
144
  :param question_options: The options the agent should select from.
145
+ :param include_comment: Whether to include a comment field.
146
+ :param use_code: Whether to use code for the options.
147
+ :param answering_instructions: Instructions for the question.
148
+ :param question_presentation: The presentation of the question.
149
+ :param permissive: Whether to force the answer to be one of the options.
164
150
 
165
151
  """
166
152
  self.question_name = question_name
@@ -202,7 +188,6 @@ class QuestionMultipleChoice(QuestionBase):
202
188
  'Happy'
203
189
 
204
190
  """
205
- from edsl.scenarios.Scenario import Scenario
206
191
 
207
192
  scenario = scenario or Scenario()
208
193
 
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
- from decimal import Decimal
2
+
3
+ # from decimal import Decimal
3
4
  from random import uniform
4
5
  from typing import Any, Optional, Union, Literal
5
6
 
@@ -14,8 +15,8 @@ from edsl.exceptions.questions import QuestionAnswerValidationError
14
15
 
15
16
 
16
17
  def create_numeric_response(
17
- min_value: Optional[Decimal] = None,
18
- max_value: Optional[Decimal] = None,
18
+ min_value: Optional[float] = None,
19
+ max_value: Optional[float] = None,
19
20
  permissive=False,
20
21
  ):
21
22
  field_kwargs = {}
@@ -27,7 +28,7 @@ def create_numeric_response(
27
28
  field_kwargs["le"] = max_value
28
29
 
29
30
  class ConstrainedNumericResponse(BaseModel):
30
- answer: Union[Decimal] = Field(**field_kwargs)
31
+ answer: Union[int, float] = Field(**field_kwargs)
31
32
  comment: Optional[str] = Field(None)
32
33
  generated_tokens: Optional[Any] = Field(None)
33
34
 
@@ -0,0 +1,41 @@
1
+ from edsl import (
2
+ QuestionFreeText,
3
+ QuestionMultipleChoice,
4
+ Survey,
5
+ QuestionList,
6
+ Question,
7
+ )
8
+
9
+
10
+ def Quick(question_text):
11
+ q_type = QuestionMultipleChoice(
12
+ question_text=f"A researcher is asking a language model this: {question_text}. What is the most appropriate type of question to ask?",
13
+ question_name="potential_question_type",
14
+ question_options=["multiple_choice", "list", "free_text"],
15
+ )
16
+
17
+ q_name = QuestionFreeText(
18
+ question_text=f"A researcher is asking a language model this: {question_text}. What is a good name for this question that's a valid python identifier? Just return the proposed identifer",
19
+ question_name="potential_question_name",
20
+ )
21
+
22
+ q_options = QuestionList(
23
+ question_text=f"A research is asking this question: { question_text }. What are the possible options for this question?",
24
+ question_name="potential_question_options",
25
+ )
26
+
27
+ survey = Survey([q_type, q_name, q_options]).add_skip_rule(
28
+ q_options, "{{ potential_question_type }} != 'multiple_choice'"
29
+ )
30
+ return survey
31
+ # results = survey.run()
32
+ # question_type = results.select("potential_question_type").first()
33
+ # question_options = results.select("potential_question_options").first()
34
+ # question_name = results.select("potential_question_name").first()
35
+ # print("Question Type: ", question_type)
36
+ # print("Question Name: ", question_name)
37
+ # print("Question Options: ", question_options)
38
+ # if question_options == None:
39
+ # return Question(question_type, question_name = question_name)
40
+ # else:
41
+ # return Question(question_type, question_name = question_name, question_options = question_options)
@@ -1,6 +1,7 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from pydantic import BaseModel, Field, field_validator
3
- from decimal import Decimal
3
+
4
+ # from decimal import Decimal
4
5
  from typing import Optional, Any, List, TypedDict
5
6
 
6
7
  from edsl.exceptions import QuestionAnswerValidationError
@@ -64,7 +65,7 @@ class ResponseValidatorABC(ABC):
64
65
  >>> rv = ResponseValidatorABC.example()
65
66
  >>> rv.override_answer = {"answer": 42}
66
67
  >>> rv.validate({"answer": 23})
67
- {'answer': Decimal('42'), 'comment': None, 'generated_tokens': None}
68
+ {'answer': 42, 'comment': None, 'generated_tokens': None}
68
69
  """
69
70
  if self.exception_to_throw:
70
71
  raise self.exception_to_throw
@@ -75,7 +76,7 @@ class ResponseValidatorABC(ABC):
75
76
 
76
77
  >>> rv = ResponseValidatorABC.example("numerical")
77
78
  >>> rv._base_validate({"answer": 42})
78
- ConstrainedNumericResponse(answer=Decimal('42'), comment=None, generated_tokens=None)
79
+ ConstrainedNumericResponse(answer=42, comment=None, generated_tokens=None)
79
80
  """
80
81
  try:
81
82
  return self.response_model(**data)
@@ -97,7 +98,7 @@ class ResponseValidatorABC(ABC):
97
98
 
98
99
  >>> rv = ResponseValidatorABC.example("numerical")
99
100
  >>> rv.validate({"answer": 42})
100
- {'answer': Decimal('42'), 'comment': None, 'generated_tokens': None}
101
+ {'answer': 42, 'comment': None, 'generated_tokens': None}
101
102
  >>> rv.max_value
102
103
  86.7
103
104
  >>> rv.validate({"answer": "120"})
@@ -109,7 +110,7 @@ class ResponseValidatorABC(ABC):
109
110
  >>> q.permissive = True
110
111
  >>> rv = q.response_validator
111
112
  >>> rv.validate({"answer": "120"})
112
- {'answer': Decimal('120'), 'comment': None, 'generated_tokens': None}
113
+ {'answer': 120, 'comment': None, 'generated_tokens': None}
113
114
  >>> rv.validate({"answer": "poo"})
114
115
  Traceback (most recent call last):
115
116
  ...
@@ -22,6 +22,7 @@ class QuestionLinearScale(QuestionMultipleChoice):
22
22
  option_labels: Optional[dict[int, str]] = None,
23
23
  answering_instructions: Optional[str] = None,
24
24
  question_presentation: Optional[str] = None,
25
+ include_comment: Optional[bool] = True,
25
26
  ):
26
27
  """Instantiate a new QuestionLinearScale.
27
28
 
@@ -36,6 +37,7 @@ class QuestionLinearScale(QuestionMultipleChoice):
36
37
  question_text=question_text,
37
38
  question_options=question_options,
38
39
  use_code=False, # question linear scale will have it's own code
40
+ include_comment=include_comment,
39
41
  )
40
42
  self.question_options = question_options
41
43
  self.option_labels = (
@@ -49,13 +51,14 @@ class QuestionLinearScale(QuestionMultipleChoice):
49
51
  ################
50
52
  @classmethod
51
53
  @inject_exception
52
- def example(cls) -> QuestionLinearScale:
54
+ def example(cls, include_comment: bool = True) -> QuestionLinearScale:
53
55
  """Return an example of a linear scale question."""
54
56
  return cls(
55
57
  question_text="How much do you like ice cream?",
56
58
  question_options=[1, 2, 3, 4, 5],
57
59
  question_name="ice_cream",
58
60
  option_labels={1: "I hate it", 5: "I love it"},
61
+ include_comment=include_comment,
59
62
  )
60
63
 
61
64
 
@@ -20,6 +20,7 @@ class QuestionTopK(QuestionCheckBox):
20
20
  max_selections: int,
21
21
  question_presentation: Optional[str] = None,
22
22
  answering_instructions: Optional[str] = None,
23
+ include_comment: Optional[bool] = True,
23
24
  ):
24
25
  """Initialize the question.
25
26
 
@@ -37,6 +38,7 @@ class QuestionTopK(QuestionCheckBox):
37
38
  max_selections=max_selections,
38
39
  question_presentation=question_presentation,
39
40
  answering_instructions=answering_instructions,
41
+ include_comment=include_comment,
40
42
  )
41
43
  if min_selections != max_selections:
42
44
  raise QuestionCreationValidationError(
@@ -52,7 +54,7 @@ class QuestionTopK(QuestionCheckBox):
52
54
  ################
53
55
  @classmethod
54
56
  @inject_exception
55
- def example(cls) -> QuestionTopK:
57
+ def example(cls, include_comment: bool = True) -> QuestionTopK:
56
58
  """Return an example question."""
57
59
  return cls(
58
60
  question_name="two_fruits",
@@ -60,6 +62,7 @@ class QuestionTopK(QuestionCheckBox):
60
62
  question_options=["apple", "banana", "carrot", "durian"],
61
63
  min_selections=2,
62
64
  max_selections=2,
65
+ include_comment=include_comment,
63
66
  )
64
67
 
65
68
 
@@ -19,6 +19,7 @@ class QuestionYesNo(QuestionMultipleChoice):
19
19
  question_options: list[str] = ["No", "Yes"],
20
20
  answering_instructions: Optional[str] = None,
21
21
  question_presentation: Optional[str] = None,
22
+ include_comment: Optional[bool] = True,
22
23
  ):
23
24
  """Instantiate a new QuestionYesNo.
24
25
 
@@ -33,6 +34,7 @@ class QuestionYesNo(QuestionMultipleChoice):
33
34
  use_code=False,
34
35
  answering_instructions=answering_instructions,
35
36
  question_presentation=question_presentation,
37
+ include_comment=include_comment,
36
38
  )
37
39
  self.question_options = question_options
38
40
 
@@ -41,9 +43,13 @@ class QuestionYesNo(QuestionMultipleChoice):
41
43
  ################
42
44
  @classmethod
43
45
  @inject_exception
44
- def example(cls) -> QuestionYesNo:
46
+ def example(cls, include_comment: bool = True) -> QuestionYesNo:
45
47
  """Return an example of a yes/no question."""
46
- return cls(question_name="is_it_equal", question_text="Is 5 + 5 equal to 11?")
48
+ return cls(
49
+ question_name="is_it_equal",
50
+ question_text="Is 5 + 5 equal to 11?",
51
+ include_comment=include_comment,
52
+ )
47
53
 
48
54
 
49
55
  def main():
File without changes
@@ -0,0 +1,7 @@
1
+ Return only a comma-separated list the values in the same order as the options, with 0s included, on one line, in square braces.
2
+
3
+ Example: if there are 4 options, the response should be "[25,25,25,25]" to allocate 25 to each option.
4
+
5
+ {% if include_comment %}
6
+ After the answer, you can put a comment explaining your choice on the next line.
7
+ {% endif %}
@@ -0,0 +1,7 @@
1
+ {{question_text}}
2
+ The options are
3
+ {% for option in question_options %}
4
+ {{ loop.index0 }}: {{option}}
5
+ {% endfor %}
6
+ Allocate your budget of {{budget_sum}} among the options.
7
+
File without changes
File without changes
@@ -472,7 +472,11 @@ class DatasetExportMixin:
472
472
  from edsl import ScenarioList, Scenario
473
473
 
474
474
  list_of_dicts = self.to_dicts(remove_prefix=remove_prefix)
475
- return ScenarioList([Scenario(d) for d in list_of_dicts])
475
+ scenarios = []
476
+ for d in list_of_dicts:
477
+ scenarios.append(Scenario(d))
478
+ return ScenarioList(scenarios)
479
+ # return ScenarioList([Scenario(d) for d in list_of_dicts])
476
480
 
477
481
  def to_agent_list(self, remove_prefix: bool = True):
478
482
  """Convert the results to a list of dictionaries, one per agent.
edsl/results/Result.py CHANGED
@@ -367,7 +367,7 @@ class Result(Base, UserDict):
367
367
  "raw_model_response", {"raw_model_response": "No raw model response"}
368
368
  ),
369
369
  question_to_attributes=json_dict.get("question_to_attributes", None),
370
- generated_tokens=json_dict.get("generated_tokens", None),
370
+ generated_tokens=json_dict.get("generated_tokens", {}),
371
371
  )
372
372
  return result
373
373
 
edsl/results/Results.py CHANGED
@@ -245,7 +245,9 @@ class Results(UserList, Mixins, Base):
245
245
  )
246
246
 
247
247
  def __repr__(self) -> str:
248
- return f"Results(data = {self.data}, survey = {repr(self.survey)}, created_columns = {self.created_columns})"
248
+ import reprlib
249
+
250
+ return f"Results(data = {reprlib.repr(self.data)}, survey = {repr(self.survey)}, created_columns = {self.created_columns})"
249
251
 
250
252
  def _repr_html_(self) -> str:
251
253
  from IPython.display import HTML
@@ -1089,6 +1091,7 @@ class Results(UserList, Mixins, Base):
1089
1091
  stop_on_exception=True,
1090
1092
  skip_retry=True,
1091
1093
  raise_validation_errors=True,
1094
+ disable_remote_inference=True,
1092
1095
  )
1093
1096
  return results
1094
1097