futurehouse-client 0.3.20.dev55__py3-none-any.whl → 0.3.20.dev105__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.
@@ -73,7 +73,7 @@ class JobNames(StrEnum):
73
73
 
74
74
  @staticmethod
75
75
  def get_response_object_from_job(job_name: str) -> type[TaskResponse]:
76
- return JobNames._get_response_mapping()[job_name]
76
+ return JobNames._get_response_mapping().get(job_name, TaskResponse)
77
77
 
78
78
  def get_response_object(self) -> type[TaskResponse]:
79
79
  return self._get_response_mapping()[self.name]
@@ -139,6 +139,7 @@ retry_if_connection_error = retry_if_exception_type((
139
139
  DEFAULT_AGENT_TIMEOUT: int = 2400 # seconds
140
140
 
141
141
 
142
+ # pylint: disable=too-many-public-methods
142
143
  class RestClient:
143
144
  REQUEST_TIMEOUT: ClassVar[float] = 30.0 # sec
144
145
  MAX_RETRY_ATTEMPTS: ClassVar[int] = 3
@@ -169,7 +170,7 @@ class RestClient:
169
170
  self.base_url = service_uri or stage.value
170
171
  self.stage = stage
171
172
  self.auth_type = auth_type
172
- self.api_key = api_key
173
+ self.api_key = api_key or os.environ.get("FUTUREHOUSE_API_KEY")
173
174
  self._clients: dict[str, Client | AsyncClient] = {}
174
175
  self.headers = headers or {}
175
176
  self.jwt = jwt
@@ -1419,15 +1420,9 @@ class RestClient:
1419
1420
  if not (world_model_id or name) or (world_model_id and name):
1420
1421
  raise ValueError("Provide either 'world_model_id' or 'name', but not both.")
1421
1422
 
1422
- params = {
1423
- "id": str(world_model_id) if world_model_id else None,
1424
- "name": name,
1425
- }
1426
- # Filter out None values before making the request
1427
- params = {k: v for k, v in params.items() if v is not None}
1428
-
1429
1423
  try:
1430
- response = self.client.get("/v0.1/world-model", params=params)
1424
+ identifier = str(world_model_id) if world_model_id else name
1425
+ response = self.client.get(f"/v0.1/world-models/{identifier}")
1431
1426
  response.raise_for_status()
1432
1427
  return WorldModelResponse.model_validate(response.json())
1433
1428
  except HTTPStatusError as e:
@@ -1465,14 +1460,9 @@ class RestClient:
1465
1460
  if not (world_model_id or name) or (world_model_id and name):
1466
1461
  raise ValueError("Provide either 'world_model_id' or 'name', but not both.")
1467
1462
 
1468
- params = {
1469
- "id": str(world_model_id) if world_model_id else None,
1470
- "name": name,
1471
- }
1472
- params = {k: v for k, v in params.items() if v is not None}
1473
-
1474
1463
  try:
1475
- response = await self.async_client.get("/v0.1/world-model", params=params)
1464
+ identifier = str(world_model_id) if world_model_id else name
1465
+ response = await self.async_client.get(f"/v0.1/world-models/{identifier}")
1476
1466
  response.raise_for_status()
1477
1467
  return WorldModelResponse.model_validate(response.json())
1478
1468
  except HTTPStatusError as e:
@@ -610,7 +610,7 @@ class RuntimeConfig(BaseModel):
610
610
  default=None,
611
611
  description="Optional job identifier for a continued job",
612
612
  )
613
- world_model_id: UUID | None = Field(
613
+ world_model_id: UUID | str | None = Field(
614
614
  default=None,
615
615
  description="Optional world model identifier for the task",
616
616
  )
@@ -46,10 +46,10 @@ class WorldModel(BaseModel):
46
46
  """
47
47
 
48
48
  content: str
49
- prior: UUID | None = None
49
+ prior: UUID | str | None = None
50
50
  name: str | None = None
51
51
  description: str | None = None
52
- trajectory_id: UUID | None = None
52
+ trajectory_id: UUID | str | None = None
53
53
  model_metadata: JsonValue | None = None
54
54
 
55
55
 
@@ -60,12 +60,12 @@ class WorldModelResponse(BaseModel):
60
60
  This model is received from the API.
61
61
  """
62
62
 
63
- id: UUID
64
- prior: UUID | None
63
+ id: UUID | str
64
+ prior: UUID | str | None
65
65
  name: str
66
66
  description: str | None
67
67
  content: str
68
- trajectory_id: UUID | None
68
+ trajectory_id: UUID | str | None
69
69
  email: str | None
70
70
  model_metadata: JsonValue | None
71
71
  enabled: bool
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.3.20.dev55'
21
- __version_tuple__ = version_tuple = (0, 3, 20, 'dev55')
20
+ __version__ = version = '0.3.20.dev105'
21
+ __version_tuple__ = version_tuple = (0, 3, 20, 'dev105')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.3.20.dev55
3
+ Version: 0.3.20.dev105
4
4
  Summary: A client for interacting with endpoints of the FutureHouse service.
5
5
  Author-email: FutureHouse technical staff <hello@futurehouse.org>
6
6
  License: Apache License
@@ -274,20 +274,19 @@ uv pip install futurehouse-client
274
274
 
275
275
  ```python
276
276
  from futurehouse_client import FutureHouseClient, JobNames
277
- from pathlib import Path
278
- from aviary.core import DummyEnv
279
- import ldp
280
277
 
281
- client = FutureHouseClient(
282
- api_key="your_api_key",
283
- )
278
+ # Set your API key to FUTUREHOUSE_API_KEY environment variable,
279
+ # or pass it as a string literal to the api_key parameter
280
+ client = FutureHouseClient()
284
281
 
285
282
  task_data = {
286
283
  "name": JobNames.CROW,
287
- "query": "Which neglected diseases had a treatment developed by artificial intelligence?",
284
+ "query": (
285
+ "Which neglected diseases had a treatment developed"
286
+ " by artificial intelligence?"
287
+ ),
288
288
  }
289
-
290
- task_response = client.run_tasks_until_done(task_data)
289
+ (task_response,) = client.run_tasks_until_done(task_data)
291
290
  ```
292
291
 
293
292
  A quickstart example can be found in the [client_notebook.ipynb](https://futurehouse.gitbook.io/futurehouse-cookbook/futurehouse-client/docs/client_notebook) file, where we show how to submit and retrieve a job task, pass runtime configuration to the agent, and ask follow-up questions to the previous job.
@@ -304,9 +303,10 @@ To create a `FutureHouseClient`, you need to pass an FutureHouse platform api ke
304
303
  ```python
305
304
  from futurehouse_client import FutureHouseClient
306
305
 
307
- client = FutureHouseClient(
308
- api_key="your_api_key",
309
- )
306
+ # Set your API key to FUTUREHOUSE_API_KEY environment variable
307
+ client = FutureHouseClient()
308
+ # Or pass it as a string literal to the api_key parameter
309
+ client = FutureHouseClient(api_key="your_api_key")
310
310
  ```
311
311
 
312
312
  ## Authentication
@@ -333,17 +333,13 @@ Using `JobNames`, the task submission looks like this:
333
333
  ```python
334
334
  from futurehouse_client import FutureHouseClient, JobNames
335
335
 
336
- client = FutureHouseClient(
337
- api_key="your_api_key",
338
- )
336
+ client = FutureHouseClient()
339
337
 
340
338
  task_data = {
341
339
  "name": JobNames.OWL,
342
340
  "query": "Has anyone tested therapeutic exerkines in humans or NHPs?",
343
341
  }
344
-
345
- task_response = client.run_tasks_until_done(task_data)
346
-
342
+ (task_response,) = client.run_tasks_until_done(task_data)
347
343
  print(task_response.answer)
348
344
  ```
349
345
 
@@ -363,8 +359,7 @@ async def main():
363
359
  "name": JobNames.OWL,
364
360
  "query": "Has anyone tested therapeutic exerkines in humans or NHPs?",
365
361
  }
366
-
367
- task_response = await client.arun_tasks_until_done(task_data)
362
+ (task_response,) = await client.arun_tasks_until_done(task_data)
368
363
  print(task_response.answer)
369
364
  return task_id
370
365
 
@@ -382,9 +377,7 @@ from futurehouse_client import FutureHouseClient, JobNames
382
377
 
383
378
 
384
379
  async def main():
385
- client = FutureHouseClient(
386
- api_key="your_api_key",
387
- )
380
+ client = FutureHouseClient()
388
381
 
389
382
  task_data = [
390
383
  {
@@ -393,10 +386,12 @@ async def main():
393
386
  },
394
387
  {
395
388
  "name": JobNames.CROW,
396
- "query": "Are there any clinically validated therapeutic exerkines for humans?",
389
+ "query": (
390
+ "Are there any clinically validated"
391
+ " therapeutic exerkines for humans?"
392
+ ),
397
393
  },
398
394
  ]
399
-
400
395
  task_responses = await client.arun_tasks_until_done(task_data)
401
396
  print(task_responses[0].answer)
402
397
  print(task_responses[1].answer)
@@ -423,17 +418,14 @@ if __name__ == "__main__":
423
418
  from futurehouse_client import FutureHouseClient, JobNames
424
419
  from futurehouse_client.models.app import TaskRequest
425
420
 
426
- client = FutureHouseClient(
427
- api_key="your_api_key",
428
- )
421
+ client = FutureHouseClient()
429
422
 
430
- task_response = client.run_tasks_until_done(
423
+ (task_response,) = client.run_tasks_until_done(
431
424
  TaskRequest(
432
425
  name=JobNames.OWL,
433
426
  query="Has anyone tested therapeutic exerkines in humans or NHPs?",
434
427
  )
435
428
  )
436
-
437
429
  print(task_response.answer)
438
430
  ```
439
431
 
@@ -455,14 +447,13 @@ client = FutureHouseClient(
455
447
  api_key="your_api_key",
456
448
  )
457
449
 
458
- task_response = client.run_tasks_until_done(
450
+ (task_response,) = client.run_tasks_until_done(
459
451
  TaskRequest(
460
452
  name=JobNames.OWL,
461
453
  query="Has anyone tested therapeutic exerkines in humans or NHPs?",
462
454
  ),
463
455
  verbose=True,
464
456
  )
465
-
466
457
  print(task_response.environment_frame)
467
458
  ```
468
459
 
@@ -487,17 +478,21 @@ client = FutureHouseClient(
487
478
  api_key="your_api_key",
488
479
  )
489
480
 
490
- task_data = {"name": JobNames.CROW, "query": "How many species of birds are there?"}
491
-
481
+ task_data = {
482
+ "name": JobNames.CROW,
483
+ "query": "How many species of birds are there?",
484
+ }
492
485
  task_id = client.create_task(task_data)
493
486
 
494
487
  continued_task_data = {
495
488
  "name": JobNames.CROW,
496
- "query": "From the previous answer, specifically,how many species of crows are there?",
489
+ "query": (
490
+ "From the previous answer,"
491
+ " specifically, how many species of crows are there?"
492
+ ),
497
493
  "runtime_config": {"continued_task_id": task_id},
498
494
  }
499
-
500
- task_result = client.run_tasks_until_done(continued_task_data)
495
+ (task_response,) = client.run_tasks_until_done(continued_task_data)
501
496
  ```
502
497
 
503
498
  ## Asynchronous tasks
@@ -505,14 +500,14 @@ task_result = client.run_tasks_until_done(continued_task_data)
505
500
  Sometimes you may want to submit many jobs, while querying results at a later time. In this way you can do other things while waiting for a response. The platform API supports this as well rather than waiting for a result.
506
501
 
507
502
  ```python
508
- from futurehouse_client import FutureHouseClient
509
-
510
- client = FutureHouseClient(
511
- api_key="your_api_key",
512
- )
503
+ from futurehouse_client import FutureHouseClient, JobNames
513
504
 
514
- task_data = {"name": JobNames.CROW, "query": "How many species of birds are there?"}
505
+ client = FutureHouseClient()
515
506
 
507
+ task_data = {
508
+ "name": JobNames.CROW,
509
+ "query": "How many species of birds are there?",
510
+ }
516
511
  task_id = client.create_task(task_data)
517
512
 
518
513
  # move on to do other things
@@ -0,0 +1,20 @@
1
+ futurehouse_client/__init__.py,sha256=BztM_ntbgmIEjzvnBWcvPhvLjM8xGDFCK0Upf3-nIn8,488
2
+ futurehouse_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ futurehouse_client/version.py,sha256=dggvSZjGalP38yUZTaRgokHrf_7S9wpjF6xrQ5xRQlk,530
4
+ futurehouse_client/clients/__init__.py,sha256=-HXNj-XJ3LRO5XM6MZ709iPs29YpApss0Q2YYg1qMZw,280
5
+ futurehouse_client/clients/job_client.py,sha256=D51_qTxya6g5Wfg_ZfJdP031TV_YDJeXkGMiYAJ1qRc,11962
6
+ futurehouse_client/clients/rest_client.py,sha256=zfGMFzLWsNWggTDrZpQZm9habxSQ0bJ2Zd5w_dZrJhU,61301
7
+ futurehouse_client/models/__init__.py,sha256=5x-f9AoM1hGzJBEHcHAXSt7tPeImST5oZLuMdwp0mXc,554
8
+ futurehouse_client/models/app.py,sha256=TrfSorJlxyuc9ZzJpd2tL1pzKOp3jNBYRqFMfmmUue0,28954
9
+ futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
10
+ futurehouse_client/models/rest.py,sha256=AwPMcB1ruoqaI8NIhX2ZzN8UuX6XsaQ7uzeSE8EpwKk,1573
11
+ futurehouse_client/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ futurehouse_client/utils/auth.py,sha256=tgWELjKfg8eWme_qdcRmc8TjQN9DVZuHHaVXZNHLchk,2960
13
+ futurehouse_client/utils/general.py,sha256=A_rtTiYW30ELGEZlWCIArO7q1nEmqi8hUlmBRYkMQ_c,767
14
+ futurehouse_client/utils/module_utils.py,sha256=aFyd-X-pDARXz9GWpn8SSViUVYdSbuy9vSkrzcVIaGI,4955
15
+ futurehouse_client/utils/monitoring.py,sha256=UjRlufe67kI3VxRHOd5fLtJmlCbVA2Wqwpd4uZhXkQM,8728
16
+ futurehouse_client-0.3.20.dev105.dist-info/licenses/LICENSE,sha256=oQ9ZHjUi-_6GfP3gs14FlPb0OlGwE1QCCKFGnJ4LD2I,11341
17
+ futurehouse_client-0.3.20.dev105.dist-info/METADATA,sha256=bKotJE6rkwyPwipLmyOVe8hNoEoniaDi87CrnCU1C2w,26118
18
+ futurehouse_client-0.3.20.dev105.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ futurehouse_client-0.3.20.dev105.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
20
+ futurehouse_client-0.3.20.dev105.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- futurehouse_client/__init__.py,sha256=BztM_ntbgmIEjzvnBWcvPhvLjM8xGDFCK0Upf3-nIn8,488
2
- futurehouse_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- futurehouse_client/version.py,sha256=R0N9IlSoJfca-REsgOruf0uQwzcxQP-poQaa9iM3N3g,528
4
- futurehouse_client/clients/__init__.py,sha256=-HXNj-XJ3LRO5XM6MZ709iPs29YpApss0Q2YYg1qMZw,280
5
- futurehouse_client/clients/job_client.py,sha256=JgB5IUAyCmnhGRsYc3bgKldA-lkM1JLwHRwwUeOCdus,11944
6
- futurehouse_client/clients/rest_client.py,sha256=XHHofNT-tOhS-jyLiAloUUnj6AiZh1hF5Fb8SeV6SNE,61513
7
- futurehouse_client/models/__init__.py,sha256=5x-f9AoM1hGzJBEHcHAXSt7tPeImST5oZLuMdwp0mXc,554
8
- futurehouse_client/models/app.py,sha256=fIWATuetex9GuNzGAWQz-9Dc63ifEFl-Mv-UN7nGSfA,28948
9
- futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
10
- futurehouse_client/models/rest.py,sha256=QqOhRT-qTMfLtNge458qyBv6JFZvoQULnGIjjcDvMy8,1543
11
- futurehouse_client/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- futurehouse_client/utils/auth.py,sha256=tgWELjKfg8eWme_qdcRmc8TjQN9DVZuHHaVXZNHLchk,2960
13
- futurehouse_client/utils/general.py,sha256=A_rtTiYW30ELGEZlWCIArO7q1nEmqi8hUlmBRYkMQ_c,767
14
- futurehouse_client/utils/module_utils.py,sha256=aFyd-X-pDARXz9GWpn8SSViUVYdSbuy9vSkrzcVIaGI,4955
15
- futurehouse_client/utils/monitoring.py,sha256=UjRlufe67kI3VxRHOd5fLtJmlCbVA2Wqwpd4uZhXkQM,8728
16
- futurehouse_client-0.3.20.dev55.dist-info/licenses/LICENSE,sha256=oQ9ZHjUi-_6GfP3gs14FlPb0OlGwE1QCCKFGnJ4LD2I,11341
17
- futurehouse_client-0.3.20.dev55.dist-info/METADATA,sha256=3E-5Yu1s0Oo3PFcGHd4gts5HnDyqB2yDL7VRpaOyyGw,25926
18
- futurehouse_client-0.3.20.dev55.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- futurehouse_client-0.3.20.dev55.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
20
- futurehouse_client-0.3.20.dev55.dist-info/RECORD,,