Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs[patch]: Update Gen UI docs #6093

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
33 changes: 23 additions & 10 deletions docs/core_docs/docs/how_to/generative_ui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ The usage is then as follows:
```tsx ai/chain.tsx
"use server";

const tool = new DynamicStructuredTool({
// ...
func: async (input, config) => {
// create a new streamable UI and wire it up to the streamEvents
const stream = createRunnableUI(config);
const tool = tool(
async (input, config) => {
const stream = await createRunnableUI(config);
stream.update(<div>Searching...</div>);

const result = await images(input);

// update the UI element with the rendered results
stream.done(
<Images
images={result.images_results
Expand All @@ -35,7 +31,15 @@ const tool = new DynamicStructuredTool({

return `[Returned ${result.images_results.length} images]`;
},
});
{
name: "Images",
description: "A tool to search for images. input should be a search query.",
schema: z.object({
query: z.string().describe("The search query used to search for cats"),
limit: z.number().describe("The number of pictures shown to the user"),
}),
}
);

// add LLM, prompt, etc...

Expand All @@ -52,9 +56,18 @@ As of `langchain` version `0.2.8`, the `createToolCallingAgent` function now sup
:::

```tsx agent.tsx
async function agent(inputs: { input: string }) {
async function agent(inputs: {
input: string;
chat_history: [role: string, content: string][];
}) {
"use server";
return streamRunnableUI(agentExecutor, inputs);

return streamRunnableUI(agentExecutor, {
input: inputs.input,
chat_history: inputs.chat_history.map(
([role, content]) => new ChatMessage(content, role)
),
});
}

export const EndpointsContext = exposeEndpoints({ agent });
Expand Down
Loading