Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/ai-quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Invoke the agent via the Restate UI playground: go to `http://localhost:9070`, c

Or invoke via `curl`:
```shell
curl localhost:8080/agent/run --json '{"prompt": "What is the weather in San Francisco?"}'
curl localhost:8080/restate/call/agent/run --json '{"prompt": "What is the weather in San Francisco?"}'
```
Output: `The weather in San Francisco is currently 23°C and sunny.`.
</Step>
Expand Down Expand Up @@ -240,7 +240,7 @@ Invoke the agent via the Restate UI playground: go to `http://localhost:9070`, c

Or invoke via `curl`:
```shell
curl localhost:8080/agent/run --json '{"message": "What is the weather in San Francisco?"}'
curl localhost:8080/restate/call/agent/run --json '{"message": "What is the weather in San Francisco?"}'
```
Output: `The weather in San Francisco is sunny and 23°C.`

Expand Down Expand Up @@ -386,7 +386,7 @@ Invoke the agent via the Restate UI playground: go to `http://localhost:9070`, c

Or invoke via `curl`:
```shell
curl localhost:8080/agent/run --json '{
curl localhost:8080/restate/call/agent/run --json '{
"message": "What is the weather like in San Francisco?",
"user_id": "user-123"
}'
Expand Down Expand Up @@ -565,7 +565,7 @@ Invoke the agent via the Restate UI playground: go to `http://localhost:9070`, c

Or invoke via `curl`:
```shell
curl localhost:8080/agent/run --json '{"message": "What is the weather in San Francisco?"}'
curl localhost:8080/restate/call/agent/run --json '{"message": "What is the weather in San Francisco?"}'
```
Output: `The weather in San Francisco is sunny and 23°C.`

Expand Down Expand Up @@ -705,7 +705,7 @@ Invoke the agent via the Restate UI playground: go to `http://localhost:9070`, c

Or invoke via `curl`:
```shell
curl localhost:8080/agent/run --json '{"message": "What is the weather in San Francisco?"}'
curl localhost:8080/restate/call/agent/run --json '{"message": "What is the weather in San Francisco?"}'
```
Output: `The weather in San Francisco is sunny and 23°C.`

Expand Down Expand Up @@ -844,7 +844,7 @@ Invoke the agent via the Restate UI playground: go to `http://localhost:9070`, c

Or invoke via `curl`:
```shell
curl localhost:8080/agent/run --json '{"message": "What is the weather in San Francisco?"}'
curl localhost:8080/restate/call/agent/run --json '{"message": "What is the weather in San Francisco?"}'
```
Output: `The weather in San Francisco is currently 23°C and sunny.`
</Step>
Expand Down Expand Up @@ -1026,7 +1026,7 @@ Invoke the agent via the Restate UI playground: go to `http://localhost:9070`, c

