Skip to content

Commit cddb4f6

Browse files
authored
chore: bump chat UI version to 0.1.2 and rename generate_ui_for_workflow (#560)
* chore: bump chat UI version to 0.1.2 and rename generate_ui_for_workflow * feat: add exports for event component generation in gen_ui module * update document * refine prompt
1 parent c82e4f5 commit cddb4f6

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

llama-index-server/docs/custom_ui_component.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,21 @@ server = LlamaIndexServer(
7676

7777
### Generate UI Component
7878

79-
We provide a `generate_ui_component` function that uses LLMs to automatically generate UI components for your workflow events.
80-
81-
> **_Note:_** This feature requires the `ANTHROPIC_API_KEY` to be set in your environment.
79+
We provide a `generate_event_component` function that uses LLMs to automatically generate UI components for your workflow events.
8280

8381
```python
84-
from llama_index.server.gen_ui.main import generate_ui_component
82+
from llama_index.server.gen_ui import generate_event_component
83+
from llama_index.llms.openai import OpenAI
8584

8685
# Generate a component using the event class you defined in your workflow
8786
from your_workflow import DeepResearchEvent
88-
ui_code = await generate_ui_component(
87+
ui_code = await generate_event_component(
8988
event_cls=DeepResearchEvent,
89+
llm=OpenAI(model="gpt-4.1"), # Default LLM is Claude 3.7 Sonnet if not provided
9090
)
9191

9292
# Alternatively, generate from your workflow file
93-
ui_code = await generate_ui_component(
93+
ui_code = await generate_event_component(
9494
workflow_file="your_workflow.py",
9595
)
9696
print(ui_code)
@@ -100,4 +100,4 @@ with open("deep_research_event.jsx", "w") as f:
100100
f.write(ui_code)
101101
```
102102

103-
> **Tip:** For optimal results, add descriptive documentation to each field in your event data class. This helps the LLM better understand your data structure and generate more appropriate UI components.
103+
> **Tip:** For optimal results, add descriptive documentation to each field in your event data class. This helps the LLM better understand your data structure and generate more appropriate UI components. We also recommend using GPT 4.1, Claude 3.7 Sonnet and Gemini 2.5 Pro for better results.

llama-index-server/llama_index/server/chat_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import requests
77

8-
CHAT_UI_VERSION = "0.1.1"
8+
CHAT_UI_VERSION = "0.1.2"
99

1010

1111
def download_chat_ui(
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .main import generate_event_component
2+
from .parse_workflow_code import get_workflow_event_schemas
3+
4+
__all__ = ["generate_event_component", "get_workflow_event_schemas"]

llama-index-server/llama_index/server/gen_ui/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ class GenUIWorkflow(Workflow):
8080

8181
code_structure: str = """
8282
```jsx
83-
// Note: Only shadcn/ui and lucide-react and tailwind css are allowed (but cn() is not supported yet).
83+
// Note: Only shadcn/ui and lucide-react and tailwind css are allowed.
8484
// shadcn import pattern: import { ComponentName } from "@/components/ui/<component_path>";
8585
// e.g: import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
8686
// import { Button } from "@/components/ui/button";
87+
// import cn from "@/lib/utils"; // clsx is not supported
8788
8889
// export the component
8990
export default function Component({ events }) {
@@ -264,7 +265,7 @@ async def write_ui_component(
264265
You should display the jump, run and meow actions in different ways. don't try to render "height" for the "run" and "meow" action.
265266
266267
## UI notice
267-
- Use shadcn/ui and lucide-react and tailwind CSS for the UI (cn() is not supported yet).
268+
- Use shadcn/ui and lucide-react and tailwind CSS for the UI.
268269
- Be careful on state handling, make sure the update should be updated in the state and there is no duplicate state.
269270
- For a long content, consider to use markdown along with dropdown to show the full content.
270271
e.g:
@@ -350,7 +351,7 @@ async def refine_code(
350351
)
351352

352353

353-
async def generate_ui_for_workflow(
354+
async def generate_event_component(
354355
workflow_file: Optional[str] = None,
355356
event_cls: Optional[Type[BaseModel]] = None,
356357
llm: Optional[LLM] = None,
@@ -360,7 +361,7 @@ async def generate_ui_for_workflow(
360361
Either workflow_file or event_cls must be provided.
361362
362363
Args:
363-
workflow_file: The path to the workflow file to generate UI from. e.g: `app/workflow.py`.
364+
workflow_file: The path to the workflow file that contains the event to generate UI for. e.g: `app/workflow.py`.
364365
event_cls: A Pydantic class to generate UI for. e.g: `DeepResearchEvent`.
365366
llm: The LLM to use for the generation. Default is Anthropic's Claude 3.7 Sonnet.
366367
We recommend using these LLMs:

0 commit comments

Comments
 (0)