edsl 0.1.57__py3-none-any.whl → 0.1.59__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 +23 -4
- edsl/agents/agent_list.py +36 -6
- edsl/coop/coop.py +274 -35
- edsl/coop/utils.py +63 -0
- edsl/dataset/dataset.py +74 -0
- edsl/dataset/dataset_operations_mixin.py +67 -62
- edsl/inference_services/services/test_service.py +1 -1
- edsl/interviews/exception_tracking.py +92 -20
- edsl/invigilators/invigilators.py +5 -1
- edsl/invigilators/prompt_constructor.py +299 -136
- edsl/jobs/html_table_job_logger.py +394 -48
- edsl/jobs/jobs_pricing_estimation.py +19 -114
- edsl/jobs/jobs_remote_inference_logger.py +29 -0
- edsl/jobs/jobs_runner_status.py +52 -21
- edsl/jobs/remote_inference.py +214 -30
- edsl/language_models/language_model.py +40 -3
- edsl/language_models/price_manager.py +91 -57
- edsl/prompts/prompt.py +1 -0
- edsl/questions/question_list.py +76 -20
- edsl/results/results.py +8 -1
- edsl/scenarios/file_store.py +8 -12
- edsl/scenarios/scenario.py +50 -2
- edsl/scenarios/scenario_list.py +34 -12
- edsl/surveys/survey.py +4 -0
- edsl/tasks/task_history.py +180 -6
- edsl/utilities/wikipedia.py +194 -0
- {edsl-0.1.57.dist-info → edsl-0.1.59.dist-info}/METADATA +4 -3
- {edsl-0.1.57.dist-info → edsl-0.1.59.dist-info}/RECORD +32 -32
- edsl/language_models/compute_cost.py +0 -78
- {edsl-0.1.57.dist-info → edsl-0.1.59.dist-info}/LICENSE +0 -0
- {edsl-0.1.57.dist-info → edsl-0.1.59.dist-info}/WHEEL +0 -0
- {edsl-0.1.57.dist-info → edsl-0.1.59.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
import asyncio
|
2
|
+
import aiohttp
|
3
|
+
import time
|
4
|
+
import re
|
5
|
+
from typing import List
|
6
|
+
|
7
|
+
def clean_text(text):
|
8
|
+
"""Clean text by jinja2 braces
|
9
|
+
If the text contains {{ or }} then replace it with the empty string
|
10
|
+
"""
|
11
|
+
return re.sub(r'({{.*?}})', '', text)
|
12
|
+
|
13
|
+
|
14
|
+
async def fetch_wikipedia_content_async(search_terms: List[str], concurrency_limit=20):
|
15
|
+
"""
|
16
|
+
Asynchronously fetch Wikipedia content for multiple search terms.
|
17
|
+
|
18
|
+
Args:
|
19
|
+
search_terms (list): List of search terms to look up on Wikipedia
|
20
|
+
concurrency_limit (int): Maximum number of concurrent requests
|
21
|
+
|
22
|
+
Returns:
|
23
|
+
list: List of dictionaries containing search results
|
24
|
+
"""
|
25
|
+
async def fetch_wiki_search(session, search_term):
|
26
|
+
"""Search for a Wikipedia page"""
|
27
|
+
search_url = "https://en.wikipedia.org/w/api.php"
|
28
|
+
search_params = {
|
29
|
+
"action": "query",
|
30
|
+
"format": "json",
|
31
|
+
"list": "search",
|
32
|
+
"srsearch": search_term,
|
33
|
+
"utf8": "1"
|
34
|
+
}
|
35
|
+
|
36
|
+
async with session.get(search_url, params=search_params) as response:
|
37
|
+
search_data = await response.json()
|
38
|
+
|
39
|
+
if "query" in search_data and search_data["query"]["search"]:
|
40
|
+
return {
|
41
|
+
"search_term": search_term,
|
42
|
+
"title": search_data["query"]["search"][0]["title"],
|
43
|
+
"found": True
|
44
|
+
}
|
45
|
+
else:
|
46
|
+
return {
|
47
|
+
"search_term": search_term,
|
48
|
+
"found": False
|
49
|
+
}
|
50
|
+
|
51
|
+
async def fetch_wiki_content(session, page_title):
|
52
|
+
"""Fetch content of a Wikipedia page"""
|
53
|
+
content_url = "https://en.wikipedia.org/w/api.php"
|
54
|
+
content_params = {
|
55
|
+
"action": "query",
|
56
|
+
"format": "json",
|
57
|
+
"titles": page_title,
|
58
|
+
"prop": "extracts|pageimages|categories|links|info",
|
59
|
+
"explaintext": "1",
|
60
|
+
"exsectionformat": "plain",
|
61
|
+
"inprop": "url",
|
62
|
+
"pithumbsize": "100", # Get a small thumbnail if available
|
63
|
+
"cllimit": "20", # Limit to 20 categories
|
64
|
+
"plimit": "20", # Limit to 20 links
|
65
|
+
"redirects": "1" # Follow redirects
|
66
|
+
}
|
67
|
+
|
68
|
+
async with session.get(content_url, params=content_params) as response:
|
69
|
+
content_data = await response.json()
|
70
|
+
page_id = list(content_data["query"]["pages"].keys())[0]
|
71
|
+
|
72
|
+
if page_id != "-1": # -1 indicates page not found
|
73
|
+
page_data = content_data["query"]["pages"][page_id]
|
74
|
+
|
75
|
+
result = {
|
76
|
+
"title": page_data.get("title", ""),
|
77
|
+
"page_id": page_id,
|
78
|
+
"content": clean_text(page_data.get("extract", "")),
|
79
|
+
"url": page_data.get("fullurl", ""),
|
80
|
+
"last_modified": page_data.get("touched", "")
|
81
|
+
}
|
82
|
+
|
83
|
+
# Add categories if available
|
84
|
+
if "categories" in page_data:
|
85
|
+
result["categories"] = [cat["title"].replace("Category:", "")
|
86
|
+
for cat in page_data["categories"]]
|
87
|
+
|
88
|
+
# Add links if available
|
89
|
+
if "links" in page_data:
|
90
|
+
result["links"] = [link["title"] for link in page_data["links"]]
|
91
|
+
|
92
|
+
# Add thumbnail if available
|
93
|
+
if "thumbnail" in page_data:
|
94
|
+
result["thumbnail"] = page_data["thumbnail"].get("source", "")
|
95
|
+
|
96
|
+
return result
|
97
|
+
else:
|
98
|
+
return {
|
99
|
+
"title": page_title,
|
100
|
+
"error": "Page not found"
|
101
|
+
}
|
102
|
+
|
103
|
+
async def process_wiki_item(session, search_term):
|
104
|
+
"""Process a single search term to get Wikipedia content"""
|
105
|
+
search_result = await fetch_wiki_search(session, search_term)
|
106
|
+
|
107
|
+
if search_result["found"]:
|
108
|
+
content_result = await fetch_wiki_content(session, search_result["title"])
|
109
|
+
|
110
|
+
# Create a complete result
|
111
|
+
result = {
|
112
|
+
"search_term": search_term,
|
113
|
+
"status": "Success",
|
114
|
+
**content_result
|
115
|
+
}
|
116
|
+
|
117
|
+
return result
|
118
|
+
else:
|
119
|
+
return {
|
120
|
+
"search_term": search_term,
|
121
|
+
"status": "Not found"
|
122
|
+
}
|
123
|
+
|
124
|
+
start_time = time.time()
|
125
|
+
|
126
|
+
# Create a ClientSession that will be used for all requests
|
127
|
+
async with aiohttp.ClientSession(
|
128
|
+
headers={"User-Agent": "WikiBatchFetcher/1.0 (your@email.com)"}
|
129
|
+
) as session:
|
130
|
+
# Create semaphore to limit concurrency
|
131
|
+
semaphore = asyncio.Semaphore(concurrency_limit)
|
132
|
+
|
133
|
+
async def bounded_process(search_term):
|
134
|
+
async with semaphore:
|
135
|
+
return await process_wiki_item(session, search_term)
|
136
|
+
|
137
|
+
# Create tasks for all search terms
|
138
|
+
tasks = [bounded_process(term) for term in search_terms]
|
139
|
+
|
140
|
+
# Wait for all tasks to complete
|
141
|
+
results = await asyncio.gather(*tasks)
|
142
|
+
|
143
|
+
end_time = time.time()
|
144
|
+
|
145
|
+
# Log summary statistics
|
146
|
+
success_count = sum(1 for r in results if r.get("status") == "Success")
|
147
|
+
#print(f"Processed {len(search_terms)} search terms in {end_time - start_time:.2f} seconds")
|
148
|
+
#print(f"Successfully retrieved {success_count} pages")
|
149
|
+
|
150
|
+
return results
|
151
|
+
|
152
|
+
def fetch_wikipedia_content(search_terms, concurrency_limit=20):
|
153
|
+
"""
|
154
|
+
Synchronous wrapper for the async function to fetch Wikipedia content
|
155
|
+
|
156
|
+
Args:
|
157
|
+
search_terms (list): List of search terms to look up on Wikipedia
|
158
|
+
concurrency_limit (int): Maximum number of concurrent requests
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
list: List of dictionaries containing search results
|
162
|
+
"""
|
163
|
+
return asyncio.run(
|
164
|
+
fetch_wikipedia_content_async(
|
165
|
+
search_terms=search_terms,
|
166
|
+
concurrency_limit=concurrency_limit
|
167
|
+
)
|
168
|
+
)
|
169
|
+
|
170
|
+
# Example usage
|
171
|
+
if __name__ == "__main__":
|
172
|
+
# Example search terms
|
173
|
+
search_terms = [
|
174
|
+
"Tommy Tuberville",
|
175
|
+
"Albert Einstein",
|
176
|
+
"Marie Curie"
|
177
|
+
]
|
178
|
+
|
179
|
+
# Call the function
|
180
|
+
results = fetch_wikipedia_content(
|
181
|
+
search_terms=search_terms,
|
182
|
+
concurrency_limit=20
|
183
|
+
)
|
184
|
+
|
185
|
+
# Print a sample of the results
|
186
|
+
for result in results:
|
187
|
+
print(f"\nSearch term: {result['search_term']}")
|
188
|
+
print(f"Status: {result['status']}")
|
189
|
+
if result['status'] == 'Success':
|
190
|
+
print(f"Title: {result['title']}")
|
191
|
+
print(f"URL: {result['url']}")
|
192
|
+
print(f"Content length: {len(result['content'])} characters")
|
193
|
+
if 'categories' in result:
|
194
|
+
print(f"Categories: {', '.join(result['categories'][:3])}...")
|
@@ -1,18 +1,19 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: edsl
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.59
|
4
4
|
Summary: Create and analyze LLM-based surveys
|
5
5
|
Home-page: https://www.expectedparrot.com/
|
6
6
|
License: MIT
|
7
7
|
Keywords: LLM,social science,surveys,user research
|
8
8
|
Author: John Horton
|
9
9
|
Author-email: info@expectedparrot.com
|
10
|
-
Requires-Python: >=3.9.1,<3.
|
10
|
+
Requires-Python: >=3.9.1,<3.14
|
11
11
|
Classifier: License :: OSI Approved :: MIT License
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
16
17
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
17
18
|
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
18
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
@@ -249,5 +250,5 @@ Choose whether to run surveys on your own computer or at the Expected Parrot ser
|
|
249
250
|
Easily share workflows and projects privately or publicly at Coop: an integrated platform for AI-based research. Your account comes with free credits for running surveys, and lets you securely share keys, track expenses and usage for your team.
|
250
251
|
|
251
252
|
**Built-in tools for analyis**:
|
252
|
-
Analyze results as specified datasets from your account or workspace. Easily import data to use with your surveys and export results
|
253
|
+
Analyze results as specified datasets from your account or workspace. Easily import data to use with your surveys and export results.
|
253
254
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
edsl/__init__.py,sha256=EkpMsEKqKRbN9Qqcn_y8CjX8OjlWFyhxslLrt3SJY0Q,4827
|
2
2
|
edsl/__init__original.py,sha256=PzMzANf98PrSleSThXT4anNkeVqZMdw0tfFonzsoiGk,4446
|
3
|
-
edsl/__version__.py,sha256=
|
3
|
+
edsl/__version__.py,sha256=6ejKyHgulDwYDrT6JBlbHrh83UmxgavrhSuOolniIfI,23
|
4
4
|
edsl/agents/__init__.py,sha256=AyhfXjygRHT1Pd9w16lcu5Bu0jnBmMPz86aKP1uRL3Y,93
|
5
|
-
edsl/agents/agent.py,sha256=
|
6
|
-
edsl/agents/agent_list.py,sha256
|
5
|
+
edsl/agents/agent.py,sha256=omq3lnEujOObKuDyr0seaTiRL7SbJxMjF6bZXqiTt7c,56296
|
6
|
+
edsl/agents/agent_list.py,sha256=k29SMOP2trdYWJs5-tPIfpme97fcnanL1lDhhJK3zfg,24249
|
7
7
|
edsl/agents/descriptors.py,sha256=TfFQWJqhqTWyH89DkNmK6qtH3xV2fUyW9FbI5KnZXv0,4592
|
8
8
|
edsl/agents/exceptions.py,sha256=7KMAtAHKqlkVkd_iVZC_mWXQnzDPV0V_n2iXaGAQgzc,5661
|
9
9
|
edsl/base/__init__.py,sha256=h119NxrAJOV92jnX7ussXNjKFXqzySVGOjMG3G7Zkzc,992
|
@@ -40,7 +40,7 @@ edsl/conversation/exceptions.py,sha256=DoUCg-ymqGOjOl0cpGT8-sNRVsr3SEwdxGAKtdeZ2
|
|
40
40
|
edsl/conversation/mug_negotiation.py,sha256=do3PTykM6A2cDGOcsohlevRgLpCICoPx8B0WIYe6hy8,2518
|
41
41
|
edsl/conversation/next_speaker_utilities.py,sha256=bqr5JglCd6bdLc9IZ5zGOAsmN2F4ERiubSMYvZIG7qk,3629
|
42
42
|
edsl/coop/__init__.py,sha256=DU2w1Nu8q6tMAa3xoPC722RrvGhmB_UgUUBJDUywsKY,1542
|
43
|
-
edsl/coop/coop.py,sha256=
|
43
|
+
edsl/coop/coop.py,sha256=YfV-jVUlM9Jw2s5x_4uN8RPUEDW3GDoqtYrduPx_ABc,74929
|
44
44
|
edsl/coop/coop_functions.py,sha256=d31kddfj9MVZaMhqwUvkSIBwrdCTQglIvFWVfUr4NuE,688
|
45
45
|
edsl/coop/coop_jobs_objects.py,sha256=_OFPVLKswXY9mKl9b3Y7gxlUhaMZ7GULx5OqyANpecU,1701
|
46
46
|
edsl/coop/coop_objects.py,sha256=_cEspdAxh7BT672poxb0HsjU-QZ4Kthg-tKDvZ6I_v0,859
|
@@ -48,11 +48,11 @@ edsl/coop/coop_regular_objects.py,sha256=indDQPeesQjHEX_CkICpJPI7o-R8KX66m9DOR9Z
|
|
48
48
|
edsl/coop/ep_key_handling.py,sha256=X0tskEaYKsRIbFUijaCL69uHYpLJcLbYFITzAu3PGJE,7872
|
49
49
|
edsl/coop/exceptions.py,sha256=EY3eNTeJM15VzFnag93hgmiqn4pR3Y-6nS9ixKGIhM8,8874
|
50
50
|
edsl/coop/price_fetcher.py,sha256=uvEPgKaSRsFq-ouRl5W9aksawUkJg9Lo7ucSePecwa4,4735
|
51
|
-
edsl/coop/utils.py,sha256=
|
51
|
+
edsl/coop/utils.py,sha256=DON2ns5nWlUqqvlNVUsdgiPlz-6oEqFVOmjhnOwHQBs,8174
|
52
52
|
edsl/data_transfer_models.py,sha256=pPaKsbo9pgNcBB9kX-U2O_dUtNkd0Xm4JNmv26jrbhI,265
|
53
53
|
edsl/dataset/__init__.py,sha256=RIzfFIytKJfniKZ0VThMk8Z2fjejx91t9PZBct78xXw,422
|
54
|
-
edsl/dataset/dataset.py,sha256=
|
55
|
-
edsl/dataset/dataset_operations_mixin.py,sha256=
|
54
|
+
edsl/dataset/dataset.py,sha256=o1icaFSE2ipCj7FDqhXkPb-E42wBzn74hLD7QXg0qaE,42277
|
55
|
+
edsl/dataset/dataset_operations_mixin.py,sha256=SDGqQRg0Zdy-VMHDF1z4bChCkZ6t5iT-tP2zydAdyYs,59344
|
56
56
|
edsl/dataset/dataset_tree.py,sha256=mKLQhwo-gxDyJCwCH3gj6Os0Jk2JqfWd_PvUyuWqM6s,14268
|
57
57
|
edsl/dataset/display/CSSParameterizer.py,sha256=vI3VTgTihJeCYGfmGp7fOhTitHZ17jrDGbq46Sa2rd8,3677
|
58
58
|
edsl/dataset/display/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -93,7 +93,7 @@ edsl/inference_services/services/mistral_ai_service.py,sha256=tvwIeqhwzT6kPjrUo_
|
|
93
93
|
edsl/inference_services/services/ollama_service.py,sha256=quSKlgD0bHG9mO_s9verGePfqQi_rZWovHEQ6dy-Fe0,303
|
94
94
|
edsl/inference_services/services/open_ai_service.py,sha256=WFcl9g7Y28hckdiD_bPxRL_yJqz9ukERL3h_znh6b80,8682
|
95
95
|
edsl/inference_services/services/perplexity_service.py,sha256=7bt5Mb6Dxkb7UOljNdTBpZuT_8ri4i6Sk_h5g8paKu4,5994
|
96
|
-
edsl/inference_services/services/test_service.py,sha256=
|
96
|
+
edsl/inference_services/services/test_service.py,sha256=JUK2bch1uu5XefMhNnuAXCbTqgiMqQRAIN8xYCMNe1E,7394
|
97
97
|
edsl/inference_services/services/together_ai_service.py,sha256=biUYs07jsrIHp19O81o0nJCwYdSWudMEXdGtmA1-y60,6151
|
98
98
|
edsl/inference_services/services/xai_service.py,sha256=hJbXF26DuFTZdy0lYT1wo3yyuWDcwcXA6EiGYUahK1w,280
|
99
99
|
edsl/inference_services/write_available.py,sha256=9L8chJb8iafHfwRBfqZKjMjkSBRWUa5gEe7F0mxsZu0,261
|
@@ -106,7 +106,7 @@ edsl/instructions/instruction_handler.py,sha256=MXy0LSyAUE5H2G8Pdhs-WerZM8VWGqNR
|
|
106
106
|
edsl/interviews/ReportErrors.py,sha256=5NC6fFGaVe6Qk4gnFd7fUFRsw9MKb7g4MFOr-EblS0o,1728
|
107
107
|
edsl/interviews/__init__.py,sha256=BC6NBomroZEc8uwOeZBMtVuXwAVQzTzm7kkgDBqEBic,328
|
108
108
|
edsl/interviews/answering_function.py,sha256=zmUMGP1xSpDm49_dqj39g8BoGGy0OmhlcUrJQvUyio8,13695
|
109
|
-
edsl/interviews/exception_tracking.py,sha256=
|
109
|
+
edsl/interviews/exception_tracking.py,sha256=2DTpDHGq_7ItZ7O3AUtKM8Wmox2EEqZi28xtCYtYHRU,13206
|
110
110
|
edsl/interviews/exceptions.py,sha256=qID-2HnSHJt5DyxBQd4698GZfTEu8rwk_VbIrBHcIRc,2626
|
111
111
|
edsl/interviews/interview.py,sha256=LyLY6kbjeUih_DREgIU38AIkrSWsKqSSgoVoLiUMlCE,26450
|
112
112
|
edsl/interviews/interview_status_dictionary.py,sha256=0ZvXLusfOA8xD_Fco4PjEBGwmR2sizHOGijTQI8RrI8,3031
|
@@ -118,8 +118,8 @@ edsl/interviews/statistics.py,sha256=lZCtq79QrDKG3jXao_OWuBRhnly9VyuhM6IdTJaYqPg
|
|
118
118
|
edsl/invigilators/__init__.py,sha256=fKbZ7p9-kMelpvET3Ku2Owu-tL_apC-8gi9JychpMBY,1843
|
119
119
|
edsl/invigilators/exceptions.py,sha256=ejoF-Gt-YcnW1yHyfpJ3jZm8AC_zD0GCYafRO2LlAMQ,2767
|
120
120
|
edsl/invigilators/invigilator_base.py,sha256=DgrXTK4AAxXr4wg2pzc0p1aGPPf1UUt01C-JW1UBTvo,20099
|
121
|
-
edsl/invigilators/invigilators.py,sha256=
|
122
|
-
edsl/invigilators/prompt_constructor.py,sha256=
|
121
|
+
edsl/invigilators/invigilators.py,sha256=8RyV8_8wc3tLMjUHJhyJLDq7CrFMo4X9gEVQz-pOks4,24025
|
122
|
+
edsl/invigilators/prompt_constructor.py,sha256=_Bh0MHWcNk0friHpDJ8F6L6JAZKf95-06lZB8U0caUQ,25266
|
123
123
|
edsl/invigilators/prompt_helpers.py,sha256=LuMZFZkInPY8M7Rw9fG9rpJIcT89tr2_Iq10ZHH_Y4A,5409
|
124
124
|
edsl/invigilators/question_instructions_prompt_builder.py,sha256=E5zpwctpt_5JjONkZRcMwB0MACAzDvvnzUhmuWTnjd0,9684
|
125
125
|
edsl/invigilators/question_option_processor.py,sha256=TRJgeFUH4m2EUlkjWkXnMWiE_CXQjO0gHyPOd_qjbec,9504
|
@@ -131,17 +131,17 @@ edsl/jobs/data_structures.py,sha256=i-XXq2zul1K1aOZDZXbPIO8l-0bJLqDL2t7pxITXbks,
|
|
131
131
|
edsl/jobs/decorators.py,sha256=0Eot9pFPsWmQIJAafNd0f5hdb9RUAFp_hGMmSUTJ_C8,3272
|
132
132
|
edsl/jobs/exceptions.py,sha256=5lktTya2VgiBR5Bd977tG2xHdrMjDqhPhQO17O6jIdc,7220
|
133
133
|
edsl/jobs/fetch_invigilator.py,sha256=nzXAIulvOvuDpRDEN5TDNmEfikUEwrnS_XCtnYG2uPQ,2795
|
134
|
-
edsl/jobs/html_table_job_logger.py,sha256=
|
134
|
+
edsl/jobs/html_table_job_logger.py,sha256=2ErAIi_Dgv_Y3l-AZ2bPUJO_X8hSrPfeFT9lEjt8X4g,34762
|
135
135
|
edsl/jobs/jobs.py,sha256=WL3ODJ4HBElnw2XVaPXqfvHzyTsEe0XeUghOZOyI0FA,42334
|
136
136
|
edsl/jobs/jobs_checks.py,sha256=bfPJ3hQ4qvRBhyte4g-4J8zExJxJr3nlLHmtVmFPJcQ,5390
|
137
137
|
edsl/jobs/jobs_component_constructor.py,sha256=9956UURv3eo-cURNPd4EV8wAQsY-AlEtQRmBu1nCOH8,6982
|
138
138
|
edsl/jobs/jobs_interview_constructor.py,sha256=8nIhhwBQWH_aZ9ZWjvRgOL0y2y6juRTb3pVngQ9Cs8g,2017
|
139
|
-
edsl/jobs/jobs_pricing_estimation.py,sha256=
|
140
|
-
edsl/jobs/jobs_remote_inference_logger.py,sha256=
|
141
|
-
edsl/jobs/jobs_runner_status.py,sha256=
|
139
|
+
edsl/jobs/jobs_pricing_estimation.py,sha256=OsCQHR-HuATPQDyND00HJ47CWqcAFNuhOb0KbbceoaU,14349
|
140
|
+
edsl/jobs/jobs_remote_inference_logger.py,sha256=4I3DjIzxfWHjWBr7o_JPhj9f8M4LuuPisCtQxjSFkxA,10132
|
141
|
+
edsl/jobs/jobs_runner_status.py,sha256=gW8EA-BAKpBvahqRipzomALEAQizd24aRW8G2y7faLQ,11905
|
142
142
|
edsl/jobs/jobs_status_enums.py,sha256=8Kgtr-ffcGGniQ2x5gCOqwURb_HaBWmYcWbUB_KTCY0,214
|
143
143
|
edsl/jobs/progress_bar_manager.py,sha256=d8wuZf7SHq3LCA36JIv1sfYymyHFOUsYRSRlRpR6K04,2832
|
144
|
-
edsl/jobs/remote_inference.py,sha256=
|
144
|
+
edsl/jobs/remote_inference.py,sha256=iO_ObqHL0fkn9-f-oPCEf3UqfX9BUlVhjycjy_i4LHM,22616
|
145
145
|
edsl/jobs/results_exceptions_handler.py,sha256=VCtnd60xwdFznzGhtXPbxLmyVf3kIjR2419LUJdFjEQ,3053
|
146
146
|
edsl/key_management/__init__.py,sha256=JiOJ71Ly9aw-tVYbWZu-qRjsW4QETYMQ9IJjsKgW1DQ,1274
|
147
147
|
edsl/key_management/exceptions.py,sha256=dDtoDh1UL52BUBrAlCIc_McgtZCAQkUx6onoSz26qeM,2158
|
@@ -150,12 +150,11 @@ edsl/key_management/key_lookup_builder.py,sha256=AlQxXbUYwyJc-3JjLddXBOBPVsYJ-B2
|
|
150
150
|
edsl/key_management/key_lookup_collection.py,sha256=b1STYU4FIqgCtCf90bRZh6IXf8kcoTC8ad8RSHPmw-w,3471
|
151
151
|
edsl/key_management/models.py,sha256=z9TimNMnz47mnITM5SlJy2m2sk1aKKtt0ybV89rsaiY,6703
|
152
152
|
edsl/language_models/__init__.py,sha256=WtefJs6XOCn5RSz22PgoAi3eTEr1NzGtnnBpDIie2mg,240
|
153
|
-
edsl/language_models/compute_cost.py,sha256=noWk0osCANksfKSh0sXFkPrcQegtSV8-jCRBjz_52uQ,2570
|
154
153
|
edsl/language_models/exceptions.py,sha256=P9dMA8XfK_qcuXNJZ-Xsb_Ny-12Ldu3fPC133RB40Ek,13728
|
155
|
-
edsl/language_models/language_model.py,sha256=
|
154
|
+
edsl/language_models/language_model.py,sha256=gN3qW1NUK4kPl_CfgMKUd8ORdSB0iEZC0miuZDsCQUw,46462
|
156
155
|
edsl/language_models/model.py,sha256=oYZsfgvko_EH4EWT9XZPEgLcs9KA36SGEAKZwYRFjv8,12013
|
157
156
|
edsl/language_models/model_list.py,sha256=Eb62xQdrlayqWYyJVgYxheMiNi14e1U9b_12qYzy1ws,4522
|
158
|
-
edsl/language_models/price_manager.py,sha256=
|
157
|
+
edsl/language_models/price_manager.py,sha256=74XEkoVdQv06w7gMFZmXeeXGW6om4_ISr-qFnmX4lFE,10711
|
159
158
|
edsl/language_models/raw_response_handler.py,sha256=i2Ye1WzjYq_2YJ1EKX946dx9m331GilwqC5qymGJlEI,4003
|
160
159
|
edsl/language_models/registry.py,sha256=io_Cp-7PtLpPuvZs_j8XaMxJiv-zSplbAQdrzPp2pzg,7308
|
161
160
|
edsl/language_models/repair.py,sha256=ljm0xc9e1tMdyKc9b-v7ikpYRBh639xJ11SkDzI2vZE,5245
|
@@ -179,7 +178,7 @@ edsl/plugins/plugin_manager.py,sha256=ifuJLgcySmLvGOc8ka8tSj-3d6ju0NknEK22pLF1L8
|
|
179
178
|
edsl/plugins/plugins_registry.py,sha256=stAaq6vkuurHc3ViHrLj5g2VomMpsLD9ufa-k-HHfgk,5165
|
180
179
|
edsl/prompts/__init__.py,sha256=4UREcqKC6SIfYykwZbaCeXI5hEil0u2x5GQKasn_NLU,653
|
181
180
|
edsl/prompts/exceptions.py,sha256=AcQCy8JGmS8ODCvRtu4aCH14OEI-oYxF0tX-ZAZ3Puk,4460
|
182
|
-
edsl/prompts/prompt.py,sha256=
|
181
|
+
edsl/prompts/prompt.py,sha256=mFCOAEHHKJ5RGMRtdkTlNMmRmsem-XligJjRVlO-PbY,14221
|
183
182
|
edsl/questions/ExceptionExplainer.py,sha256=BgM80FRPJjS_TrY6XaVmlT666MzY9DEagviGQj9-WEQ,2868
|
184
183
|
edsl/questions/HTMLQuestion.py,sha256=lx3Sysm6fMZmFc9hifnkGslt7ZBpDEvziM9-IJFMJLU,3238
|
185
184
|
edsl/questions/Quick.py,sha256=HRLT2Lmhd1Gj4ggkrpCMYhzeWsRwlQaigu2EzdiXb5Q,1717
|
@@ -211,7 +210,7 @@ edsl/questions/question_free_text.py,sha256=Oaw7C5BCclCiaWJlWHQJFEPppKxT7zWBFyIb
|
|
211
210
|
edsl/questions/question_functional.py,sha256=iwFlJmXBoFDu5D4tZ4Ci_yhfQo8_tB9C3W5I2p7KipA,9524
|
212
211
|
edsl/questions/question_likert_five.py,sha256=MG1R7I7KZjAff7qhMQ0b462GJRC6MKgUZBP4wiqqmio,6547
|
213
212
|
edsl/questions/question_linear_scale.py,sha256=OSGV6vwoAgDKoZhudqKiUPpJY8iMpHWNkCr0KlTZrpc,3350
|
214
|
-
edsl/questions/question_list.py,sha256=
|
213
|
+
edsl/questions/question_list.py,sha256=CkmR3LntXyAiQUrVZLZTlniK5D8WMTDcQqwMWJwL9_A,20697
|
215
214
|
edsl/questions/question_matrix.py,sha256=Okg3sRboG4C1ArTSgUXUWlJJzWqsUimgB1lYtI9Hq8o,37397
|
216
215
|
edsl/questions/question_multiple_choice.py,sha256=uTWZ0FGE8czIxmiZ_6mvc8KR5efpatZo_egid1WrHgc,23679
|
217
216
|
edsl/questions/question_multiple_choice_with_other.py,sha256=J0_3V5SfetQzqqVMgTIZ5TUwiY4X-bMCogSqquG0tzQ,23624
|
@@ -280,7 +279,7 @@ edsl/results/__init__.py,sha256=RKbHY0g6s_k42VcdmTOZ2yB_nltiJnnbeQAkUY5WD9o,129
|
|
280
279
|
edsl/results/exceptions.py,sha256=u-TQsazt_qj-G4eJKBnj0UtpnIiw6A2GcCLJ2wTYE_g,6536
|
281
280
|
edsl/results/report.py,sha256=oHjMY981Gn8estqvoTk5SPiuEOIM0IR_QPBrRLdk5pM,7481
|
282
281
|
edsl/results/result.py,sha256=5cT7ikHDoNASGINRLDRCpMokusz0Plx5iq7LJ9pgK5I,29723
|
283
|
-
edsl/results/results.py,sha256=
|
282
|
+
edsl/results/results.py,sha256=BOy_NfRAWu9Q_JeuMtfG04oQhE7hMuiJ-WAH6_ov6Vk,84973
|
284
283
|
edsl/results/results_selector.py,sha256=4_XMS2Fb-3rcXEPUYaBRw52r1i66jttjttqNFe6PRc4,18050
|
285
284
|
edsl/scenarios/DocxScenario.py,sha256=ul3nkX826m_T6LFptswqtnH5czP_yxMlLWgbTmFIZI4,482
|
286
285
|
edsl/scenarios/PdfExtractor.py,sha256=6nPZ6v9x2RrU42EkqlEcW3MS-WIQpGfwg4--6WvEC8I,1972
|
@@ -290,7 +289,7 @@ edsl/scenarios/directory_scanner.py,sha256=xv-3HHRPsyGa8m6mHpqLjK-UBC-nhG9gz3VC5
|
|
290
289
|
edsl/scenarios/document_chunker.py,sha256=EpB0V0oxLzpKntl00Qa3VZNPS7sg9aXdYyqKxhFFzTM,7680
|
291
290
|
edsl/scenarios/exceptions.py,sha256=FeORBm90UthKHDp7cE8I7KJgyA3-pFKNpoivZRr8ifc,10636
|
292
291
|
edsl/scenarios/file_methods.py,sha256=LkN7mZsadRaiNhvKPP_jY7OhUMEsfhEEFY-hpnwdplM,2794
|
293
|
-
edsl/scenarios/file_store.py,sha256=
|
292
|
+
edsl/scenarios/file_store.py,sha256=YmcI9DcHwbTmsYk5RARpAHRuwjfM2RAL3kVjh5WnCn0,32910
|
294
293
|
edsl/scenarios/handlers/__init__.py,sha256=_-A6vXzQPKga7fDyteDt1QPA6lDwmgERJKG8SrdhYxQ,965
|
295
294
|
edsl/scenarios/handlers/csv_file_store.py,sha256=kXOms0ph5JJj6jSbpfQ-SZjuT4vvSRhq5AGpv1L4TPQ,1369
|
296
295
|
edsl/scenarios/handlers/docx_file_store.py,sha256=KSKAAUIWF2K5xr92nx7UGQ9djgtDX4ke-Eyik8QAdlQ,2155
|
@@ -308,9 +307,9 @@ edsl/scenarios/handlers/sql_file_store.py,sha256=wa_Qw1-bk-tHhtQrp1IAxSAROygEQ5F
|
|
308
307
|
edsl/scenarios/handlers/sqlite_file_store.py,sha256=rwsfxD5G_XNEa-aRCx6A83lW0i2OiS51EzYsJeTE7ps,4936
|
309
308
|
edsl/scenarios/handlers/txt_file_store.py,sha256=oGMqm2X_dWTt0W2e2zDung2i_A_z2mMmm4rrQImnVtU,980
|
310
309
|
edsl/scenarios/handlers/webm_file_store.py,sha256=UG3sPwsxbZAjM1H9rbpdkvXMrS3iRbaaN-4VNGh3JX8,3659
|
311
|
-
edsl/scenarios/scenario.py,sha256=
|
310
|
+
edsl/scenarios/scenario.py,sha256=3LQhJ8QSVaatuV2DZOJwJDRgrwyx2zmOE0B-7AIVTtI,39184
|
312
311
|
edsl/scenarios/scenario_join.py,sha256=1r_czZctN7JKbw38bQolKdz0kBaMqhWzo8IsxzHK1TY,5409
|
313
|
-
edsl/scenarios/scenario_list.py,sha256=
|
312
|
+
edsl/scenarios/scenario_list.py,sha256=GfUvYHgSMyvBbYJZ1f7YvodcQ9DhLyrR3DrKB4R7nsI,87652
|
314
313
|
edsl/scenarios/scenario_list_gc_test.py,sha256=VaZBg_GjfSaM92Gj3eiSt3aQ_rECDfD339ZCTqryfdc,4676
|
315
314
|
edsl/scenarios/scenario_list_memory_test.py,sha256=l_PeTJkh0MYQoRLIiFOI8hmzEyjf86_PG7UvU-2-l_o,7138
|
316
315
|
edsl/scenarios/scenario_list_pdf_tools.py,sha256=sehQro5PzJ7Y4Ck9VJ8HTxKN8HSbk3aDipVYuxaJbdI,7686
|
@@ -334,7 +333,7 @@ edsl/surveys/rules/__init__.py,sha256=yXrL1uzhv1PdndhI4ArR5-QyMy18Q1Unv3AXpjswHj
|
|
334
333
|
edsl/surveys/rules/rule.py,sha256=S9XnZNSSHMK8E2HZ4w0imJjCW8RpoD3DZ1p1vSKDp40,15130
|
335
334
|
edsl/surveys/rules/rule_collection.py,sha256=KK3xyklLYyQL5ubFFX_UWXUFM0rLcZgv8L2ofZBBjYo,14140
|
336
335
|
edsl/surveys/rules/rule_manager.py,sha256=SD3wNFlEzmUBzpJsecrup-BugKU2dF5E4XWYyKd-EXg,6332
|
337
|
-
edsl/surveys/survey.py,sha256=
|
336
|
+
edsl/surveys/survey.py,sha256=zDmpuPVZlRjNYrB0wFf56BjkbrMjdwY5hGYMTjndCYs,72665
|
338
337
|
edsl/surveys/survey_css.py,sha256=-WetQGjvGkp8W4jq94XCHewvzbOLBKPCpsxIjRi2hG8,8789
|
339
338
|
edsl/surveys/survey_export.py,sha256=rmlRdLW_KYuzkPxM65NU0DZlihH-67tUoCBc7I-7VxQ,8275
|
340
339
|
edsl/surveys/survey_flow_visualization.py,sha256=aEmmwYeaa2YaTILEwsRANPfmNLut_oCmUd9iHPBtXwA,9550
|
@@ -343,7 +342,7 @@ edsl/tasks/__init__.py,sha256=24Uw8dEDLoHfyJgNgjHOcJ_dKjjZZz68FH0PUC7M0bE,2000
|
|
343
342
|
edsl/tasks/exceptions.py,sha256=vi-ns7T8UrdOQD9PBSO-8hYlXgoperykX5c2hrYaNg4,2022
|
344
343
|
edsl/tasks/question_task_creator.py,sha256=ZSht6I3k5JjQaARufj1hdJbvWltwUzx40ikvmAjL0FA,12110
|
345
344
|
edsl/tasks/task_creators.py,sha256=u-CxzB0Qv90PDkfi0bQV3EAT89co9fXIal5JOUPcKls,5616
|
346
|
-
edsl/tasks/task_history.py,sha256=
|
345
|
+
edsl/tasks/task_history.py,sha256=YvAM99jnWhQtzrlR4q7UQgxJk6dakbzsria9MHuBPjs,36438
|
347
346
|
edsl/tasks/task_status_enum.py,sha256=cQSJMcswLGdknO7tvNZBZV05T_TZV-MEBY3DxyLzTo0,9032
|
348
347
|
edsl/tasks/task_status_log.py,sha256=dbeZ5LUCJzWzBbMEIRUZKP1hjANJy7enyTiEU7hwS8w,3165
|
349
348
|
edsl/templates/error_reporting/base.html,sha256=BsPp87_XfLJZA4V0oPF8ulmTFyPHgB3KyPEJkgSxsmQ,1299
|
@@ -382,8 +381,9 @@ edsl/utilities/repair_functions.py,sha256=EXkXsqnmgPqj9b3dff1cZnJyaZw-qEvGENXCRH
|
|
382
381
|
edsl/utilities/restricted_python.py,sha256=248N2p5EWHDSpcK1G-q7DUoJeWy4sB6aO-RV0-5O7uY,2038
|
383
382
|
edsl/utilities/template_loader.py,sha256=SCAcnTnxNQ67MNSkmfz7F-S_u2peyGn2j1oRIqi1wfg,870
|
384
383
|
edsl/utilities/utilities.py,sha256=irHheAGOnl_6RwI--Hi9StVzvsHcWCqB48PWsWJQYOw,12045
|
385
|
-
edsl
|
386
|
-
edsl-0.1.
|
387
|
-
edsl-0.1.
|
388
|
-
edsl-0.1.
|
389
|
-
edsl-0.1.
|
384
|
+
edsl/utilities/wikipedia.py,sha256=I3Imbz3fzbaoA0ZLDsWUO2YpP_ovvaqtu-yd2Ye1BB0,6933
|
385
|
+
edsl-0.1.59.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
|
386
|
+
edsl-0.1.59.dist-info/METADATA,sha256=FxWojFvdFs_p5nVxCwWquIeheS8yTHhAwXcGECq2ejg,12082
|
387
|
+
edsl-0.1.59.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
388
|
+
edsl-0.1.59.dist-info/entry_points.txt,sha256=JnG7xqMtHaQu9BU-yPATxdyCeA48XJpuclnWCqMfIMU,38
|
389
|
+
edsl-0.1.59.dist-info/RECORD,,
|
@@ -1,78 +0,0 @@
|
|
1
|
-
from typing import Any, Union, TYPE_CHECKING
|
2
|
-
|
3
|
-
if TYPE_CHECKING:
|
4
|
-
from .language_model import LanguageModel
|
5
|
-
|
6
|
-
class ComputeCost:
|
7
|
-
"""Computes the dollar cost of a raw response.
|
8
|
-
|
9
|
-
# TODO: Add doctests
|
10
|
-
>>> True
|
11
|
-
True
|
12
|
-
|
13
|
-
"""
|
14
|
-
def __init__(self, language_model: "LanguageModel"):
|
15
|
-
self.language_model = language_model
|
16
|
-
self._price_lookup = None
|
17
|
-
|
18
|
-
@property
|
19
|
-
def price_lookup(self):
|
20
|
-
if self._price_lookup is None:
|
21
|
-
from ..coop import Coop
|
22
|
-
|
23
|
-
c = Coop()
|
24
|
-
self._price_lookup = c.fetch_prices()
|
25
|
-
return self._price_lookup
|
26
|
-
|
27
|
-
def cost(self, raw_response: dict[str, Any]) -> Union[float, str]:
|
28
|
-
"""Return the dollar cost of a raw response."""
|
29
|
-
|
30
|
-
usage = self.get_usage_dict(raw_response)
|
31
|
-
from ..coop import Coop
|
32
|
-
|
33
|
-
c = Coop()
|
34
|
-
price_lookup = c.fetch_prices()
|
35
|
-
key = (self._inference_service_, self.model)
|
36
|
-
if key not in price_lookup:
|
37
|
-
return f"Could not find price for model {self.model} in the price lookup."
|
38
|
-
|
39
|
-
relevant_prices = price_lookup[key]
|
40
|
-
try:
|
41
|
-
input_tokens = int(usage[self.input_token_name])
|
42
|
-
output_tokens = int(usage[self.output_token_name])
|
43
|
-
except Exception as e:
|
44
|
-
return f"Could not fetch tokens from model response: {e}"
|
45
|
-
|
46
|
-
try:
|
47
|
-
inverse_output_price = relevant_prices["output"]["one_usd_buys"]
|
48
|
-
inverse_input_price = relevant_prices["input"]["one_usd_buys"]
|
49
|
-
except Exception as e:
|
50
|
-
if "output" not in relevant_prices:
|
51
|
-
return f"Could not fetch prices from {relevant_prices} - {e}; Missing 'output' key."
|
52
|
-
if "input" not in relevant_prices:
|
53
|
-
return f"Could not fetch prices from {relevant_prices} - {e}; Missing 'input' key."
|
54
|
-
return f"Could not fetch prices from {relevant_prices} - {e}"
|
55
|
-
|
56
|
-
if inverse_input_price == "infinity":
|
57
|
-
input_cost = 0
|
58
|
-
else:
|
59
|
-
try:
|
60
|
-
input_cost = input_tokens / float(inverse_input_price)
|
61
|
-
except Exception as e:
|
62
|
-
return f"Could not compute input price - {e}."
|
63
|
-
|
64
|
-
if inverse_output_price == "infinity":
|
65
|
-
output_cost = 0
|
66
|
-
else:
|
67
|
-
try:
|
68
|
-
output_cost = output_tokens / float(inverse_output_price)
|
69
|
-
except Exception as e:
|
70
|
-
return f"Could not compute output price - {e}"
|
71
|
-
|
72
|
-
return input_cost + output_cost
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if __name__ == "__main__":
|
77
|
-
import doctest
|
78
|
-
doctest.testmod()
|
File without changes
|
File without changes
|
File without changes
|