edsl 0.1.37__py3-none-any.whl → 0.1.37.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 +35 -86
- edsl/agents/AgentList.py +0 -5
- edsl/agents/InvigilatorBase.py +23 -2
- edsl/agents/PromptConstructor.py +105 -148
- edsl/agents/descriptors.py +4 -17
- edsl/conjure/AgentConstructionMixin.py +3 -11
- edsl/conversation/Conversation.py +14 -66
- edsl/coop/coop.py +14 -148
- edsl/data/Cache.py +1 -1
- edsl/exceptions/__init__.py +3 -7
- edsl/exceptions/agents.py +19 -17
- edsl/exceptions/results.py +8 -11
- edsl/exceptions/surveys.py +10 -13
- edsl/inference_services/AwsBedrock.py +2 -7
- edsl/inference_services/InferenceServicesCollection.py +9 -32
- edsl/jobs/Jobs.py +71 -306
- edsl/jobs/interviews/InterviewExceptionEntry.py +1 -5
- edsl/jobs/tasks/TaskHistory.py +0 -1
- edsl/language_models/LanguageModel.py +59 -47
- edsl/language_models/__init__.py +0 -1
- edsl/prompts/Prompt.py +4 -11
- edsl/questions/QuestionBase.py +13 -53
- edsl/questions/QuestionBasePromptsMixin.py +33 -1
- edsl/questions/QuestionFreeText.py +0 -1
- edsl/questions/QuestionFunctional.py +2 -2
- edsl/questions/descriptors.py +28 -23
- edsl/results/DatasetExportMixin.py +1 -25
- edsl/results/Result.py +1 -16
- edsl/results/Results.py +120 -31
- edsl/results/ResultsDBMixin.py +1 -1
- edsl/results/Selector.py +1 -18
- edsl/scenarios/Scenario.py +12 -48
- edsl/scenarios/ScenarioHtmlMixin.py +2 -7
- edsl/scenarios/ScenarioList.py +1 -12
- edsl/surveys/Rule.py +4 -10
- edsl/surveys/Survey.py +77 -100
- edsl/utilities/utilities.py +0 -18
- {edsl-0.1.37.dist-info → edsl-0.1.37.dev1.dist-info}/METADATA +1 -1
- {edsl-0.1.37.dist-info → edsl-0.1.37.dev1.dist-info}/RECORD +42 -46
- edsl/conversation/chips.py +0 -95
- edsl/exceptions/BaseException.py +0 -21
- edsl/exceptions/scenarios.py +0 -22
- edsl/language_models/KeyLookup.py +0 -30
- {edsl-0.1.37.dist-info → edsl-0.1.37.dev1.dist-info}/LICENSE +0 -0
- {edsl-0.1.37.dist-info → edsl-0.1.37.dev1.dist-info}/WHEEL +0 -0
@@ -99,8 +99,6 @@ class AgentConstructionMixin:
|
|
99
99
|
sample_size: int = None,
|
100
100
|
seed: str = "edsl",
|
101
101
|
dryrun=False,
|
102
|
-
disable_remote_cache: bool = False,
|
103
|
-
disable_remote_inference: bool = False,
|
104
102
|
) -> Union[Results, None]:
|
105
103
|
"""Return the results of the survey.
|
106
104
|
|
@@ -111,7 +109,7 @@ class AgentConstructionMixin:
|
|
111
109
|
|
112
110
|
>>> from edsl.conjure.InputData import InputDataABC
|
113
111
|
>>> id = InputDataABC.example()
|
114
|
-
>>> r = id.to_results(
|
112
|
+
>>> r = id.to_results()
|
115
113
|
>>> len(r) == id.num_observations
|
116
114
|
True
|
117
115
|
"""
|
@@ -127,10 +125,7 @@ class AgentConstructionMixin:
|
|
127
125
|
import time
|
128
126
|
|
129
127
|
start = time.time()
|
130
|
-
_ = survey.by(agent_list.sample(DRYRUN_SAMPLE)).run(
|
131
|
-
disable_remote_cache=disable_remote_cache,
|
132
|
-
disable_remote_inference=disable_remote_inference,
|
133
|
-
)
|
128
|
+
_ = survey.by(agent_list.sample(DRYRUN_SAMPLE)).run()
|
134
129
|
end = time.time()
|
135
130
|
print(f"Time to run {DRYRUN_SAMPLE} agents (s): {round(end - start, 2)}")
|
136
131
|
time_per_agent = (end - start) / DRYRUN_SAMPLE
|
@@ -148,10 +143,7 @@ class AgentConstructionMixin:
|
|
148
143
|
f"Full sample will take about {round(full_sample_time / 3600, 2)} hours."
|
149
144
|
)
|
150
145
|
return None
|
151
|
-
return survey.by(agent_list).run(
|
152
|
-
disable_remote_cache=disable_remote_cache,
|
153
|
-
disable_remote_inference=disable_remote_inference,
|
154
|
-
)
|
146
|
+
return survey.by(agent_list).run()
|
155
147
|
|
156
148
|
|
157
149
|
if __name__ == "__main__":
|
@@ -5,7 +5,7 @@ from typing import Optional, Callable
|
|
5
5
|
from edsl import Agent, QuestionFreeText, Results, AgentList, ScenarioList, Scenario
|
6
6
|
from edsl.questions import QuestionBase
|
7
7
|
from edsl.results.Result import Result
|
8
|
-
|
8
|
+
|
9
9
|
from edsl.data import Cache
|
10
10
|
|
11
11
|
from edsl.conversation.next_speaker_utilities import (
|
@@ -54,9 +54,6 @@ class Conversation:
|
|
54
54
|
"""A conversation between a list of agents. The first agent in the list is the first speaker.
|
55
55
|
After that, order is determined by the next_speaker function.
|
56
56
|
The question asked to each agent is determined by the next_statement_question.
|
57
|
-
|
58
|
-
If the user has passed in a "per_round_message_template", this will be displayed at the beginning of each round.
|
59
|
-
{{ round_message }} must be in the question_text.
|
60
57
|
"""
|
61
58
|
|
62
59
|
def __init__(
|
@@ -67,62 +64,28 @@ class Conversation:
|
|
67
64
|
next_statement_question: Optional[QuestionBase] = None,
|
68
65
|
next_speaker_generator: Optional[Callable] = None,
|
69
66
|
verbose: bool = False,
|
70
|
-
per_round_message_template: Optional[str] = None,
|
71
67
|
conversation_index: Optional[int] = None,
|
72
68
|
cache=None,
|
73
|
-
disable_remote_inference=False,
|
74
|
-
default_model: Optional["LanguageModel"] = None,
|
75
69
|
):
|
76
|
-
self.disable_remote_inference = disable_remote_inference
|
77
|
-
self.per_round_message_template = per_round_message_template
|
78
|
-
|
79
70
|
if cache is None:
|
80
71
|
self.cache = Cache()
|
81
72
|
else:
|
82
73
|
self.cache = cache
|
83
74
|
|
84
75
|
self.agent_list = agent_list
|
85
|
-
|
86
|
-
from edsl import Model
|
87
|
-
|
88
|
-
for agent in self.agent_list:
|
89
|
-
if not hasattr(agent, "model"):
|
90
|
-
if default_model is not None:
|
91
|
-
agent.model = default_model
|
92
|
-
else:
|
93
|
-
agent.model = Model()
|
94
|
-
|
95
76
|
self.verbose = verbose
|
96
77
|
self.agent_statements = []
|
97
78
|
self._conversation_index = conversation_index
|
79
|
+
|
98
80
|
self.agent_statements = AgentStatements()
|
99
81
|
|
100
82
|
self.max_turns = max_turns
|
101
83
|
|
102
84
|
if next_statement_question is None:
|
103
|
-
import textwrap
|
104
|
-
|
105
|
-
base_question = textwrap.dedent(
|
106
|
-
"""\
|
107
|
-
You are {{ agent_name }}. This is the conversation so far: {{ conversation }}
|
108
|
-
{% if round_message is not none %}
|
109
|
-
{{ round_message }}
|
110
|
-
{% endif %}
|
111
|
-
What do you say next?"""
|
112
|
-
)
|
113
85
|
self.next_statement_question = QuestionFreeText(
|
114
|
-
question_text=
|
86
|
+
question_text="You are {{ agent_name }}. This is the converstaion so far: {{ conversation }}. What do you say next?",
|
115
87
|
question_name="dialogue",
|
116
88
|
)
|
117
|
-
else:
|
118
|
-
self.next_statement_question = next_statement_question
|
119
|
-
if (
|
120
|
-
per_round_message_template
|
121
|
-
and "{{ round_message }}" not in next_statement_question.question_text
|
122
|
-
):
|
123
|
-
raise ValueError(
|
124
|
-
"If you pass in a per_round_message_template, you must include {{ round_message }} in the question_text."
|
125
|
-
)
|
126
89
|
|
127
90
|
# Determine how the next speaker is chosen
|
128
91
|
if next_speaker_generator is None:
|
@@ -130,7 +93,6 @@ What do you say next?"""
|
|
130
93
|
else:
|
131
94
|
func = next_speaker_generator
|
132
95
|
|
133
|
-
# Choose the next speaker
|
134
96
|
self.next_speaker = speaker_closure(
|
135
97
|
agent_list=self.agent_list, generator_function=func
|
136
98
|
)
|
@@ -196,32 +158,18 @@ What do you say next?"""
|
|
196
158
|
}
|
197
159
|
return Scenario(d)
|
198
160
|
|
199
|
-
async def get_next_statement(self, *, index, speaker, conversation)
|
200
|
-
"""Get the next statement from the speaker."""
|
161
|
+
async def get_next_statement(self, *, index, speaker, conversation):
|
201
162
|
q = self.next_statement_question
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
s = Scenario(
|
213
|
-
{
|
214
|
-
"agent_name": speaker.name,
|
215
|
-
"conversation": conversation,
|
216
|
-
"conversation_index": self.conversation_index,
|
217
|
-
"index": index,
|
218
|
-
"round_message": round_message,
|
219
|
-
}
|
220
|
-
)
|
221
|
-
jobs = q.by(s).by(speaker).by(speaker.model)
|
222
|
-
jobs.show_prompts()
|
223
|
-
results = await jobs.run_async(
|
224
|
-
cache=self.cache, disable_remote_inference=self.disable_remote_inference
|
163
|
+
assert q.parameters == {"agent_name", "conversation"}, q.parameters
|
164
|
+
results = await q.run_async(
|
165
|
+
index=index,
|
166
|
+
conversation=conversation,
|
167
|
+
conversation_index=self.conversation_index,
|
168
|
+
agent_name=speaker.name,
|
169
|
+
agent=speaker,
|
170
|
+
just_answer=False,
|
171
|
+
cache=self.cache,
|
172
|
+
model=speaker.model,
|
225
173
|
)
|
226
174
|
return results[0]
|
227
175
|
|
edsl/coop/coop.py
CHANGED
@@ -28,18 +28,9 @@ class Coop:
|
|
28
28
|
- Provide a URL directly, or use the default one.
|
29
29
|
"""
|
30
30
|
self.api_key = api_key or os.getenv("EXPECTED_PARROT_API_KEY")
|
31
|
-
|
32
31
|
self.url = url or CONFIG.EXPECTED_PARROT_URL
|
33
32
|
if self.url.endswith("/"):
|
34
33
|
self.url = self.url[:-1]
|
35
|
-
if "chick.expectedparrot" in self.url:
|
36
|
-
self.api_url = "https://chickapi.expectedparrot.com"
|
37
|
-
elif "expectedparrot" in self.url:
|
38
|
-
self.api_url = "https://api.expectedparrot.com"
|
39
|
-
elif "localhost:1234" in self.url:
|
40
|
-
self.api_url = "http://localhost:8000"
|
41
|
-
else:
|
42
|
-
self.api_url = self.url
|
43
34
|
self._edsl_version = edsl.__version__
|
44
35
|
|
45
36
|
################
|
@@ -68,7 +59,7 @@ class Coop:
|
|
68
59
|
"""
|
69
60
|
Send a request to the server and return the response.
|
70
61
|
"""
|
71
|
-
url = f"{self.
|
62
|
+
url = f"{self.url}/{uri}"
|
72
63
|
method = method.upper()
|
73
64
|
if payload is None:
|
74
65
|
timeout = 20
|
@@ -99,83 +90,18 @@ class Coop:
|
|
99
90
|
|
100
91
|
return response
|
101
92
|
|
102
|
-
def _resolve_server_response(
|
103
|
-
self, response: requests.Response, check_api_key: bool = True
|
104
|
-
) -> None:
|
93
|
+
def _resolve_server_response(self, response: requests.Response) -> None:
|
105
94
|
"""
|
106
95
|
Check the response from the server and raise errors as appropriate.
|
107
96
|
"""
|
108
97
|
if response.status_code >= 400:
|
109
98
|
message = response.json().get("detail")
|
110
99
|
# print(response.text)
|
111
|
-
if "
|
112
|
-
import secrets
|
113
|
-
from edsl.utilities.utilities import write_api_key_to_env
|
114
|
-
|
115
|
-
edsl_auth_token = secrets.token_urlsafe(16)
|
116
|
-
|
117
|
-
print("Your Expected Parrot API key is invalid.")
|
118
|
-
print(
|
119
|
-
"\nUse the link below to log in to Expected Parrot so we can automatically update your API key."
|
120
|
-
)
|
121
|
-
self._display_login_url(edsl_auth_token=edsl_auth_token)
|
122
|
-
api_key = self._poll_for_api_key(edsl_auth_token)
|
123
|
-
|
124
|
-
if api_key is None:
|
125
|
-
print("\nTimed out waiting for login. Please try again.")
|
126
|
-
return
|
127
|
-
|
128
|
-
write_api_key_to_env(api_key)
|
129
|
-
print("\n✨ API key retrieved and written to .env file.")
|
130
|
-
print("Rerun your code to try again with a valid API key.")
|
131
|
-
return
|
132
|
-
|
133
|
-
elif "Authorization" in message:
|
100
|
+
if "Authorization" in message:
|
134
101
|
print(message)
|
135
102
|
message = "Please provide an Expected Parrot API key."
|
136
|
-
|
137
103
|
raise CoopServerResponseError(message)
|
138
104
|
|
139
|
-
def _poll_for_api_key(
|
140
|
-
self, edsl_auth_token: str, timeout: int = 120
|
141
|
-
) -> Union[str, None]:
|
142
|
-
"""
|
143
|
-
Allows the user to retrieve their Expected Parrot API key by logging in with an EDSL auth token.
|
144
|
-
|
145
|
-
:param edsl_auth_token: The EDSL auth token to use for login
|
146
|
-
:param timeout: Maximum time to wait for login, in seconds (default: 120)
|
147
|
-
"""
|
148
|
-
import time
|
149
|
-
from datetime import datetime
|
150
|
-
|
151
|
-
start_poll_time = time.time()
|
152
|
-
waiting_for_login = True
|
153
|
-
while waiting_for_login:
|
154
|
-
elapsed_time = time.time() - start_poll_time
|
155
|
-
if elapsed_time > timeout:
|
156
|
-
# Timed out waiting for the user to log in
|
157
|
-
print("\r" + " " * 80 + "\r", end="")
|
158
|
-
return None
|
159
|
-
|
160
|
-
api_key = self._get_api_key(edsl_auth_token)
|
161
|
-
if api_key is not None:
|
162
|
-
print("\r" + " " * 80 + "\r", end="")
|
163
|
-
return api_key
|
164
|
-
else:
|
165
|
-
duration = 5
|
166
|
-
time_checked = datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
167
|
-
frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
|
168
|
-
start_time = time.time()
|
169
|
-
i = 0
|
170
|
-
while time.time() - start_time < duration:
|
171
|
-
print(
|
172
|
-
f"\r{frames[i % len(frames)]} Waiting for login. Last checked: {time_checked}",
|
173
|
-
end="",
|
174
|
-
flush=True,
|
175
|
-
)
|
176
|
-
time.sleep(0.1)
|
177
|
-
i += 1
|
178
|
-
|
179
105
|
def _json_handle_none(self, value: Any) -> Any:
|
180
106
|
"""
|
181
107
|
Handle None values during JSON serialization.
|
@@ -208,7 +134,7 @@ class Coop:
|
|
208
134
|
response = self._send_server_request(
|
209
135
|
uri="api/v0/edsl-settings", method="GET", timeout=5
|
210
136
|
)
|
211
|
-
self._resolve_server_response(response
|
137
|
+
self._resolve_server_response(response)
|
212
138
|
return response.json()
|
213
139
|
except Timeout:
|
214
140
|
return {}
|
@@ -563,7 +489,6 @@ class Coop:
|
|
563
489
|
description: Optional[str] = None,
|
564
490
|
status: RemoteJobStatus = "queued",
|
565
491
|
visibility: Optional[VisibilityType] = "unlisted",
|
566
|
-
initial_results_visibility: Optional[VisibilityType] = "unlisted",
|
567
492
|
iterations: Optional[int] = 1,
|
568
493
|
) -> dict:
|
569
494
|
"""
|
@@ -592,7 +517,6 @@ class Coop:
|
|
592
517
|
"iterations": iterations,
|
593
518
|
"visibility": visibility,
|
594
519
|
"version": self._edsl_version,
|
595
|
-
"initial_results_visibility": initial_results_visibility,
|
596
520
|
},
|
597
521
|
)
|
598
522
|
self._resolve_server_response(response)
|
@@ -644,9 +568,7 @@ class Coop:
|
|
644
568
|
"version": data.get("version"),
|
645
569
|
}
|
646
570
|
|
647
|
-
def remote_inference_cost(
|
648
|
-
self, input: Union[Jobs, Survey], iterations: int = 1
|
649
|
-
) -> int:
|
571
|
+
def remote_inference_cost(self, input: Union[Jobs, Survey]) -> int:
|
650
572
|
"""
|
651
573
|
Get the cost of a remote inference job.
|
652
574
|
|
@@ -671,7 +593,6 @@ class Coop:
|
|
671
593
|
job.to_dict(),
|
672
594
|
default=self._json_handle_none,
|
673
595
|
),
|
674
|
-
"iterations": iterations,
|
675
596
|
},
|
676
597
|
)
|
677
598
|
self._resolve_server_response(response)
|
@@ -694,7 +615,7 @@ class Coop:
|
|
694
615
|
async def remote_async_execute_model_call(
|
695
616
|
self, model_dict: dict, user_prompt: str, system_prompt: str
|
696
617
|
) -> dict:
|
697
|
-
url = self.
|
618
|
+
url = self.url + "/inference/"
|
698
619
|
# print("Now using url: ", url)
|
699
620
|
data = {
|
700
621
|
"model_dict": model_dict,
|
@@ -715,7 +636,7 @@ class Coop:
|
|
715
636
|
] = "lime_survey",
|
716
637
|
email=None,
|
717
638
|
):
|
718
|
-
url = f"{self.
|
639
|
+
url = f"{self.url}/api/v0/export_to_{platform}"
|
719
640
|
if email:
|
720
641
|
data = {"json_string": json.dumps({"survey": survey, "email": email})}
|
721
642
|
else:
|
@@ -740,17 +661,6 @@ class Coop:
|
|
740
661
|
else:
|
741
662
|
return {}
|
742
663
|
|
743
|
-
def fetch_models(self) -> dict:
|
744
|
-
"""
|
745
|
-
Fetch a dict of available models from Coop.
|
746
|
-
|
747
|
-
Each key in the dict is an inference service, and each value is a list of models from that service.
|
748
|
-
"""
|
749
|
-
response = self._send_server_request(uri="api/v0/models", method="GET")
|
750
|
-
self._resolve_server_response(response)
|
751
|
-
data = response.json()
|
752
|
-
return data
|
753
|
-
|
754
664
|
def fetch_rate_limit_config_vars(self) -> dict:
|
755
665
|
"""
|
756
666
|
Fetch a dict of rate limit config vars from Coop.
|
@@ -765,58 +675,14 @@ class Coop:
|
|
765
675
|
data = response.json()
|
766
676
|
return data
|
767
677
|
|
768
|
-
def _display_login_url(self, edsl_auth_token: str):
|
769
|
-
"""
|
770
|
-
Uses rich.print to display a login URL.
|
771
|
-
|
772
|
-
- We need this function because URL detection with print() does not work alongside animations in VSCode.
|
773
|
-
"""
|
774
|
-
from rich import print as rich_print
|
775
|
-
|
776
|
-
url = f"{CONFIG.EXPECTED_PARROT_URL}/login?edsl_auth_token={edsl_auth_token}"
|
777
|
-
|
778
|
-
rich_print(f"[#38bdf8][link={url}]{url}[/link][/#38bdf8]")
|
779
|
-
|
780
|
-
def _get_api_key(self, edsl_auth_token: str):
|
781
|
-
"""
|
782
|
-
Given an EDSL auth token, find the corresponding user's API key.
|
783
|
-
"""
|
784
|
-
|
785
|
-
response = self._send_server_request(
|
786
|
-
uri="api/v0/get-api-key",
|
787
|
-
method="POST",
|
788
|
-
payload={
|
789
|
-
"edsl_auth_token": edsl_auth_token,
|
790
|
-
},
|
791
|
-
)
|
792
|
-
data = response.json()
|
793
|
-
api_key = data.get("api_key")
|
794
|
-
return api_key
|
795
|
-
|
796
|
-
def login(self):
|
797
|
-
"""
|
798
|
-
Starts the EDSL auth token login flow.
|
799
|
-
"""
|
800
|
-
import secrets
|
801
|
-
from dotenv import load_dotenv
|
802
|
-
from edsl.utilities.utilities import write_api_key_to_env
|
803
|
-
|
804
|
-
edsl_auth_token = secrets.token_urlsafe(16)
|
805
|
-
|
806
|
-
print(
|
807
|
-
"\nUse the link below to log in to Expected Parrot so we can automatically update your API key."
|
808
|
-
)
|
809
|
-
self._display_login_url(edsl_auth_token=edsl_auth_token)
|
810
|
-
api_key = self._poll_for_api_key(edsl_auth_token)
|
811
|
-
|
812
|
-
if api_key is None:
|
813
|
-
raise Exception("Timed out waiting for login. Please try again.")
|
814
|
-
|
815
|
-
write_api_key_to_env(api_key)
|
816
|
-
print("\n✨ API key retrieved and written to .env file.")
|
817
678
|
|
818
|
-
|
819
|
-
|
679
|
+
if __name__ == "__main__":
|
680
|
+
sheet_data = fetch_sheet_data()
|
681
|
+
if sheet_data:
|
682
|
+
print(f"Successfully fetched {len(sheet_data)} rows of data.")
|
683
|
+
print("First row:", sheet_data[0])
|
684
|
+
else:
|
685
|
+
print("Failed to fetch sheet data.")
|
820
686
|
|
821
687
|
|
822
688
|
def main():
|
edsl/data/Cache.py
CHANGED
@@ -194,7 +194,7 @@ class Cache(Base):
|
|
194
194
|
>>> c = Cache()
|
195
195
|
>>> len(c)
|
196
196
|
0
|
197
|
-
>>> results = Question.example("free_text").by(m).run(cache = c
|
197
|
+
>>> results = Question.example("free_text").by(m).run(cache = c)
|
198
198
|
>>> len(c)
|
199
199
|
1
|
200
200
|
"""
|
edsl/exceptions/__init__.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
from .agents import (
|
2
|
-
|
2
|
+
AgentAttributeLookupCallbackError,
|
3
3
|
AgentCombinationError,
|
4
|
-
|
5
|
-
|
4
|
+
AgentLacksLLMError,
|
5
|
+
AgentRespondedWithBadJSONError,
|
6
6
|
)
|
7
7
|
from .configuration import (
|
8
8
|
InvalidEnvironmentVariableError,
|
@@ -14,10 +14,6 @@ from .data import (
|
|
14
14
|
DatabaseIntegrityError,
|
15
15
|
)
|
16
16
|
|
17
|
-
from .scenarios import (
|
18
|
-
ScenarioError,
|
19
|
-
)
|
20
|
-
|
21
17
|
from .general import MissingAPIKeyError
|
22
18
|
|
23
19
|
from .jobs import JobsRunError, InterviewErrorPriorTaskCanceled, InterviewTimeoutError
|
edsl/exceptions/agents.py
CHANGED
@@ -1,35 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class AgentErrors(BaseException):
|
5
|
-
relevant_doc = "https://docs.expectedparrot.com/en/latest/agents.html"
|
1
|
+
class AgentErrors(Exception):
|
2
|
+
pass
|
6
3
|
|
7
4
|
|
8
5
|
class AgentDynamicTraitsFunctionError(AgentErrors):
|
9
|
-
|
10
|
-
"https://docs.expectedparrot.com/en/latest/agents.html#dynamic-traits-function"
|
11
|
-
)
|
12
|
-
relevant_notebook = "https://docs.expectedparrot.com/en/latest/notebooks/example_agent_dynamic_traits.html"
|
6
|
+
pass
|
13
7
|
|
14
8
|
|
15
9
|
class AgentDirectAnswerFunctionError(AgentErrors):
|
16
|
-
|
10
|
+
pass
|
11
|
+
|
12
|
+
|
13
|
+
class AgentAttributeLookupCallbackError(AgentErrors):
|
14
|
+
pass
|
17
15
|
|
18
16
|
|
19
17
|
class AgentCombinationError(AgentErrors):
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
pass
|
19
|
+
|
20
|
+
|
21
|
+
class AgentLacksLLMError(AgentErrors):
|
22
|
+
pass
|
23
|
+
|
24
|
+
|
25
|
+
class AgentRespondedWithBadJSONError(AgentErrors):
|
26
|
+
pass
|
23
27
|
|
24
28
|
|
25
29
|
class AgentNameError(AgentErrors):
|
26
|
-
|
30
|
+
pass
|
27
31
|
|
28
32
|
|
29
33
|
class AgentTraitKeyError(AgentErrors):
|
30
|
-
|
31
|
-
"https://docs.expectedparrot.com/en/latest/agents.html#constructing-an-agent"
|
32
|
-
)
|
34
|
+
pass
|
33
35
|
|
34
36
|
|
35
37
|
class FailedTaskException(Exception):
|
edsl/exceptions/results.py
CHANGED
@@ -1,29 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class ResultsError(BaseException):
|
5
|
-
relevant_docs = "https://docs.expectedparrot.com/en/latest/results.html"
|
1
|
+
class ResultsErrors(Exception):
|
2
|
+
pass
|
6
3
|
|
7
4
|
|
8
|
-
class ResultsDeserializationError(
|
5
|
+
class ResultsDeserializationError(ResultsErrors):
|
9
6
|
pass
|
10
7
|
|
11
8
|
|
12
|
-
class ResultsBadMutationstringError(
|
9
|
+
class ResultsBadMutationstringError(ResultsErrors):
|
13
10
|
pass
|
14
11
|
|
15
12
|
|
16
|
-
class ResultsColumnNotFoundError(
|
13
|
+
class ResultsColumnNotFoundError(ResultsErrors):
|
17
14
|
pass
|
18
15
|
|
19
16
|
|
20
|
-
class ResultsInvalidNameError(
|
17
|
+
class ResultsInvalidNameError(ResultsErrors):
|
21
18
|
pass
|
22
19
|
|
23
20
|
|
24
|
-
class ResultsMutateError(
|
21
|
+
class ResultsMutateError(ResultsErrors):
|
25
22
|
pass
|
26
23
|
|
27
24
|
|
28
|
-
class ResultsFilterError(
|
25
|
+
class ResultsFilterError(ResultsErrors):
|
29
26
|
pass
|
edsl/exceptions/surveys.py
CHANGED
@@ -1,37 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class SurveyError(BaseException):
|
5
|
-
relevant_doc = "https://docs.expectedparrot.com/en/latest/surveys.html"
|
1
|
+
class SurveyErrors(Exception):
|
2
|
+
pass
|
6
3
|
|
7
4
|
|
8
|
-
class SurveyCreationError(
|
5
|
+
class SurveyCreationError(SurveyErrors):
|
9
6
|
pass
|
10
7
|
|
11
8
|
|
12
|
-
class SurveyHasNoRulesError(
|
9
|
+
class SurveyHasNoRulesError(SurveyErrors):
|
13
10
|
pass
|
14
11
|
|
15
12
|
|
16
|
-
class SurveyRuleSendsYouBackwardsError(
|
13
|
+
class SurveyRuleSendsYouBackwardsError(SurveyErrors):
|
17
14
|
pass
|
18
15
|
|
19
16
|
|
20
|
-
class SurveyRuleSkipLogicSyntaxError(
|
17
|
+
class SurveyRuleSkipLogicSyntaxError(SurveyErrors):
|
21
18
|
pass
|
22
19
|
|
23
20
|
|
24
|
-
class SurveyRuleReferenceInRuleToUnknownQuestionError(
|
21
|
+
class SurveyRuleReferenceInRuleToUnknownQuestionError(SurveyErrors):
|
25
22
|
pass
|
26
23
|
|
27
24
|
|
28
|
-
class SurveyRuleRefersToFutureStateError(
|
25
|
+
class SurveyRuleRefersToFutureStateError(SurveyErrors):
|
29
26
|
pass
|
30
27
|
|
31
28
|
|
32
|
-
class SurveyRuleCollectionHasNoRulesAtNodeError(
|
29
|
+
class SurveyRuleCollectionHasNoRulesAtNodeError(SurveyErrors):
|
33
30
|
pass
|
34
31
|
|
35
32
|
|
36
|
-
class SurveyRuleCannotEvaluateError(
|
33
|
+
class SurveyRuleCannotEvaluateError(SurveyErrors):
|
37
34
|
pass
|
@@ -28,16 +28,12 @@ class AwsBedrockService(InferenceServiceABC):
|
|
28
28
|
"ai21.j2-ultra",
|
29
29
|
"ai21.j2-ultra-v1",
|
30
30
|
]
|
31
|
-
_models_list_cache: List[str] = []
|
32
31
|
|
33
32
|
@classmethod
|
34
33
|
def available(cls):
|
35
34
|
"""Fetch available models from AWS Bedrock."""
|
36
|
-
|
37
|
-
region = os.getenv("AWS_REGION", "us-east-1")
|
38
|
-
|
39
35
|
if not cls._models_list_cache:
|
40
|
-
client = boto3.client("bedrock", region_name=
|
36
|
+
client = boto3.client("bedrock", region_name="us-west-2")
|
41
37
|
all_models_ids = [
|
42
38
|
x["modelId"] for x in client.list_foundation_models()["modelSummaries"]
|
43
39
|
]
|
@@ -84,8 +80,7 @@ class AwsBedrockService(InferenceServiceABC):
|
|
84
80
|
self.api_token
|
85
81
|
) # call to check the if env variables are set.
|
86
82
|
|
87
|
-
|
88
|
-
client = boto3.client("bedrock-runtime", region_name=region)
|
83
|
+
client = boto3.client("bedrock-runtime", region_name="us-west-2")
|
89
84
|
|
90
85
|
conversation = [
|
91
86
|
{
|