futurehouse-client 0.3.20.dev105__py3-none-any.whl → 0.3.20.dev112__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.
@@ -8,6 +8,11 @@ from .models.app import (
8
8
  TaskResponse,
9
9
  TaskResponseVerbose,
10
10
  )
11
+ from .utils.world_model_tools import (
12
+ create_world_model_tool,
13
+ search_world_model_tool,
14
+ make_world_model_tools,
15
+ )
11
16
 
12
17
  __all__ = [
13
18
  "FinchTaskResponse",
@@ -19,4 +24,7 @@ __all__ = [
19
24
  "TaskRequest",
20
25
  "TaskResponse",
21
26
  "TaskResponseVerbose",
27
+ "create_world_model_tool",
28
+ "search_world_model_tool",
29
+ "make_world_model_tools",
22
30
  ]
@@ -111,6 +111,8 @@ class WorldModelFetchError(RestClientError):
111
111
  class WorldModelCreationError(RestClientError):
112
112
  """Raised when there's an error creating a world model."""
113
113
 
114
+ class WorldModelDeletionError(RestClientError):
115
+ """Raised when there's an error deleting a world model."""
114
116
 
115
117
  class InvalidTaskDescriptionError(Exception):
116
118
  """Raised when the task description is invalid or empty."""
@@ -1476,6 +1478,25 @@ class RestClient:
1476
1478
  except Exception as e:
1477
1479
  raise WorldModelFetchError(f"An unexpected error occurred: {e}") from e
1478
1480
 
1481
+ @retry(
1482
+ stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
1483
+ wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
1484
+ retry=retry_if_connection_error,
1485
+ )
1486
+ def search_world_models(self, query: str, size: int = 10) -> list[str]:
1487
+ """Search for world models.
1488
+
1489
+ Args:
1490
+ query: The search query.
1491
+ size: The number of results to return.
1492
+
1493
+ Returns:
1494
+ A list of world model names.
1495
+ """
1496
+ response = self.client.get(f"/v0.1/world-models/search/{query}", params={"size": size})
1497
+ response.raise_for_status()
1498
+ return response.json()
1499
+
1479
1500
  @retry(
1480
1501
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
1481
1502
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
@@ -1549,7 +1570,30 @@ class RestClient:
1549
1570
  f"An unexpected error occurred during world model creation: {e}"
1550
1571
  ) from e
1551
1572
 
1573
+ @retry(
1574
+ stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
1575
+ wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
1576
+ retry=retry_if_connection_error,
1577
+ )
1578
+ async def delete_world_model(self, world_model_id: UUID) -> None:
1579
+ """Delete a world model snapshot by its ID.
1552
1580
 
1581
+ Args:
1582
+ world_model_id: The unique ID of the world model snapshot to delete.
1583
+
1584
+ Raises:
1585
+ WorldModelDeletionError: If the API call fails.
1586
+ """
1587
+ try:
1588
+ response = await self.async_client.delete(f"/v0.1/world-models/{world_model_id}")
1589
+ response.raise_for_status()
1590
+ except HTTPStatusError as e:
1591
+ raise WorldModelDeletionError(
1592
+ f"Error deleting world model: {e.response.status_code} - {e.response.text}"
1593
+ ) from e
1594
+ except Exception as e:
1595
+ raise WorldModelDeletionError(f"An unexpected error occurred: {e}") from e
1596
+
1553
1597
  def get_installed_packages() -> dict[str, str]:
1554
1598
  """Returns a dictionary of installed packages and their versions."""
1555
1599
  return {
@@ -0,0 +1,52 @@
1
+ from futurehouse_client.clients.rest_client import RestClient
2
+ from futurehouse_client.models.app import Stage
3
+ from futurehouse_client.models.rest import WorldModel
4
+ from uuid import UUID
5
+ from aviary.core import Tool
6
+
7
+
8
+ class WorldModelTools:
9
+ CLIENT = RestClient(
10
+ stage = Stage.DEV,
11
+ api_key="Dk7WJRLpqTFNxp5dYRoj6A.platformv01.eyJqdGkiOiI4ODAyZmZiNy1hNjM2LTRkMWYtYWE4NC1lZTQzYTMzMzRjZGMiLCJzdWIiOiJuN1dJbGU5VDljZ1BkTjd2OUJlM0pEUlpZVTgyIiwiaWF0IjoxNzQ5MDc2NzYzfQ.vThmFNLChP54DZBwB+qeMTB6CvAQ1IVXkTcpB0+efZ0",
12
+ )
13
+
14
+ @staticmethod
15
+ def create_world_model(name: str, description: str, content: str) -> UUID:
16
+ """Create a new world model.
17
+
18
+ Args:
19
+ name: The name of the world model.
20
+ description: A description of the world model.
21
+ content: The content/data of the world model.
22
+
23
+ Returns:
24
+ UUID: The ID of the newly created world model.
25
+ """
26
+ world_model = WorldModel(
27
+ name=name,
28
+ description=description,
29
+ content=content,
30
+ )
31
+ return WorldModelTools.CLIENT.create_world_model(world_model)
32
+
33
+ @staticmethod
34
+ def search_world_models(query: str) -> list[str]:
35
+ """Search for world models using a text query.
36
+
37
+ Args:
38
+ query: The search query string to match against world model content.
39
+
40
+ Returns:
41
+ list[str]: A list of world model IDs that match the search query.
42
+ """
43
+ return WorldModelTools.CLIENT.search_world_models(query, size=1)
44
+
45
+ create_world_model_tool = Tool.from_function(WorldModelTools.create_world_model)
46
+ search_world_model_tool = Tool.from_function(WorldModelTools.search_world_models)
47
+
48
+ def make_world_model_tools() -> list[Tool]:
49
+ return [
50
+ search_world_model_tool,
51
+ create_world_model_tool,
52
+ ]
@@ -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.dev105'
21
- __version_tuple__ = version_tuple = (0, 3, 20, 'dev105')
20
+ __version__ = version = '0.3.20.dev112'
21
+ __version_tuple__ = version_tuple = (0, 3, 20, 'dev112')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.3.20.dev105
3
+ Version: 0.3.20.dev112
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
@@ -1,9 +1,9 @@
1
- futurehouse_client/__init__.py,sha256=BztM_ntbgmIEjzvnBWcvPhvLjM8xGDFCK0Upf3-nIn8,488
1
+ futurehouse_client/__init__.py,sha256=rRAJFxDI0nDHiMkyB-d7Q8Y2vVKFVnIFwOuRdjClTPw,707
2
2
  futurehouse_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- futurehouse_client/version.py,sha256=dggvSZjGalP38yUZTaRgokHrf_7S9wpjF6xrQ5xRQlk,530
3
+ futurehouse_client/version.py,sha256=nAw6MsWnD67V5v8vArdCA5jF1Rjl2uTamVcuYk2lPQo,530
4
4
  futurehouse_client/clients/__init__.py,sha256=-HXNj-XJ3LRO5XM6MZ709iPs29YpApss0Q2YYg1qMZw,280
5
5
  futurehouse_client/clients/job_client.py,sha256=D51_qTxya6g5Wfg_ZfJdP031TV_YDJeXkGMiYAJ1qRc,11962
6
- futurehouse_client/clients/rest_client.py,sha256=zfGMFzLWsNWggTDrZpQZm9habxSQ0bJ2Zd5w_dZrJhU,61301
6
+ futurehouse_client/clients/rest_client.py,sha256=hDV1Pr9gemChBKtklnlZlrwSYVUfHEGNGGmVDhoByIw,63015
7
7
  futurehouse_client/models/__init__.py,sha256=5x-f9AoM1hGzJBEHcHAXSt7tPeImST5oZLuMdwp0mXc,554
8
8
  futurehouse_client/models/app.py,sha256=TrfSorJlxyuc9ZzJpd2tL1pzKOp3jNBYRqFMfmmUue0,28954
9
9
  futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
@@ -13,8 +13,9 @@ futurehouse_client/utils/auth.py,sha256=tgWELjKfg8eWme_qdcRmc8TjQN9DVZuHHaVXZNHL
13
13
  futurehouse_client/utils/general.py,sha256=A_rtTiYW30ELGEZlWCIArO7q1nEmqi8hUlmBRYkMQ_c,767
14
14
  futurehouse_client/utils/module_utils.py,sha256=aFyd-X-pDARXz9GWpn8SSViUVYdSbuy9vSkrzcVIaGI,4955
15
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,,
16
+ futurehouse_client/utils/world_model_tools.py,sha256=f-Q1X55HuisYyfTEHhhLMY_VamSMCkdXuHHp_V509bc,1899
17
+ futurehouse_client-0.3.20.dev112.dist-info/licenses/LICENSE,sha256=oQ9ZHjUi-_6GfP3gs14FlPb0OlGwE1QCCKFGnJ4LD2I,11341
18
+ futurehouse_client-0.3.20.dev112.dist-info/METADATA,sha256=a4IX4zQbKP51L71qkqjS8--fvdyIGVQZqneJn7DZuLg,26118
19
+ futurehouse_client-0.3.20.dev112.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ futurehouse_client-0.3.20.dev112.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
21
+ futurehouse_client-0.3.20.dev112.dist-info/RECORD,,