Or invoke via `curl`:
```shell
curl localhost:8080/agent/chat --json '{"message": "What is the weather in San Francisco?"}'
curl localhost:8080/restate/call/agent/chat --json '{"message": "What is the weather in San Francisco?"}'
```
Output: `The weather in San Francisco is currently 23°C and sunny.`
</Step>
Expand Down
30 changes: 18 additions & 12 deletions docs/ai/patterns/chat-ui-integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ You can also call Restate services using plain HTTP requests without the SDK.
For example, in JavaScript:
```javascript {"CODE_LOAD::ts/src/ai/guides/chat-ui/http_requests.js#here"}
// Request-response
const response = await fetch("http://localhost:8080/my-agent/run", {
const response = await fetch("http://localhost:8080/restate/call/my-agent/run", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message: "How are you?" }),
});
const result = await response.json();

// Fire-and-forget: add /send to the URL
await fetch("http://localhost:8080/my-agent/run/send", {
// Fire-and-forget: use the /restate/send/... path
await fetch("http://localhost:8080/restate/send/my-agent/run", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message: "How are you?" }),
Expand All @@ -113,7 +113,7 @@ await fetch("http://localhost:8080/my-agent/run/send", {
You can let Restate deduplicate requests by adding an idempotency key to the header of your request.

```javascript {"CODE_LOAD::ts/src/ai/guides/chat-ui/http_requests.js#idempotency"}
await fetch("http://localhost:8080/my-agent/run/send", {
await fetch("http://localhost:8080/restate/send/my-agent/run", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -136,7 +136,7 @@ There are three ways to do this:

```javascript {"CODE_LOAD::ts/src/ai/guides/chat-ui/http_requests.js#attach"}
// start the invocation
const handle = await fetch("http://localhost:8080/agent/run/send", {
const handle = await fetch("http://localhost:8080/restate/send/agent/run", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify("How are you?"),
Expand All @@ -145,9 +145,9 @@ const handle = await fetch("http://localhost:8080/agent/run/send", {
// retrieve the invocationId
const { invocationId, status } = await handle.json();

// retrieve the result
// retrieve the result by attaching to the invocation id
const result = await fetch(
`http://localhost:8080/restate/invocation/${invocationId}/attach`,
`http://localhost:8080/restate/attach/${invocationId}`,
{ method: "GET" }
);
await result.json();
Expand All @@ -156,12 +156,18 @@ await result.json();
3. If you started the invocation with an idempotency key, then you can use that to attach to it. This does not start the invocation as opposed to point 1:

```javascript {"CODE_LOAD::ts/src/ai/guides/chat-ui/http_requests.js#attach_idem"}
// start the invocation with idempotency key
// attach via the idempotency key of an earlier invocation
const idempotencyKey = "abc-123";
const result = await fetch(
`http://localhost:8080/restate/invocation/agent/run/${idempotencyKey}/attach`,
{ method: "GET" }
);
const result = await fetch(`http://localhost:8080/restate/attach`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
type: "idempotency",
service: "agent",
handler: "run",
idempotencyKey,
}),
});
await result.json();
```

Expand Down
4 changes: 2 additions & 2 deletions docs/ai/patterns/competitive-racing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request:
```bash
curl localhost:8080/RacingAgent/run \
curl localhost:8080/restate/call/RacingAgent/run \
--json '{
"message": "What is the best approach to learn machine learning?"
}'
Expand Down Expand Up @@ -126,7 +126,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request:
```bash
curl localhost:8080/RacingAgent/run \
curl localhost:8080/restate/call/RacingAgent/run \
--json '{
"message": "What is the best approach to learn machine learning?"
}'
Expand Down
42 changes: 21 additions & 21 deletions docs/ai/patterns/human-in-the-loop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ Register the agents with Restate:
restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations
```

Use `curl` with `/send` to start the claim asynchronously, without waiting for the result:
Use `curl` with the `send` verb to start the claim asynchronously, without waiting for the result:
```bash
curl localhost:8080/HumanClaimApprovalAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalAgent/run \
--json '{"prompt": "Process my hospital bill of 3000USD for a broken leg."}'
```

Expand Down Expand Up @@ -145,9 +145,9 @@ Register the agents with Restate:
restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations
```

Use `curl` with `/send` to start the claim asynchronously, without waiting for the result:
Use `curl` with the `send` verb to start the claim asynchronously, without waiting for the result:
```bash
curl localhost:8080/HumanClaimApprovalAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```

Expand Down Expand Up @@ -203,9 +203,9 @@ Register the agents with Restate:
restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations
```

Use `curl` with `/send` to start the claim asynchronously, without waiting for the result:
Use `curl` with the `send` verb to start the claim asynchronously, without waiting for the result:
```bash
curl localhost:8080/HumanClaimApprovalAgent/user-123/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalAgent/user-123/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg.", "session_id": "session-123"}'
```

Expand Down Expand Up @@ -260,9 +260,9 @@ Register the agents with Restate:
restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations
```

Use `curl` with `/send` to start the claim asynchronously, without waiting for the result:
Use `curl` with the `send` verb to start the claim asynchronously, without waiting for the result:
```bash
curl localhost:8080/HumanClaimApprovalAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```

Expand Down Expand Up @@ -317,9 +317,9 @@ Register the agents with Restate:
restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations
```

Use `curl` with `/send` to start the claim asynchronously, without waiting for the result:
Use `curl` with the `send` verb to start the claim asynchronously, without waiting for the result:
```bash
curl localhost:8080/HumanClaimApprovalAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```

Expand Down Expand Up @@ -388,9 +388,9 @@ Register the services with Restate:
restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations
```

Use `curl` with `/send` to start the moderation asynchronously:
Use `curl` with the `send` verb to start the moderation asynchronously:
```bash
curl localhost:8080/HumanClaimApprovalAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```

Expand Down Expand Up @@ -475,9 +475,9 @@ Register the services with Restate:
restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations
```

Use `curl` with `/send` to start the claim asynchronously, without waiting for the result:
Use `curl` with the `send` verb to start the claim asynchronously, without waiting for the result:
```bash
curl localhost:8080/HumanClaimApprovalAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```

