This commit is contained in:
Isaac Francisco
2024-06-26 10:41:29 -07:00
committed by GitHub
parent fae97d9fba
commit 6caea79fba
3 changed files with 81 additions and 8 deletions
+9 -8
View File
@@ -188,14 +188,15 @@ nav:
- Run Agent in Background: "cloud/how-tos/cloud_examples/background_run.ipynb"
- Run Multiple Agents in Thread: "cloud/how-tos/cloud_examples/same-thread.ipynb"
- Human-in-the-Loop:
- Add Breakpoint: "cloud/how-tos/cloud_examples/human_in_the_loop_breakpoint.ipynb"
- Wait for User Input: "cloud/how-tos/cloud_examples/human_in_the_loop_user_input.ipynb"
- Edit Graph State: "cloud/how-tos/cloud_examples/human_in_the_loop_edit_state.ipynb"
- Replay and Branch from Prior States: "cloud/how-tos/cloud_examples/human_in_the_loop_time_travel.ipynb"
- Create Agents with Configuration: "cloud/how-tos/cloud_examples/configuration_cloud.ipynb"
- Convert LangGraph calls to LangGraph Cloud calls: "cloud/how-tos/cloud_examples/langgraph_to_langgraph_cloud.ipynb"
- Create Cron Jobs: "cloud/how-tos/cloud_examples/cron_jobs.ipynb"
- Create Stateless Runs: "cloud/how-tos/cloud_examples/stateless_runs.ipynb"
- Add Breakpoint: 'cloud/how-tos/cloud_examples/human_in_the_loop_breakpoint.ipynb'
- Wait for User Input: 'cloud/how-tos/cloud_examples/human_in_the_loop_user_input.ipynb'
- Edit Graph State: 'cloud/how-tos/cloud_examples/human_in_the_loop_edit_state.ipynb'
- Replay and Branch from Prior States: 'cloud/how-tos/cloud_examples/human_in_the_loop_time_travel.ipynb'
- Create Agents with Configuration: 'cloud/how-tos/cloud_examples/configuration_cloud.ipynb'
- Convert LangGraph calls to LangGraph Cloud calls: 'cloud/how-tos/cloud_examples/langgraph_to_langgraph_cloud.ipynb'
- Create Cron Jobs: 'cloud/how-tos/cloud_examples/cron_jobs.ipynb'
- Create Stateless Runs: 'cloud/how-tos/cloud_examples/stateless_runs.ipynb'
- Integrate Webhooks: 'cloud/how-tos/cloud_examples/webhooks.ipynb'
- SDK:
- Python: "cloud/sdk/python_sdk.ipynb"
- JS/TS: "cloud/sdk/js_sdk.ipynb"
Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

+72
View File
@@ -0,0 +1,72 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Use Webhooks\n",
"\n",
"You may wish to use webhooks in your client, especially when using async streams in case you want to update something in your service once the API call to Langgraph Cloud has finished running. To do so, you will need to expose an endpoint that can accept POST requests, and then pass it to your API request in the \"webhook\" parameter.\n",
"\n",
"Currently, the SDK has not exposed this endpoint but you can access it through curl commands as follows.\n",
"\n",
"The following endpoints accept `webhook` as a parameter: \n",
"\n",
"- Create Run -> POST /thread/{thread_id}/runs\n",
"- Create Thread Cron -> POST /thread/{thread_id}/runs/crons\n",
"- Stream Run -> POST /thread/{thread_id}/runs/stream\n",
"- Wait Run -> POST /thread/{thread_id}/runs/wait\n",
"- Create Cron -> POST /runs/crons\n",
"- Stream Run Stateless -> POST /runs/stream\n",
"- Wait Run Stateless -> POST /runs/wait\n",
"\n",
"The following example uses a url from a public website that allows users to create free webhooks, but you should pass in the webhook that you wish to use. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"curl --request POST \\\n",
" --url http://localhost:8123/threads/b76d1e94-f251-40e3-8933-796d775cdb4c/runs/stream \\\n",
" --header 'Content-Type: application/json' \\\n",
" --data '{\n",
" \"assistant_id\": \"fe096781-5601-53d2-b2f6-0d3403f7e9ca\",\n",
" \"input\" : {\"messages\":[{\"role\": \"user\", \"content\": \"Hello! My name is Bagatur and I am 26 years old.\"}]},\n",
" \"metadata\": {},\n",
" \"config\": {\n",
" \"configurable\": {}\n",
" },\n",
" \"multitask_strategy\": \"reject\",\n",
" \"stream_mode\": [\n",
" \"values\"\n",
" ],\n",
" \"webhook\": \"https://webhook.site/6ca33471-dd65-4103-a851-0a252dae0f2a\"\n",
"}'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To check that this worked as intended, we can go to the website where our webhook was created and confirm that it received a POST request:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Webhook response](./img/webhook_results.png)"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}