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
Copy file name to clipboardExpand all lines: llama-index-server/docs/custom_ui_component.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,21 +76,21 @@ server = LlamaIndexServer(
76
76
77
77
### Generate UI Component
78
78
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.
82
80
83
81
```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
85
84
86
85
# Generate a component using the event class you defined in your workflow
87
86
from your_workflow import DeepResearchEvent
88
-
ui_code =awaitgenerate_ui_component(
87
+
ui_code =awaitgenerate_event_component(
89
88
event_cls=DeepResearchEvent,
89
+
llm=OpenAI(model="gpt-4.1"), # Default LLM is Claude 3.7 Sonnet if not provided
90
90
)
91
91
92
92
# Alternatively, generate from your workflow file
93
-
ui_code =awaitgenerate_ui_component(
93
+
ui_code =awaitgenerate_event_component(
94
94
workflow_file="your_workflow.py",
95
95
)
96
96
print(ui_code)
@@ -100,4 +100,4 @@ with open("deep_research_event.jsx", "w") as f:
100
100
f.write(ui_code)
101
101
```
102
102
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.
0 commit comments