futurehouse-client 0.0.1__tar.gz → 0.0.2__tar.gz

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.
Files changed (36) hide show
  1. futurehouse_client-0.0.2/PKG-INFO +225 -0
  2. futurehouse_client-0.0.2/README.md +187 -0
  3. futurehouse_client-0.0.2/docs/client_notebook.ipynb +197 -0
  4. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/__init__.py +2 -2
  5. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/clients/__init__.py +2 -2
  6. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/clients/job_client.py +1 -1
  7. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/clients/rest_client.py +10 -5
  8. futurehouse_client-0.0.2/futurehouse_client.egg-info/PKG-INFO +225 -0
  9. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client.egg-info/SOURCES.txt +0 -8
  10. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/pyproject.toml +1 -1
  11. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/tests/test_rest.py +2 -2
  12. futurehouse_client-0.0.1/PKG-INFO +0 -151
  13. futurehouse_client-0.0.1/README.md +0 -113
  14. futurehouse_client-0.0.1/docs/client_notebook.ipynb +0 -354
  15. futurehouse_client-0.0.1/docs/client_notebook.md +0 -117
  16. futurehouse_client-0.0.1/docs/crow_client_notebook_w_deployment.ipynb +0 -226
  17. futurehouse_client-0.0.1/docs/envs/dummy_env/__init__.py +0 -3
  18. futurehouse_client-0.0.1/docs/envs/dummy_env/env.py +0 -127
  19. futurehouse_client-0.0.1/docs/envs/dummy_env/requirements.txt +0 -1
  20. futurehouse_client-0.0.1/docs/envs/testEnv/env.py +0 -46
  21. futurehouse_client-0.0.1/futurehouse_client/utils/__init__.py +0 -0
  22. futurehouse_client-0.0.1/futurehouse_client.egg-info/PKG-INFO +0 -151
  23. futurehouse_client-0.0.1/tests/__init__.py +0 -0
  24. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/LICENSE +0 -0
  25. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/docs/__init__.py +0 -0
  26. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/models/__init__.py +0 -0
  27. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/models/app.py +0 -0
  28. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/models/client.py +0 -0
  29. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/models/rest.py +0 -0
  30. {futurehouse_client-0.0.1/docs/envs/testEnv → futurehouse_client-0.0.2/futurehouse_client/utils}/__init__.py +0 -0
  31. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client/utils/module_utils.py +0 -0
  32. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client.egg-info/dependency_links.txt +0 -0
  33. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client.egg-info/requires.txt +0 -0
  34. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/futurehouse_client.egg-info/top_level.txt +0 -0
  35. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/setup.cfg +0 -0
  36. {futurehouse_client-0.0.1 → futurehouse_client-0.0.2}/uv.lock +0 -0
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.4
2
+ Name: futurehouse-client
3
+ Version: 0.0.2
4
+ Summary: A client for interacting with endpoints of the FutureHouse service.
5
+ Author-email: FutureHouse technical staff <hello@futurehouse.org>
6
+ Classifier: Operating System :: OS Independent
7
+ Classifier: Programming Language :: Python :: 3 :: Only
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python
11
+ Requires-Python: <3.13,>=3.11
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: cloudpickle
14
+ Requires-Dist: dm-tree<0.1.9
15
+ Requires-Dist: fhaviary
16
+ Requires-Dist: httpx
17
+ Requires-Dist: ldp>=0.22.0
18
+ Requires-Dist: pydantic
19
+ Requires-Dist: python-dotenv
20
+ Requires-Dist: tenacity
21
+ Provides-Extra: dev
22
+ Requires-Dist: black; extra == "dev"
23
+ Requires-Dist: jupyter; extra == "dev"
24
+ Requires-Dist: jupyterlab; extra == "dev"
25
+ Requires-Dist: mypy; extra == "dev"
26
+ Requires-Dist: notebook; extra == "dev"
27
+ Requires-Dist: pre-commit; extra == "dev"
28
+ Requires-Dist: pylint; extra == "dev"
29
+ Requires-Dist: pylint-per-file-ignores; extra == "dev"
30
+ Requires-Dist: pylint-pydantic; extra == "dev"
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-rerunfailures; extra == "dev"
33
+ Requires-Dist: pytest-subtests; extra == "dev"
34
+ Requires-Dist: pytest-timeout; extra == "dev"
35
+ Requires-Dist: pytest-xdist; extra == "dev"
36
+ Requires-Dist: ruff; extra == "dev"
37
+ Requires-Dist: setuptools_scm; extra == "dev"
38
+
39
+ # FutureHouse Platform API Documentation
40
+
41
+ Documentation and tutorials for crow-client, a client for interacting with endpoints of the FutureHouse crow service.
42
+
43
+ > FutureHouse's mascot is the crow. Therefore, some objects are named after the crow as a homage.
44
+
45
+ <!--TOC-->
46
+
47
+ - [Installation](#installation)
48
+ - [Quickstart](#quickstart)
49
+ - [Functionalities](#functionalities)
50
+ - [Stages](#stages)
51
+ - [Authentication](#authentication)
52
+ - [Job submission](#job-submission)
53
+ - [Job Continuation](#job-continuation)
54
+ - [Job retrieval](#job-retrieval)
55
+
56
+ <!--TOC-->
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ uv pip install crow-client
62
+ ```
63
+
64
+ ## Quickstart
65
+
66
+ ```python
67
+ from crow_client import CrowClient, JobNames
68
+ from pathlib import Path
69
+ from aviary.core import DummyEnv
70
+ import ldp
71
+
72
+ client = CrowClient(
73
+ stage=Stage.DEV,
74
+ auth_type=AuthType.API_KEY,
75
+ api_key="your_api_key",
76
+ )
77
+
78
+ job_data = {
79
+ "name": JobNames.CROW,
80
+ "query": "Has anyone tested therapeutic exerkines in humans or NHPs?",
81
+ }
82
+
83
+ job_run_id = client.create_job(job_data)
84
+
85
+ job_status = client.get_job(job_run_id)
86
+ ```
87
+
88
+ A quickstart example can be found in the [crow_client_notebook.ipynb](./docs/crow_client_notebook.ipynb) 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.
89
+
90
+ ## Functionalities
91
+
92
+ Crow-client implements a RestClient (called `CrowClient`) with the following functionalities:
93
+
94
+ - [Authentication](#authtype): `auth_client`
95
+ - [Job submission](#job-submission): `create_job(JobRequest)`
96
+ - [Job status](#job-status): `get_job(job_id)`
97
+
98
+ To create a `CrowClient`, you need to pass the following parameters:
99
+ | Parameter | Type | Default | Description |
100
+ | --- | --- | --- | --- |
101
+ | stage | Stage | Stage.DEV | Where the job will be submitted? |
102
+ | organization | str \| None | None | Which organization to use? |
103
+ | auth_type | AuthType | AuthType.API_KEY | Which authentication method to use? |
104
+ | api_key | str \| None | None | The API key to use for authentication, if using auth_type=AuthType.API_KEY. |
105
+
106
+ To instantiate a Client, we can use the following code:
107
+
108
+ ```python
109
+ from crow_client import CrowClient
110
+ from crow_client.models import Stage, AuthType
111
+
112
+ client = CrowClient(
113
+ stage=Stage.DEV,
114
+ organization="your_organization",
115
+ auth_type=AuthType.API_KEY,
116
+ api_key="your_api_key",
117
+ )
118
+ ```
119
+
120
+ ### Stages
121
+
122
+ The stage is where your job will be submitted. This parameter can be one of the following:
123
+ | Name | Description |
124
+ | --- | --- |
125
+ | Stage.DEV | Development environment at https://dev.api.platform.futurehouse.org |
126
+ | Stage.PROD | Production environment at https://api.platform.futurehouse.org |
127
+
128
+ ## Authentication
129
+
130
+ In order to use the `CrowClient`, you need to authenticate yourself. Authentication is done by providing an API key, which can be obtained directly from your [profile page in the FutureHouse platform](https://platform.futurehouse.org/profile).
131
+
132
+ ## Job submission
133
+
134
+ `CrowClient` can be used to submit jobs to the FutureHouse platform. Using a `CrowClient` instance, you can submit jobs to the platform by calling the `create_job` method, which receives a `JobRequest` (or a dictionary with `kwargs`) and returns the job id.
135
+ Aiming to make the submission of jobs as simple as possible, we have created a `JobNames` enum that contains the available job types.
136
+
137
+ The available supported jobs are:
138
+ | Alias | Job Name | Task type | Description |
139
+ | --- | --- | --- | --- |
140
+ | `JobNames.CROW` | `job-futurehouse-paperqa2` | Fast Search | Ask a question of scientific data sources, and receive a high-accuracy, cited response. Built with [PaperQA2](https://github.com/Future-House/paper-qa). |
141
+ | `JobNames.FALCON` | `job-futurehouse-paperqa2-deep` | Deep Search | Use a plethora of sources to deeply research. Receive a detailed, structured report as a response. |
142
+ | `JobNames.OWL` | `job-futurehouse-hasanyone` | Precedent Search | Formerly known as HasAnyone, query if anyone has ever done something in science. |
143
+ | `JobNames.DUMMY` | `job-futurehouse-dummy` | Dummy Task | This is a dummy task. Mainly for testing purposes. |
144
+
145
+ Using `JobNames`, the client automatically adapts the job name to the current stage.
146
+ The job submission looks like this:
147
+
148
+ ```python
149
+ from crow_client import CrowClient, JobNames
150
+ from crow_client.models import AuthType, Stage
151
+
152
+ client = CrowClient(
153
+ stage=Stage.DEV,
154
+ auth_type=AuthType.API_KEY,
155
+ api_key="your_api_key",
156
+ )
157
+
158
+ job_data = {
159
+ "name": JobNames.CROW,
160
+ "query": "Has anyone tested therapeutic exerkines in humans or NHPs?",
161
+ }
162
+
163
+ job_id = client.create_job(job_data)
164
+ ```
165
+
166
+ `JobRequest` has the following fields:
167
+
168
+ | Field | Type | Description |
169
+ | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------- |
170
+ | id | UUID | Optional job identifier. A UUID will be generated if not provided |
171
+ | name | str | Name of the job to execute eg. `job-futurehouse-paperqa2`, or using the `JobNames` for convenience: `JobNames.CROW` |
172
+ | query | str | Query or task to be executed by the job |
173
+ | runtime_config | RuntimeConfig | Optional runtime parameters for the job |
174
+
175
+ `runtime_config` can receive a `AgentConfig` object with the desired kwargs. Check the available `AgentConfig` fields in the [LDP documentation](https://github.com/Future-House/ldp/blob/main/src/ldp/agent/agent.py#L87). Besides the `AgentConfig` object, we can also pass `timeout` and `max_steps` to limit the execution time and the number of steps the agent can take.
176
+ Other especialised configurations are also available but are outside the scope of this documentation.
177
+
178
+ ## Job Continuation
179
+
180
+ Once a job is submitted and the answer is returned, FutureHouse platform allow you to ask follow-up questions to the previous job.
181
+ It is also possible through the platform API.
182
+ To accomplish that, we can use the `runtime_config` we discussed in the [Job submission](#job-submission) section.
183
+
184
+ ```python
185
+ from crow_client import CrowClient, JobNames
186
+ from crow_client.models import AuthType, Stage
187
+
188
+ client = CrowClient(
189
+ stage=Stage.DEV,
190
+ auth_type=AuthType.API_KEY,
191
+ api_key="your_api_key",
192
+ )
193
+
194
+ job_data = {"name": JobNames.CROW, "query": "How many species of birds are there?"}
195
+
196
+ job_id = client.create_job(job_data)
197
+
198
+ continued_job_data = {
199
+ "name": JobNames.CROW,
200
+ "query": "From the previous answer, specifically,how many species of crows are there?",
201
+ "runtime_config": {"continued_job_id": job_id},
202
+ }
203
+
204
+ continued_job_id = client.create_job(continued_job_data)
205
+ ```
206
+
207
+ ## Job retrieval
208
+
209
+ Once a job is submitted, you can retrieve it by calling the `get_job` method, which receives a job id and returns a `JobResponse` object.
210
+
211
+ ```python
212
+ from crow_client import CrowClient
213
+ from crow_client.models import AuthType
214
+
215
+ client = CrowClient(
216
+ auth_type=AuthType.API_KEY,
217
+ api_key="your_api_key",
218
+ )
219
+
220
+ job_id = "job_id"
221
+
222
+ job_status = client.get_job(job_id)
223
+ ```
224
+
225
+ `job_status` contains information about the job. For instance, its `status`, `task`, `environment_name` and `agent_name`, and other fields specific to the job.
@@ -0,0 +1,187 @@
1
+ # FutureHouse Platform API Documentation
2
+
3
+ Documentation and tutorials for crow-client, a client for interacting with endpoints of the FutureHouse crow service.
4
+
5
+ > FutureHouse's mascot is the crow. Therefore, some objects are named after the crow as a homage.
6
+
7
+ <!--TOC-->
8
+
9
+ - [Installation](#installation)
10
+ - [Quickstart](#quickstart)
11
+ - [Functionalities](#functionalities)
12
+ - [Stages](#stages)
13
+ - [Authentication](#authentication)
14
+ - [Job submission](#job-submission)
15
+ - [Job Continuation](#job-continuation)
16
+ - [Job retrieval](#job-retrieval)
17
+
18
+ <!--TOC-->
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ uv pip install crow-client
24
+ ```
25
+
26
+ ## Quickstart
27
+
28
+ ```python
29
+ from crow_client import CrowClient, JobNames
30
+ from pathlib import Path
31
+ from aviary.core import DummyEnv
32
+ import ldp
33
+
34
+ client = CrowClient(
35
+ stage=Stage.DEV,
36
+ auth_type=AuthType.API_KEY,
37
+ api_key="your_api_key",
38
+ )
39
+
40
+ job_data = {
41
+ "name": JobNames.CROW,
42
+ "query": "Has anyone tested therapeutic exerkines in humans or NHPs?",
43
+ }
44
+
45
+ job_run_id = client.create_job(job_data)
46
+
47
+ job_status = client.get_job(job_run_id)
48
+ ```
49
+
50
+ A quickstart example can be found in the [crow_client_notebook.ipynb](./docs/crow_client_notebook.ipynb) 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.
51
+
52
+ ## Functionalities
53
+
54
+ Crow-client implements a RestClient (called `CrowClient`) with the following functionalities:
55
+
56
+ - [Authentication](#authtype): `auth_client`
57
+ - [Job submission](#job-submission): `create_job(JobRequest)`
58
+ - [Job status](#job-status): `get_job(job_id)`
59
+
60
+ To create a `CrowClient`, you need to pass the following parameters:
61
+ | Parameter | Type | Default | Description |
62
+ | --- | --- | --- | --- |
63
+ | stage | Stage | Stage.DEV | Where the job will be submitted? |
64
+ | organization | str \| None | None | Which organization to use? |
65
+ | auth_type | AuthType | AuthType.API_KEY | Which authentication method to use? |
66
+ | api_key | str \| None | None | The API key to use for authentication, if using auth_type=AuthType.API_KEY. |
67
+
68
+ To instantiate a Client, we can use the following code:
69
+
70
+ ```python
71
+ from crow_client import CrowClient
72
+ from crow_client.models import Stage, AuthType
73
+
74
+ client = CrowClient(
75
+ stage=Stage.DEV,
76
+ organization="your_organization",
77
+ auth_type=AuthType.API_KEY,
78
+ api_key="your_api_key",
79
+ )
80
+ ```
81
+
82
+ ### Stages
83
+
84
+ The stage is where your job will be submitted. This parameter can be one of the following:
85
+ | Name | Description |
86
+ | --- | --- |
87
+ | Stage.DEV | Development environment at https://dev.api.platform.futurehouse.org |
88
+ | Stage.PROD | Production environment at https://api.platform.futurehouse.org |
89
+
90
+ ## Authentication
91
+
92
+ In order to use the `CrowClient`, you need to authenticate yourself. Authentication is done by providing an API key, which can be obtained directly from your [profile page in the FutureHouse platform](https://platform.futurehouse.org/profile).
93
+
94
+ ## Job submission
95
+
96
+ `CrowClient` can be used to submit jobs to the FutureHouse platform. Using a `CrowClient` instance, you can submit jobs to the platform by calling the `create_job` method, which receives a `JobRequest` (or a dictionary with `kwargs`) and returns the job id.
97
+ Aiming to make the submission of jobs as simple as possible, we have created a `JobNames` enum that contains the available job types.
98
+
99
+ The available supported jobs are:
100
+ | Alias | Job Name | Task type | Description |
101
+ | --- | --- | --- | --- |
102
+ | `JobNames.CROW` | `job-futurehouse-paperqa2` | Fast Search | Ask a question of scientific data sources, and receive a high-accuracy, cited response. Built with [PaperQA2](https://github.com/Future-House/paper-qa). |
103
+ | `JobNames.FALCON` | `job-futurehouse-paperqa2-deep` | Deep Search | Use a plethora of sources to deeply research. Receive a detailed, structured report as a response. |
104
+ | `JobNames.OWL` | `job-futurehouse-hasanyone` | Precedent Search | Formerly known as HasAnyone, query if anyone has ever done something in science. |
105
+ | `JobNames.DUMMY` | `job-futurehouse-dummy` | Dummy Task | This is a dummy task. Mainly for testing purposes. |
106
+
107
+ Using `JobNames`, the client automatically adapts the job name to the current stage.
108
+ The job submission looks like this:
109
+
110
+ ```python
111
+ from crow_client import CrowClient, JobNames
112
+ from crow_client.models import AuthType, Stage
113
+
114
+ client = CrowClient(
115
+ stage=Stage.DEV,
116
+ auth_type=AuthType.API_KEY,
117
+ api_key="your_api_key",
118
+ )
119
+
120
+ job_data = {
121
+ "name": JobNames.CROW,
122
+ "query": "Has anyone tested therapeutic exerkines in humans or NHPs?",
123
+ }
124
+
125
+ job_id = client.create_job(job_data)
126
+ ```
127
+
128
+ `JobRequest` has the following fields:
129
+
130
+ | Field | Type | Description |
131
+ | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------- |
132
+ | id | UUID | Optional job identifier. A UUID will be generated if not provided |
133
+ | name | str | Name of the job to execute eg. `job-futurehouse-paperqa2`, or using the `JobNames` for convenience: `JobNames.CROW` |
134
+ | query | str | Query or task to be executed by the job |
135
+ | runtime_config | RuntimeConfig | Optional runtime parameters for the job |
136
+
137
+ `runtime_config` can receive a `AgentConfig` object with the desired kwargs. Check the available `AgentConfig` fields in the [LDP documentation](https://github.com/Future-House/ldp/blob/main/src/ldp/agent/agent.py#L87). Besides the `AgentConfig` object, we can also pass `timeout` and `max_steps` to limit the execution time and the number of steps the agent can take.
138
+ Other especialised configurations are also available but are outside the scope of this documentation.
139
+
140
+ ## Job Continuation
141
+
142
+ Once a job is submitted and the answer is returned, FutureHouse platform allow you to ask follow-up questions to the previous job.
143
+ It is also possible through the platform API.
144
+ To accomplish that, we can use the `runtime_config` we discussed in the [Job submission](#job-submission) section.
145
+
146
+ ```python
147
+ from crow_client import CrowClient, JobNames
148
+ from crow_client.models import AuthType, Stage
149
+
150
+ client = CrowClient(
151
+ stage=Stage.DEV,
152
+ auth_type=AuthType.API_KEY,
153
+ api_key="your_api_key",
154
+ )
155
+
156
+ job_data = {"name": JobNames.CROW, "query": "How many species of birds are there?"}
157
+
158
+ job_id = client.create_job(job_data)
159
+
160
+ continued_job_data = {
161
+ "name": JobNames.CROW,
162
+ "query": "From the previous answer, specifically,how many species of crows are there?",
163
+ "runtime_config": {"continued_job_id": job_id},
164
+ }
165
+
166
+ continued_job_id = client.create_job(continued_job_data)
167
+ ```
168
+
169
+ ## Job retrieval
170
+
171
+ Once a job is submitted, you can retrieve it by calling the `get_job` method, which receives a job id and returns a `JobResponse` object.
172
+
173
+ ```python
174
+ from crow_client import CrowClient
175
+ from crow_client.models import AuthType
176
+
177
+ client = CrowClient(
178
+ auth_type=AuthType.API_KEY,
179
+ api_key="your_api_key",
180
+ )
181
+
182
+ job_id = "job_id"
183
+
184
+ job_status = client.get_job(job_id)
185
+ ```
186
+
187
+ `job_status` contains information about the job. For instance, its `status`, `task`, `environment_name` and `agent_name`, and other fields specific to the job.
@@ -0,0 +1,197 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# FutureHouse platform client usage example"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "import sys\n",
17
+ "from pathlib import Path\n",
18
+ "\n",
19
+ "sys.path.insert(0, str(Path(\"..\").resolve()))"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "code",
24
+ "execution_count": null,
25
+ "metadata": {},
26
+ "outputs": [],
27
+ "source": [
28
+ "import time\n",
29
+ "\n",
30
+ "from futurehouse_client import Client, JobNames\n",
31
+ "from futurehouse_client.models import (\n",
32
+ " AuthType,\n",
33
+ " JobRequest,\n",
34
+ " RuntimeConfig,\n",
35
+ " Stage,\n",
36
+ ")\n",
37
+ "from ldp.agent import AgentConfig"
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "markdown",
42
+ "metadata": {},
43
+ "source": [
44
+ "## Client instantiation\n",
45
+ "\n",
46
+ "Here we use `auth_type=AuthType.API_KEY` to authenticate with the platform.\n",
47
+ "Please log in to the platform and go to your user settings to get your API key."
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "code",
52
+ "execution_count": null,
53
+ "metadata": {},
54
+ "outputs": [],
55
+ "source": [
56
+ "client = Client(\n",
57
+ " stage=Stage.PROD,\n",
58
+ " auth_type=AuthType.API_KEY,\n",
59
+ " api_key=\"your-api-key\",\n",
60
+ ")"
61
+ ]
62
+ },
63
+ {
64
+ "cell_type": "markdown",
65
+ "metadata": {},
66
+ "source": [
67
+ "## Submit a job"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "markdown",
72
+ "metadata": {},
73
+ "source": [
74
+ "Submitting jobs is done by calling the `create_job` method, which receives a `JobRequest` object."
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": null,
80
+ "metadata": {},
81
+ "outputs": [],
82
+ "source": [
83
+ "job_data = JobRequest(\n",
84
+ " name=JobNames.from_string(\"crow\"),\n",
85
+ " query=\"What is the molecule known to have the greatest solubility in water?\",\n",
86
+ ")\n",
87
+ "client.create_job(job_data)\n",
88
+ "\n",
89
+ "while client.get_job().status != \"success\":\n",
90
+ " time.sleep(5)\n",
91
+ "print(f\"Job status: {client.get_job().status}\")\n",
92
+ "print(f\"Job answer: \\n{client.get_job().formatted_answer}\")"
93
+ ]
94
+ },
95
+ {
96
+ "cell_type": "markdown",
97
+ "metadata": {},
98
+ "source": [
99
+ "You can also pass a `runtime_config` to the job, which will be used to configure the agent on runtime.\n",
100
+ "Here, we will define a agent configuration and pass it to the job. This agent is used to decide the next action to take.\n",
101
+ "We will also use the `max_steps` parameter to limit the number of steps the agent will take."
102
+ ]
103
+ },
104
+ {
105
+ "cell_type": "code",
106
+ "execution_count": null,
107
+ "metadata": {},
108
+ "outputs": [],
109
+ "source": [
110
+ "agent = AgentConfig(\n",
111
+ " agent_type=\"SimpleAgent\",\n",
112
+ " agent_kwargs={\n",
113
+ " \"model\": \"gpt-4o\",\n",
114
+ " \"temperature\": 0.0,\n",
115
+ " },\n",
116
+ ")\n",
117
+ "job_data = JobRequest(\n",
118
+ " name=JobNames.CROW,\n",
119
+ " query=\"How many moons does earth have?\",\n",
120
+ " runtime_config=RuntimeConfig(agent=agent, max_steps=10),\n",
121
+ ")\n",
122
+ "client.create_job(job_data)\n",
123
+ "\n",
124
+ "while client.get_job().status != \"success\":\n",
125
+ " time.sleep(5)\n",
126
+ "print(f\"Job status: {client.get_job().status}\")\n",
127
+ "print(f\"Job answer: \\n{client.get_job().formatted_answer}\")"
128
+ ]
129
+ },
130
+ {
131
+ "cell_type": "markdown",
132
+ "metadata": {},
133
+ "source": [
134
+ "# Continue a job\n",
135
+ "\n",
136
+ "The platform allows to keep asking follow-up questions to the previous job.\n",
137
+ "To accomplish that, we can use the `runtime_config` to pass the `job_id` of the previous job.\n",
138
+ "\n",
139
+ "Notice that `create_job` accepts both a `JobRequest` object and a dictionary with keywords arguments."
140
+ ]
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": null,
145
+ "metadata": {},
146
+ "outputs": [],
147
+ "source": [
148
+ "job_data = JobRequest(name=JobNames.CROW, query=\"How many species of birds are there?\")\n",
149
+ "\n",
150
+ "job_id = client.create_job(job_data)\n",
151
+ "while client.get_job().status != \"success\":\n",
152
+ " time.sleep(5)\n",
153
+ "print(f\"First job status: {client.get_job().status}\")\n",
154
+ "print(f\"First job answer: \\n{client.get_job().formatted_answer}\")"
155
+ ]
156
+ },
157
+ {
158
+ "cell_type": "code",
159
+ "execution_count": null,
160
+ "metadata": {},
161
+ "outputs": [],
162
+ "source": [
163
+ "continued_job_data = {\n",
164
+ " \"name\": JobNames.CROW,\n",
165
+ " \"query\": \"From the previous answer, specifically,how many species of crows are there?\",\n",
166
+ " \"runtime_config\": {\"continued_job_id\": job_id},\n",
167
+ "}\n",
168
+ "\n",
169
+ "continued_job_id = client.create_job(continued_job_data)\n",
170
+ "while client.get_job().status != \"success\":\n",
171
+ " time.sleep(5)\n",
172
+ "print(f\"Continued job status: {client.get_job().status}\")\n",
173
+ "print(f\"Continued job answer: \\n{client.get_job().formatted_answer}\")"
174
+ ]
175
+ }
176
+ ],
177
+ "metadata": {
178
+ "kernelspec": {
179
+ "display_name": ".venv",
180
+ "language": "python",
181
+ "name": "python3"
182
+ },
183
+ "language_info": {
184
+ "codemirror_mode": {
185
+ "name": "ipython",
186
+ "version": 3
187
+ },
188
+ "file_extension": ".py",
189
+ "mimetype": "text/x-python",
190
+ "name": "python",
191
+ "nbconvert_exporter": "python",
192
+ "pygments_lexer": "ipython3"
193
+ }
194
+ },
195
+ "nbformat": 4,
196
+ "nbformat_minor": 4
197
+ }
@@ -1,9 +1,9 @@
1
1
  from .clients.job_client import JobClient, JobNames
2
2
  from .clients.rest_client import JobResponse, JobResponseVerbose, PQAJobResponse
3
- from .clients.rest_client import RestClient as Client
3
+ from .clients.rest_client import RestClient as FutureHouseClient
4
4
 
5
5
  __all__ = [
6
- "Client",
6
+ "FutureHouseClient",
7
7
  "JobClient",
8
8
  "JobNames",
9
9
  "JobResponse",
@@ -1,9 +1,9 @@
1
1
  from .job_client import JobClient, JobNames
2
2
  from .rest_client import JobResponse, JobResponseVerbose, PQAJobResponse
3
- from .rest_client import RestClient as CrowClient
3
+ from .rest_client import RestClient as FutureHouseClient
4
4
 
5
5
  __all__ = [
6
- "CrowClient",
6
+ "FutureHouseClient",
7
7
  "JobClient",
8
8
  "JobNames",
9
9
  "JobResponse",
@@ -19,7 +19,7 @@ logger = logging.getLogger(__name__)
19
19
 
20
20
 
21
21
  class JobNames(StrEnum):
22
- """Enum of available crow jobs."""
22
+ """Enum of available jobs."""
23
23
 
24
24
  CROW = "job-futurehouse-paperqa2"
25
25
  FALCON = "job-futurehouse-paperqa2-deep"