edsl 0.1.34.dev2__py3-none-any.whl → 0.1.35__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.34.dev2"
1
+ __version__ = "0.1.35"
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
  from typing import Dict, Any, Optional, Set
3
3
  from collections import UserList
4
- import enum
4
+ import pdb
5
5
 
6
6
  from jinja2 import Environment, meta
7
7
 
@@ -197,14 +197,15 @@ class PromptConstructor:
197
197
  self.question.question_options = question_options
198
198
 
199
199
  # might be getting it from the prior answers
200
- if isinstance(
201
- question_options := self.prior_answers_dict()
202
- .get(question_option_key)
203
- .answer,
204
- list,
205
- ):
206
- question_data["question_options"] = question_options
207
- self.question.question_options = question_options
200
+ if self.prior_answers_dict().get(question_option_key) is not None:
201
+ if isinstance(
202
+ question_options := self.prior_answers_dict()
203
+ .get(question_option_key)
204
+ .answer,
205
+ list,
206
+ ):
207
+ question_data["question_options"] = question_options
208
+ self.question.question_options = question_options
208
209
 
209
210
  replacement_dict = (
210
211
  {key: f"<see file {key}>" for key in self.scenario_file_keys}
@@ -240,10 +241,13 @@ class PromptConstructor:
240
241
  )
241
242
 
242
243
  if undefined_template_variables:
243
- # breakpoint()
244
- raise QuestionScenarioRenderError(
245
- f"Question instructions still has variables: {undefined_template_variables}."
246
- )
244
+ msg = f"Question instructions still has variables: {undefined_template_variables}."
245
+ import warnings
246
+
247
+ warnings.warn(msg)
248
+ # raise QuestionScenarioRenderError(
249
+ # f"Question instructions still has variables: {undefined_template_variables}."
250
+ # )
247
251
 
248
252
  ####################################
249
253
  # Check if question has instructions - these are instructions in a Survey that can apply to multiple follow-on questions
@@ -188,12 +188,16 @@ class OpenAIService(InferenceServiceABC):
188
188
  else:
189
189
  content = user_prompt
190
190
  client = self.async_client()
191
+
191
192
  messages = [
192
193
  {"role": "system", "content": system_prompt},
193
194
  {"role": "user", "content": content},
194
195
  ]
195
- if system_prompt == "" and self.omit_system_prompt_if_empty:
196
+ if (
197
+ system_prompt == "" and self.omit_system_prompt_if_empty
198
+ ) or "o1" in self.model:
196
199
  messages = messages[1:]
200
+
197
201
  params = {
198
202
  "model": self.model,
199
203
  "messages": messages,
@@ -205,7 +209,14 @@ class OpenAIService(InferenceServiceABC):
205
209
  "logprobs": self.logprobs,
206
210
  "top_logprobs": self.top_logprobs if self.logprobs else None,
207
211
  }
208
- response = await client.chat.completions.create(**params)
212
+ if "o1" in self.model:
213
+ params.pop("max_tokens")
214
+ params["max_completion_tokens"] = self.max_tokens
215
+ params["temperature"] = 1
216
+ try:
217
+ response = await client.chat.completions.create(**params)
218
+ except Exception as e:
219
+ print(e)
209
220
  return response.model_dump()
210
221
 
211
222
  LLM.__name__ = "LanguageModel"
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
  import asyncio
5
5
  from typing import Any, Type, List, Generator, Optional, Union
6
+ import copy
6
7
 
