edsl 0.1.37.dev3__py3-none-any.whl → 0.1.37.dev4__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.37.dev3"
1
+ __version__ = "0.1.37.dev4"
edsl/coop/coop.py CHANGED
@@ -568,7 +568,9 @@ class Coop:
568
568
  "version": data.get("version"),
569
569
  }
570
570
 
571
- def remote_inference_cost(self, input: Union[Jobs, Survey]) -> int:
571
+ def remote_inference_cost(
572
+ self, input: Union[Jobs, Survey], iterations: int = 1
573
+ ) -> int:
572
574
  """
573
575
  Get the cost of a remote inference job.
574
576
 
@@ -593,6 +595,7 @@ class Coop:
593
595
  job.to_dict(),
594
596
  default=self._json_handle_none,
595
597
  ),
598
+ "iterations": iterations,
596
599
  },
597
600
  )
598
601
  self._resolve_server_response(response)
@@ -28,12 +28,16 @@ class AwsBedrockService(InferenceServiceABC):
28
28
  "ai21.j2-ultra",
29
29
  "ai21.j2-ultra-v1",
30
30
  ]
31
+ _models_list_cache: List[str] = []
31
32
 
32
33
  @classmethod
33
34
  def available(cls):
34
35
  """Fetch available models from AWS Bedrock."""
36
+
37
+ region = os.getenv("AWS_REGION", "us-east-1")
38
+
35
39
  if not cls._models_list_cache:
36
- client = boto3.client("bedrock", region_name="us-west-2")
40
+ client = boto3.client("bedrock", region_name=region)
37
41
  all_models_ids = [
38
42
  x["modelId"] for x in client.list_foundation_models()["modelSummaries"]
39
43
  ]
@@ -80,7 +84,8 @@ class AwsBedrockService(InferenceServiceABC):
80
84
  self.api_token
81
85
  ) # call to check the if env variables are set.
82
86
 
83
- client = boto3.client("bedrock-runtime", region_name="us-west-2")
87
+ region = os.getenv("AWS_REGION", "us-east-1")
88
+ client = boto3.client("bedrock-runtime", region_name=region)
84
89
 
85
90
  conversation = [
86
91
  {
edsl/jobs/Jobs.py CHANGED
@@ -193,7 +193,7 @@ class Jobs(Base):
193
193
  inference_service=invigilator.model._inference_service_,
194
194
  model=invigilator.model.model,
195
195
  )
196
- costs.append(prompt_cost["cost"])
196
+ costs.append(prompt_cost["cost_usd"])
197
197
 
198
198
  d = Dataset(
199
199
  [
@@ -241,10 +241,25 @@ class Jobs(Base):
241
241
 
242
242
  try:
243
243
  relevant_prices = price_lookup[key]
244
- output_price_per_token = 1 / float(
245
- relevant_prices["output"]["one_usd_buys"]
244
+
245
+ service_input_token_price = float(
246
+ relevant_prices["input"]["service_stated_token_price"]
247
+ )
248
+ service_input_token_qty = float(
249
+ relevant_prices["input"]["service_stated_token_qty"]
250
+ )
251
+ input_price_per_token = service_input_token_price / service_input_token_qty
252
+
253
+ service_output_token_price = float(
254
+ relevant_prices["output"]["service_stated_token_price"]
246
255
  )
247
- input_price_per_token = 1 / float(relevant_prices["input"]["one_usd_buys"])
256
+ service_output_token_qty = float(
257
+ relevant_prices["output"]["service_stated_token_qty"]
258
+ )
259
+ output_price_per_token = (
260
+ service_output_token_price / service_output_token_qty
261
+ )
262
+
248
263
  except KeyError:
249
264
  # A KeyError is likely to occur if we cannot retrieve prices (the price_lookup dict is empty)
250
265
  # Use a sensible default
@@ -254,9 +269,8 @@ class Jobs(Base):
254
269
  warnings.warn(
255
270
  "Price data could not be retrieved. Using default estimates for input and output token prices. Input: $0.15 / 1M tokens; Output: $0.60 / 1M tokens"
256
271
  )
257
-
258
- output_price_per_token = 0.00000015 # $0.15 / 1M tokens
259
- input_price_per_token = 0.00000060 # $0.60 / 1M tokens
272
+ input_price_per_token = 0.00000015 # $0.15 / 1M tokens
273
+ output_price_per_token = 0.00000060 # $0.60 / 1M tokens
260
274
 
261
275
  # Compute the number of characters (double if the question involves piping)
262
276
  user_prompt_chars = len(str(user_prompt)) * get_piping_multiplier(
@@ -279,7 +293,7 @@ class Jobs(Base):
279
293
  return {
280
294
  "input_tokens": input_tokens,
281
295
  "output_tokens": output_tokens,
282
- "cost": cost,
296
+ "cost_usd": cost,
283
297
  }
284
298
 
285
299
  def estimate_job_cost_from_external_prices(
@@ -326,7 +340,7 @@ class Jobs(Base):
326
340
  "system_prompt": system_prompt,
327
341
  "estimated_input_tokens": prompt_cost["input_tokens"],
328
342
  "estimated_output_tokens": prompt_cost["output_tokens"],
329
- "estimated_cost": prompt_cost["cost"],
343
+ "estimated_cost_usd": prompt_cost["cost_usd"],
330
344
  "inference_service": inference_service,
331
345
  "model": model,
332
346
  }
@@ -338,21 +352,21 @@ class Jobs(Base):
338
352
  df.groupby(["inference_service", "model"])
339
353
  .agg(
340
354
  {
341
- "estimated_cost": "sum",
355
+ "estimated_cost_usd": "sum",
342
356
  "estimated_input_tokens": "sum",
343
357
  "estimated_output_tokens": "sum",
344
358
  }
345
359
  )
346
360
  .reset_index()
347
361
  )
348
- df["estimated_cost"] = df["estimated_cost"] * iterations
362
+ df["estimated_cost_usd"] = df["estimated_cost_usd"] * iterations
349
363
  df["estimated_input_tokens"] = df["estimated_input_tokens"] * iterations
350
364
  df["estimated_output_tokens"] = df["estimated_output_tokens"] * iterations
351
365
 
352
366
  estimated_costs_by_model = df.to_dict("records")
353
367
 
354
368
  estimated_total_cost = sum(
355
- model["estimated_cost"] for model in estimated_costs_by_model
369
+ model["estimated_cost_usd"] for model in estimated_costs_by_model
356
370
  )
357
371
  estimated_total_input_tokens = sum(
358
372
  model["estimated_input_tokens"] for model in estimated_costs_by_model
@@ -362,7 +376,7 @@ class Jobs(Base):
362
376
  )
363
377
 
364
378
  output = {
365
- "estimated_total_cost": estimated_total_cost,
379
+ "estimated_total_cost_usd": estimated_total_cost,
366
380
  "estimated_total_input_tokens": estimated_total_input_tokens,
367
381
  "estimated_total_output_tokens": estimated_total_output_tokens,
368
382
  "model_costs": estimated_costs_by_model,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: edsl
3
- Version: 0.1.37.dev3
3
+ Version: 0.1.37.dev4
4
4
  Summary: Create and analyze LLM-based surveys
5
5
  Home-page: https://www.expectedparrot.com/
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
1
  edsl/__init__.py,sha256=Xc4AuXpEALuT7khU4CFgvV_WI9elsQ28w5RuyVx8MME,1865
2
- edsl/__version__.py,sha256=A3QLK8TySf0DLI2iYA29bIFRb2fHl1LUTU3Rz_zq6fc,29
2
+ edsl/__version__.py,sha256=dAS6KospAxXp-Jke6rn3zCdBJVHr2Z4wB3o_aH5u42g,29
3
3
  edsl/agents/__init__.py,sha256=Jw2EmdckbcROk_4tRPcJ2i-YEutApOs8BCohy3IHzqY,139
4
4
  edsl/agents/Agent.py,sha256=Eoo4ixztM2abxMjYzLdYDNx95XIvtGuiQAMN2Ue5EwE,30258
5
5
  edsl/agents/AgentList.py,sha256=VeCP_Hpk5jJ5Z5-9eYhHLtSEviOz4C_oFQBkU5DUBqs,11799
@@ -44,7 +44,7 @@ edsl/conversation/Conversation.py,sha256=al29DNlKb1QnO1pHN6pAxNSilSrWPbcClySswjQ
44
44
  edsl/conversation/mug_negotiation.py,sha256=WhdhN6dCiZ8bvpptudEnIEObkUQuy4y52-ysQSPuk54,2697
45
45
  edsl/conversation/next_speaker_utilities.py,sha256=EpGlZ_J9-vSNzezpngC58EFCfxOoN8tZ3DHBKcT3h80,3722
46
46
  edsl/coop/__init__.py,sha256=XqMfFaHIeyAb_dfDw7VaKf6wCPdahh19ye4w6XAY3R4,117
47
- edsl/coop/coop.py,sha256=2RFa72XKmnP6GBvNIMG7StUmQgHjQNrtwoRLAKkmqR8,29942
47
+ edsl/coop/coop.py,sha256=Dx6a6THS44SeopIidhbGEQaaIdZFHK23RLeuYXmVAU8,30022
48
48
  edsl/coop/PriceFetcher.py,sha256=CALznFyhdyiOylBuZFPfWg66iNVGG_q72CQMGCicfxU,1824
49
49
  edsl/coop/utils.py,sha256=r3FKAsNYnJ_bTTDKrq_TDubJrXnbW5lN3JzNExYHzuM,3732
50
50
  edsl/data/__init__.py,sha256=LW9OLfpkTtUZFpAnB-_E72dXdhsOew53BbcgYlDcU6A,174
@@ -70,7 +70,7 @@ edsl/exceptions/results.py,sha256=E0xOzjPKTLH3wXeudl5jUJ352vh4KL4jV0K_tYyT_HY,41
70
70
  edsl/exceptions/surveys.py,sha256=D1MQzGwhZbDEqcBtgyVnVbsnn5qCZ_gsdfS8In0MsuY,591
71
71
  edsl/inference_services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  edsl/inference_services/AnthropicService.py,sha256=lm12W-vHUOByZMjz8CXuLO0vwpypI-KBumRRuWptXPo,3004
73
- edsl/inference_services/AwsBedrock.py,sha256=54Cq7hSR9K7eAcfVL7LPSBoQJCiePZ6q4Ol5WQ-KUKM,4041
73
+ edsl/inference_services/AwsBedrock.py,sha256=xhh8k0judjum-iQd9Ez1cBNovAbi3i5N5pyev7MVxaY,4193
74
74
  edsl/inference_services/AzureAI.py,sha256=NCjmm0yggie8HClcal7Gi_n4lTKM1QvW10uhs4L8ILY,9106
75
75
  edsl/inference_services/DeepInfraService.py,sha256=OKpc9E9nyJu-mOqUHs_dBwOHh9xhDHksGfsvVwJHBf8,533
76
76
  edsl/inference_services/GoogleService.py,sha256=8nQIlnKNlfP_FNtc0aZGJq1mnAW9aFnU0x8k8YMvTU4,5578
@@ -100,7 +100,7 @@ edsl/jobs/interviews/InterviewStatisticsCollection.py,sha256=gAUQ77j1tTpBrhnGo4l
100
100
  edsl/jobs/interviews/InterviewStatusDictionary.py,sha256=mxNuG6rVtiqhaeN7r7z_A0ikAqOha-nzKztsPE8YV-4,2563
101
101
  edsl/jobs/interviews/InterviewStatusLog.py,sha256=ygccC-5G58-X9rYv6kJQA0hPHMdYhSYkeRmPcT7OGLQ,3344
102
102
  edsl/jobs/interviews/ReportErrors.py,sha256=3P8umwT_WTUgC5XvwNIxwuG-s-2ddSuKzhDHH1ogpWc,1849
103
- edsl/jobs/Jobs.py,sha256=nM2H0YvRtxHmO-gpDv-uVYEqHmEOJwwmpsBLsRe7wJg,41784
103
+ edsl/jobs/Jobs.py,sha256=VRhAd-mdowqqpTRPDq4TCBnxijbhndywBelx_ZlG_wU,42363
104
104
  edsl/jobs/runners/JobsRunnerAsyncio.py,sha256=Fe_uddyLWLXfXxHXDDKs52U3J9UGwNQGD_T_Zfhgn7Y,13077
105
105
  edsl/jobs/runners/JobsRunnerStatus.py,sha256=yGRW4K-QueJbJ6wGoxfRg-131TeypwQ5is89lH8ymc4,12444
106
106
  edsl/jobs/runners/JobsRunnerStatusData.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -273,7 +273,7 @@ edsl/utilities/repair_functions.py,sha256=ZnoJsWzBRxhZnMf4yY3586nmoR_5pzktV-xWdh
273
273
  edsl/utilities/restricted_python.py,sha256=ZK4r_T3cNSvIMXTuyC6dCHVX6-ed2NRzzXUbHAcgLlw,2130
274
274
  edsl/utilities/SystemInfo.py,sha256=7xJ8MYEEx3aVFOoynu_nQqAv2ePQMyehEZOxFWMZk44,820
275
275
  edsl/utilities/utilities.py,sha256=7om9Nh9IWxusHEA2a2QuwZiaoLozbSTCIPkfKf5ZIGk,11758
276
- edsl-0.1.37.dev3.dist-info/LICENSE,sha256=hq3hkdxkn1rC8xTiiHh0VdWniMNkcS3rBozeiaKE5SQ,1132
277
- edsl-0.1.37.dev3.dist-info/METADATA,sha256=zIxI59xtjuGGG21eOCGUz32s26RNHZys2kFj9JKsT5k,4476
278
- edsl-0.1.37.dev3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
279
- edsl-0.1.37.dev3.dist-info/RECORD,,
276
+ edsl-0.1.37.dev4.dist-info/LICENSE,sha256=hq3hkdxkn1rC8xTiiHh0VdWniMNkcS3rBozeiaKE5SQ,1132
277
+ edsl-0.1.37.dev4.dist-info/METADATA,sha256=vPaelDUUNHaNIiLsi9vphW8u9gopSxLqFXBcfCyhnpY,4476
278
+ edsl-0.1.37.dev4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
279
+ edsl-0.1.37.dev4.dist-info/RECORD,,