Expand Down Expand Up @@ -543,7 +543,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request to the service:
```bash
curl localhost:8080/HumanClaimApprovalWithTimeoutsAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalWithTimeoutsAgent/run \
--json '{"prompt": "Process my hospital bill of 3000USD for a broken leg."}'
```
Restart the service and check in the UI how the process will block for the remaining time without starting over.
Expand Down Expand Up @@ -591,7 +591,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request to the service:
```bash
curl localhost:8080/HumanClaimApprovalWithTimeoutsAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalWithTimeoutsAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```
Restart the service and check in the UI how the process will block for the remaining time without starting over.
Expand Down Expand Up @@ -641,7 +641,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request to the service:
```bash
curl localhost:8080/HumanClaimApprovalWithTimeoutsAgent/user-123/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalWithTimeoutsAgent/user-123/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg.", "session_id": "session-123"}'
```
Restart the service and check in the UI how the process will block for the remaining time without starting over.
Expand Down Expand Up @@ -693,7 +693,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request to the service:
```bash
curl localhost:8080/HumanClaimApprovalWithTimeoutsAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalWithTimeoutsAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```
Restart the service and check in the UI how the process will block for the remaining time without starting over.
Expand Down Expand Up @@ -741,7 +741,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request to the service:
```bash
curl localhost:8080/HumanClaimApprovalWithTimeoutsAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalWithTimeoutsAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```
Restart the service and check in the UI how the process will block for the remaining time without starting over.
Expand Down Expand Up @@ -784,7 +784,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request to the service:
```bash
curl localhost:8080/HumanClaimApprovalWithTimeoutsAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalWithTimeoutsAgent/run \
--json '{"prompt": "Process my hospital bill of 3000USD for a broken leg."}'
```
Restart the service and check in the UI how the process will block for the remaining time without starting over.
Expand Down Expand Up @@ -832,7 +832,7 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

Send a request to the service:
```bash
curl localhost:8080/HumanClaimApprovalWithTimeoutsAgent/run/send \
curl localhost:8080/restate/send/HumanClaimApprovalWithTimeoutsAgent/run \
--json '{"message": "Process my hospital bill of 3000USD for a broken leg."}'
```
Restart the service and check in the UI how the process will block for the remaining time without starting over.
Expand Down
20 changes: 10 additions & 10 deletions docs/ai/patterns/interrupt-regenerate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,24 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

**Happy path** — one message, one full response:
```bash
curl localhost:8080/CodingAgent/alice/message \
curl localhost:8080/restate/call/CodingAgent/alice/message \
--json '{"content":"Write me a small todo CLI in TypeScript."}'

# Wait a few seconds, then:
curl localhost:8080/CodingAgent/alice/getHistory
curl localhost:8080/restate/call/CodingAgent/alice/getHistory
```

**Interruption path** — fire a first message, then interrupt before it finishes:
```bash
# Fire-and-forget the first message
curl localhost:8080/CodingAgent/bob/message/send \
curl localhost:8080/restate/send/CodingAgent/bob/message \
--json '{"content":"Build a Fastify app with user auth."}'

# Immediately interrupt with new context
curl localhost:8080/CodingAgent/bob/message \
curl localhost:8080/restate/call/CodingAgent/bob/message \
--json '{"content":"Actually, use Hono instead of Fastify."}'

curl localhost:8080/CodingAgent/bob/getHistory
curl localhost:8080/restate/call/CodingAgent/bob/getHistory
```

Open the Restate UI at `http://localhost:9070` to inspect the invocations — the first `CodingTask.runTask` shows status `cancelled`, and the second `completed`.
Expand Down Expand Up @@ -296,24 +296,24 @@ restate deployments register http://localhost:9080 --force --yes # dev only: ove

**Happy path**: one message, one full response:
```bash
curl localhost:8080/CodingAgent/alice/message \
curl localhost:8080/restate/call/CodingAgent/alice/message \
--json '{"content":"Write me a small todo CLI in Python."}'

# Wait a few seconds, then:
curl localhost:8080/CodingAgent/alice/get_history
curl localhost:8080/restate/call/CodingAgent/alice/get_history
```

**Interruption path**: fire a first message, then interrupt before it finishes:
```bash
# Fire-and-forget the first message
curl localhost:8080/CodingAgent/bob/message/send \
curl localhost:8080/restate/send/CodingAgent/bob/message \
--json '{"content":"Build a Flask app with user auth."}'

# Immediately interrupt with new context
curl localhost:8080/CodingAgent/bob/message \
curl localhost:8080/restate/call/CodingAgent/bob/message \
--json '{"content":"Actually, use FastAPI instead of Flask."}'

curl localhost:8080/CodingAgent/bob/get_history
curl localhost:8080/restate/call/CodingAgent/bob/get_history
```

Open the Restate UI at `http://localhost:9070` to inspect the invocations — the first `CodingTask.run_task` shows status `cancelled`, and the second `completed`.
Expand Down
Loading
Loading