7
8
  from tenacity import (
8
9
  retry,
@@ -99,7 +100,9 @@ class Interview(InterviewStatusMixin):
99
100
 
100
101
  """
101
102
  self.agent = agent
102
- self.survey = survey
103
+ # what I would like to do
104
+ self.survey = copy.deepcopy(survey) # survey copy.deepcopy(survey)
105
+ # self.survey = survey
103
106
  self.scenario = scenario
104
107
  self.model = model
105
108
  self.debug = debug
@@ -1,7 +1,6 @@
1
1
  This question requires a numerical response in the form of an integer or decimal (e.g., -12, 0, 1, 2, 3.45, ...).
2
2
  Respond with just your number on a single line.
3
3
  If your response is equivalent to zero, report '0'
4
- If you cannot determine the answer, report 'None'
5
4
 
6
5
  {% if include_comment %}
7
6
  After the answer, put a comment explaining your choice on the next line.
@@ -39,6 +39,15 @@ class ScenarioList(Base, UserList, ScenarioListMixin):
39
39
  super().__init__([])
40
40
  self.codebook = codebook or {}
41
41
 
42
+ def unique(self) -> ScenarioList:
43
+ """Return a list of unique scenarios.
44
+
45
+ >>> s = ScenarioList([Scenario({'a': 1}), Scenario({'a': 1}), Scenario({'a': 2})])
46
+ >>> s.unique()
47
+ ScenarioList([Scenario({'a': 1}), Scenario({'a': 2})])
48
+ """
49
+ return ScenarioList(list(set(self)))
50
+
42
51
  @property
43
52
  def has_jinja_braces(self) -> bool:
44
53
  """Check if the ScenarioList has Jinja braces."""
edsl/surveys/base.py CHANGED
@@ -36,6 +36,10 @@ class EndOfSurveyParent:
36
36
  """
37
37
  return self
38
38
 
39
+ def __deepcopy__(self, memo):
40
+ # Return the same instance when deepcopy is called
41
+ return self
42
+
39
43
  def __radd__(self, other):
40
44
  """Add the object to another object.
41
45
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: edsl
3
- Version: 0.1.34.dev2
3
+ Version: 0.1.35
4
4
  Summary: Create and analyze LLM-based surveys
5
5
  Home-page: https://www.expectedparrot.com/
6
6
  License: MIT
@@ -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=voKonN-j0vUxItkRduH4SgbwrZQV8MKBnReeUBbNHRA,28
5
+ edsl/__version__.py,sha256=ABqgofsnbWf7823vTBbZNQ81eKQbWwrVToAU6T3z-6s,23
6
6
  edsl/agents/Agent.py,sha256=ww6DK177eHQUlYkzgnt1b-MBDKXCdhVx3HezAZZ7TKk,28473
7
7
  edsl/agents/AgentList.py,sha256=qo8VK3Ov0YOSbsBcHmlwLZBH81CcDfy5IEcx9AVH78M,10963
8
8
  edsl/agents/Invigilator.py,sha256=6xd4sJ6Jzxld8LZDWZuSCZLL_MfaSux4LJCAm_RLEOM,9077
9
9
  edsl/agents/InvigilatorBase.py,sha256=qIdAiriXAbnJH_SN9w2UAXHcDgQvk8Ar3QerKFjtPwM,10341
10
- edsl/agents/PromptConstructor.py,sha256=J002jaFLQHSwdSGqhBY5THwVb2fBHj6O4-8NsiVsom8,14598
10
+ edsl/agents/PromptConstructor.py,sha256=qVCfRyYR-vKcpGJ_It2SOUvBfHtF8M6qYcf9ZCsHBl8,14855
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
@@ -78,7 +78,7 @@ edsl/inference_services/InferenceServiceABC.py,sha256=rXqorwbKqzlwui2cxum8_TRrBc
78
78
  edsl/inference_services/InferenceServicesCollection.py,sha256=EDyxnoSjGXhWob_ost7U8WUYjn1jgL_noB0-VlXBnOo,2810
79
79
  edsl/inference_services/MistralAIService.py,sha256=7mUsBEZdEWIjfh4qMNemTT2xYMq7k0yuMLGtDTdfp4Y,3878
80
80
  edsl/inference_services/OllamaService.py,sha256=oro9CRl8IUE2Ro-zE69Cr4Zaf6Gdw29XW5CFU-46E0k,498
81
- edsl/inference_services/OpenAIService.py,sha256=2rGW0iGD_hnM1NHBJQCDI59Ti-9wFQu7gh8hDB95Cr4,7264
81
+ edsl/inference_services/OpenAIService.py,sha256=wraTu62bZojmgAXHNG6pJMMPZiyO1pSDfY73LVaBR_I,7621
82
82
  edsl/inference_services/TestService.py,sha256=-jTXkl_qLt1k8gJjRb0SMgTb9EY-XMTP-ZUL9AJcUCA,3009
83
83
  edsl/inference_services/TogetherAIService.py,sha256=p_31ccrfN25kZF2xlAlUkb7w1EL4lGjmkSv-5qZ7TtY,6301
84
84
  edsl/inference_services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -93,7 +93,7 @@ edsl/jobs/__init__.py,sha256=aKuAyd_GoalGj-k7djOoVwEbFUE2XLPlikXaA1_8yAg,32
93
93
  edsl/jobs/buckets/BucketCollection.py,sha256=11CRisE1WAPcAlI3YJK3DVvu0AqSvv8KskXo4Q1waSk,2286
94
94
  edsl/jobs/buckets/ModelBuckets.py,sha256=hxw_tzc0V42CiB7mh5jIxlgwDVJ-zFZhlLtKrHEg8ho,2419
95
95
  edsl/jobs/buckets/TokenBucket.py,sha256=7fG4omzTcj5xC2iJLO9bfBkdAGs6Y3weXzlA3BgPr0E,9090
96
- edsl/jobs/interviews/Interview.py,sha256=Gt6Fan_b6jD2cv6Pzp1Lr2BCSc6oTmSIrgvIoi1ycfA,23758
96
+ edsl/jobs/interviews/Interview.py,sha256=iw0thEGwENOl8uzHRJ88zjYHEDSlM_X96Fyse9wZCwM,23883
97
97
  edsl/jobs/interviews/InterviewExceptionCollection.py,sha256=Ez8BCZUD3odqoY9h-gzYKKM8yaHynQ-eYw2uMDh7t98,3279
98
98
  edsl/jobs/interviews/InterviewExceptionEntry.py,sha256=BGGjj0sb1wJJ0QmYklt1DyEYKD8mUGygllGfN2WXKbY,4903
99
99
  edsl/jobs/interviews/InterviewStatistic.py,sha256=hY5d2EkIJ96NilPpZAvZZzZoxLXM7ss3xx5MIcKtTPs,1856
@@ -205,7 +205,7 @@ edsl/questions/templates/multiple_choice/answering_instructions.jinja,sha256=eSc
205
205
  edsl/questions/templates/multiple_choice/html.jinja,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
206
206
  edsl/questions/templates/multiple_choice/question_presentation.jinja,sha256=hoEVj4GQD3EYnR2AStXkMFOJeqISNoEVzBd8-cx2yWg,273
207
207
  edsl/questions/templates/numerical/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
208
- edsl/questions/templates/numerical/answering_instructions.jinja,sha256=BfGAeKFJWEzzvB91x8DrpRUERSvDv6kXf3Y0szL27LY,373
208
+ edsl/questions/templates/numerical/answering_instructions.jinja,sha256=70CnuIbdRKGiYJk7316-FFloRh3Oeg_RvUu4tthNKqs,323
209
209
  edsl/questions/templates/numerical/question_presentation.jinja,sha256=8lMUWtEPHD4XOAyVEfCmWSwRFrdUa3lo8sxzogDyzWE,183
210
210
  edsl/questions/templates/rank/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
211
211
  edsl/questions/templates/rank/answering_instructions.jinja,sha256=-LWrhVJ0ZwQW_DXhARh5GweqlarWbhZzoqwr6tE-33s,433
@@ -232,7 +232,7 @@ edsl/results/tree_explore.py,sha256=hQjiO4E71rIOPDgEHgK8T8ukxqoNdgX_tvyiDlG4_9U,
232
232
  edsl/scenarios/FileStore.py,sha256=V_zn2RmVclcBQTvqghotnTO97YHWUXqeVfN7eMfpfUM,13929
233
233
  edsl/scenarios/Scenario.py,sha256=ZG1x4_MmWP9j0gakLwsxOZ7ESMy3ifwBMhgQlHvsYo8,16809
234
234
  edsl/scenarios/ScenarioHtmlMixin.py,sha256=EmugmbPJYW5eZS30rM6pDMDQD9yrrvHjmgZWB1qBfq4,1882
235
- edsl/scenarios/ScenarioList.py,sha256=v5zmM3AOxbVFN9kez6h8GVbFFAxDlykycXqREDc2h8c,40622
235
+ edsl/scenarios/ScenarioList.py,sha256=1zbwDICXbvtUGA5bDlhThNp9pfhBGIHIqhK2cX-th50,40942
236
236
  edsl/scenarios/ScenarioListExportMixin.py,sha256=wfffY9xy_1QyIM-1xnisr64izSLjmyuotUYY5iDLodc,1681
237
237
  edsl/scenarios/ScenarioListPdfMixin.py,sha256=z_H2sZn5SCSq6nRLSU5jefaOlh4sqJLyOY_Ld0XCR18,8332
238
238
  edsl/scenarios/__init__.py,sha256=KRwZCLf2R0qyJvv1NGbd8M51Bt6Ia6Iylg-Xq_2Fa6M,98
@@ -253,7 +253,7 @@ edsl/surveys/SurveyExportMixin.py,sha256=Kvkd2ku2Kemsn2Nw-Yt8GTnGFcUqfEiKznmisAe
253
253
  edsl/surveys/SurveyFlowVisualizationMixin.py,sha256=dEG_f-L0ZAyWU5Ta584IX5GZurjVt1tbIISo5z61Jvg,4004
254
254
  edsl/surveys/SurveyQualtricsImport.py,sha256=SSZv53D1zVhQSfSw-X0_cte0QnkWhE9v922wLn6RMkI,9771
255
255
  edsl/surveys/__init__.py,sha256=vjMYVlP95fHVqqw2FfKXRuYbTArZkZr1nK4FnXzZWzs,129
256
- edsl/surveys/base.py,sha256=n5PBx0BF0powzBXCsufpUekfNK_9huf3rohtU1mMCq0,1001
256
+ edsl/surveys/base.py,sha256=XJHGEbbsH6hlYYkmI4isVLD8guLz8BdhR-eQRL78mc4,1115
257
257
  edsl/surveys/descriptors.py,sha256=3B-hBVvGpLlVBCyOnPuxkLjesvpr0QIuATbggp_MJ7o,2076
258
258
  edsl/surveys/instructions/ChangeInstruction.py,sha256=XDLuI5nVI60iJz1w1kLaKmYryAYE0XIyRbElBtNjVVM,1265
259
259
  edsl/surveys/instructions/Instruction.py,sha256=WaTGihAQ6lCtm5W4vknTamkPzDp-eIAirdtGV37fdbc,925
@@ -289,7 +289,7 @@ edsl/utilities/interface.py,sha256=AaKpWiwWBwP2swNXmnFlIf3ZFsjfsR5bjXQAW47tD-8,1
289
289
  edsl/utilities/repair_functions.py,sha256=tftmklAqam6LOQQu_-9U44N-llycffhW8LfO63vBmNw,929
290
290
  edsl/utilities/restricted_python.py,sha256=5-_zUhrNbos7pLhDl9nr8d24auRlquR6w-vKkmNjPiA,2060
291
291
  edsl/utilities/utilities.py,sha256=gqMtWWNEZkWLiRR9vHW-VRNy2bStEPlJ-I2aK9CwFiQ,11367
292
- edsl-0.1.34.dev2.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
293
- edsl-0.1.34.dev2.dist-info/METADATA,sha256=HL8x3U8tuYTevkNMVg0Vy8hs_0SqpuZz0MyKre1AHbk,4476
294
- edsl-0.1.34.dev2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
295
- edsl-0.1.34.dev2.dist-info/RECORD,,
292
+ edsl-0.1.35.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
293
+ edsl-0.1.35.dist-info/METADATA,sha256=eyPEBXgJt4VgO_f7yPO8rIjvRDT2_RFjbCzF3bvVftk,4471
294
+ edsl-0.1.35.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
295
+ edsl-0.1.35.dist-info/RECORD,,