Skip to content

Commit 91fee37

Browse files
authored
Updated how to access the response from run_tasks_until_done (#23)
* Updated how to access the response from run_tasks_until_done * Update docs/client_notebook.md * Changed old create_task to run_tasks_until_done in docs
1 parent 7d2fc6c commit 91fee37

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

docs/client_notebook.ipynb

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
"metadata": {},
5555
"source": [
5656
"In the futurehouse platform, we refer to the deployed combination of agent and environment as a `job`.\n",
57-
"Submitting task to a futurehouse job is done by calling the `create_task` method, which receives a `TaskRequest` object."
57+
"Submitting task to a futurehouse job is done by calling the `run_tasks_until_done` method, which receives a `TaskRequest` object.\n",
58+
"\n",
59+
"For convenience, one can use the `run_tasks_until_done` method, which submits the task and returns a list of `TaskResponse` objects."
5860
]
5961
},
6062
{
@@ -67,7 +69,8 @@
6769
" name=JobNames.from_string(\"crow\"),\n",
6870
" query=\"What is the molecule known to have the greatest solubility in water?\",\n",
6971
")\n",
70-
"task_response = client.run_tasks_until_done(task_data)\n",
72+
"responses = client.run_tasks_until_done(task_data)\n",
73+
"task_response = responses[0]\n",
7174
"\n",
7275
"print(f\"Job status: {task_response.status}\")\n",
7376
"print(f\"Job answer: \\n{task_response.formatted_answer}\")"
@@ -77,7 +80,7 @@
7780
"cell_type": "markdown",
7881
"metadata": {},
7982
"source": [
80-
"You can also pass a `runtime_config` to the `create_task` method, which will be used to configure the agent on runtime.\n",
83+
"You can also pass a `runtime_config` to the `run_tasks_until_done` method, which will be used to configure the agent on runtime.\n",
8184
"Here, we will define a agent configuration and include it in the `TaskRequest`. This agent is used to decide the next action to take.\n",
8285
"We will also use the `max_steps` parameter to limit the number of steps the agent will take."
8386
]
@@ -100,7 +103,8 @@
100103
" query=\"How many moons does earth have?\",\n",
101104
" runtime_config=RuntimeConfig(agent=agent, max_steps=10),\n",
102105
")\n",
103-
"task_response = client.run_tasks_until_done(task_data)\n",
106+
"responses = client.run_tasks_until_done(task_data)\n",
107+
"task_response = responses[0]\n",
104108
"\n",
105109
"print(f\"Job status: {task_response.status}\")\n",
106110
"print(f\"Job answer: \\n{task_response.formatted_answer}\")"
@@ -115,7 +119,7 @@
115119
"The platform allows to ask follow-up questions to the previous job.\n",
116120
"To accomplish that, we can use the `runtime_config` to pass the `task_id` of the previous task.\n",
117121
"\n",
118-
"Notice that `create_task` accepts both a `TaskRequest` object and a dictionary with keywords arguments."
122+
"Notice that `run_tasks_until_done` accepts both a `TaskRequest` object and a dictionary with keywords arguments."
119123
]
120124
},
121125
{
@@ -128,7 +132,8 @@
128132
" name=JobNames.CROW, query=\"How many species of birds are there?\"\n",
129133
")\n",
130134
"\n",
131-
"task_response = client.run_tasks_until_done(task_data)\n",
135+
"responses = client.run_tasks_until_done(task_data)\n",
136+
"task_response = responses[0]\n",
132137
"\n",
133138
"print(f\"First job status: {task_response.status}\")\n",
134139
"print(f\"First job answer: \\n{task_response.formatted_answer}\")"
@@ -146,7 +151,8 @@
146151
" \"runtime_config\": {\"continued_job_id\": task_response.task_id},\n",
147152
"}\n",
148153
"\n",
149-
"continued_task_response = client.run_tasks_until_done(continued_job_data)\n",
154+
"responses = client.run_tasks_until_done(continued_job_data)\n",
155+
"continued_task_response = responses[0]\n",
150156
"\n",
151157
"\n",
152158
"print(f\"Continued job status: {continued_task_response.status}\")\n",

docs/client_notebook.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,23 @@ client = FutureHouseClient(
3838

3939

4040
In the futurehouse platform, we refer to the deployed combination of agent and environment as a `job`.
41-
Submitting task to a futurehouse job is done by calling the `create_task` method, which receives a `TaskRequest` object.
41+
Submitting task to a futurehouse job is done by calling the `run_tasks_until_done` method, which receives a `TaskRequest` object.
42+
43+
For convenience, one can use the `run_tasks_until_done` method, which submits the task and returns a list of `TaskResponse` objects.
4244

4345
```python
4446
task_data = TaskRequest(
4547
name=JobNames.from_string("crow"),
4648
query="What is the molecule known to have the greatest solubility in water?",
4749
)
48-
task_response = client.run_tasks_until_done(task_data)
50+
responses = client.run_tasks_until_done(task_data)
51+
task_response = responses[0]
4952

5053
print(f"Job status: {task_response.status}")
5154
print(f"Job answer: \n{task_response.formatted_answer}")
5255
```
5356

54-
You can also pass a `runtime_config` to the `create_task` method, which will be used to configure the agent on runtime.
57+
You can also pass a `runtime_config` to the `run_tasks_until_done` method, which will be used to configure the agent on runtime.
5558
Here, we will define a agent configuration and include it in the `TaskRequest`. This agent is used to decide the next action to take.
5659
We will also use the `max_steps` parameter to limit the number of steps the agent will take.
5760

@@ -68,7 +71,8 @@ task_data = TaskRequest(
6871
query="How many moons does earth have?",
6972
runtime_config=RuntimeConfig(agent=agent, max_steps=10),
7073
)
71-
task_response = client.run_tasks_until_done(task_data)
74+
responses = client.run_tasks_until_done(task_data)
75+
task_response = responses[0]
7276

7377
print(f"Job status: {task_response.status}")
7478
print(f"Job answer: \n{task_response.formatted_answer}")
@@ -79,14 +83,15 @@ print(f"Job answer: \n{task_response.formatted_answer}")
7983
The platform allows to ask follow-up questions to the previous job.
8084
To accomplish that, we can use the `runtime_config` to pass the `task_id` of the previous task.
8185

82-
Notice that `create_task` accepts both a `TaskRequest` object and a dictionary with keywords arguments.
86+
Notice that `run_tasks_until_done` accepts both a `TaskRequest` object and a dictionary with keywords arguments.
8387

8488
```python
8589
task_data = TaskRequest(
8690
name=JobNames.CROW, query="How many species of birds are there?"
8791
)
8892

89-
task_response = client.run_tasks_until_done(task_data)
93+
responses = client.run_tasks_until_done(task_data)
94+
task_response = responses[0]
9095

9196
print(f"First job status: {task_response.status}")
9297
print(f"First job answer: \n{task_response.formatted_answer}")
@@ -101,7 +106,8 @@ continued_job_data = {
101106
"runtime_config": {"continued_job_id": task_response.task_id},
102107
}
103108

104-
continued_task_response = client.run_tasks_until_done(continued_job_data)
109+
responses = client.run_tasks_until_done(continued_job_data)
110+
continued_task_response = responses[0]
105111

106112

107113
print(f"Continued job status: {continued_task_response.status}")

0 commit comments

Comments
 (0)