You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6f7e77f
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: adev-ja/src/content/ai/design-patterns.en.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ A common pattern when working with user-provided prompts is to separate the user
10
10
2. When the user submits (e.g., by clicking a button), update a second signal with contents of the first signal.
11
11
3. Use the second signal in the **`params`** field of your `resource`.
12
12
13
-
This setup ensures the resource's **`loader`** function only runs when the user explicitly submits their prompt, not on every keystroke. You can use additional signal parameters, like a `sessionId` or `userId` (which can be useful for creating persistent LLM sessions), in the `loader` field. This way, the request always uses these parameters' current values without re-triggering the asyncronous function defined in the `loader` field.
13
+
This setup ensures the resource's **`loader`** function only runs when the user explicitly submits their prompt, not on every keystroke. You can use additional signal parameters, like a `sessionId` or `userId` (which can be useful for creating persistent LLM sessions), in the `loader` field. This way, the request always uses these parameters' current values without re-triggering the asynchronous function defined in the `loader` field.
14
14
15
15
Many AI SDKs provide helper methods for making API calls. For example, the Genkit client library exposes a `runFlow` method for calling Genkit flows, which you can call from a resource's `loader`. For other APIs, you can use the [`httpResource`](guide/signals/resource#reactive-data-fetching-with-httpresource).
16
16
@@ -90,14 +90,14 @@ The following example demonstrates how to create a responsive UI to dynamically
90
90
91
91
92
92
## AI patterns in action: streaming chat responses
93
-
Interfaces often display partial results from LLM-based APIs incrementally as response data arrives. Angular's resource API provides the ability to stream responses to support this type of pattern. The `stream` property of `resource` accepts an asyncronous function you can use to apply updates to a signal value over time. The signal being updated represents the data being streamed.
93
+
Interfaces often display partial results from LLM-based APIs incrementally as response data arrives. Angular's resource API provides the ability to stream responses to support this type of pattern. The `stream` property of `resource` accepts an asynchronous function you can use to apply updates to a signal value over time. The signal being updated represents the data being streamed.
94
94
95
95
```ts
96
96
characters=resource({
97
97
stream: async () => {
98
98
const data =signal<ResourceStreamItem<string>>({value: ''});
99
99
// Calls a Genkit streaming flow using the streamFlow method
0 commit comments