Skip to content

Commit 93092c3

Browse files
committed
fix import paths
1 parent 813ffd9 commit 93092c3

File tree

10 files changed

+80
-74
lines changed

10 files changed

+80
-74
lines changed

docs/docs/workflows/v2.x/deployment.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/docs/workflows/v2.x/customizing_entry_exit_points.md renamed to docs/docs/workflows/v2/customizing_entry_exit_points.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To be able to use a custom start event, the first step is creating a custom clas
1414
```python
1515
from pathlib import Path
1616

17-
from llama_index.core.workflow import StartEvent
17+
from workflows.events import StartEvent
1818
from llama_index.indices.managed.llama_cloud import LlamaCloudIndex
1919
from llama_index.llms.openai import OpenAI
2020

@@ -75,7 +75,7 @@ dictionary that we then assign to `StopEvent.result`.
7575
First step to support custom stop events, we need to create a subclass of `StopEvent`:
7676

7777
```python
78-
from llama_index.core.workflow import StopEvent
78+
from workflows.events import StopEvent
7979

8080

8181
class MyStopEvent(StopEvent):

docs/docs/workflows/v2/deployment.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Deploying a Workflow
2+
3+
You can deploy a workflow as a multi-agent service with [llama_deploy](../../module_guides/llama_deploy) ([repo](https://github.com/run-llama/llama_deploy)). Each agent service is orchestrated via a control plane and communicates via a message queue. Deploy locally or on Kubernetes.

docs/docs/workflows/v2.x/drawing.md renamed to docs/docs/workflows/v2/drawing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ draw_most_recent_execution(w, filename="joke_flow_recent.html")
3131
Optionally, you can choose to use global context between steps. For example, maybe multiple steps access the original `query` input from the user. You can store this in global context so that every step has access.
3232

3333
```python
34-
from llama_index.core.workflow import Context
34+
from workflows import Context
3535

3636

3737
@step

docs/docs/workflows/v2.x/getting_started.md renamed to docs/docs/workflows/v2/index.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
As an illustrative example, let's consider a naive workflow where a joke is generated and then critiqued.
2323

2424
```python
25-
from llama_index.core.workflow import (
25+
from workflows import Workflow, step
26+
from workflows.events import (
2627
Event,
2728
StartEvent,
2829
StopEvent,
29-
Workflow,
30-
step,
3130
)
3231

3332
# `pip install llama-index-llms-openai` if you don't already have it
@@ -158,12 +157,11 @@ You can also decorate and attach steps to a workflow without subclassing it.
158157
Below is the `JokeFlow` from earlier, but defined without subclassing.
159158

160159
```python
161-
from llama_index.core.workflow import (
160+
from workflows import Workflow, step
161+
from workflows.events import (
162162
Event,
163163
StartEvent,
164164
StopEvent,
165-
Workflow,
166-
step,
167165
)
168166
from llama_index.llms.openai import OpenAI
169167

@@ -196,3 +194,51 @@ async def critique_joke(ev: JokeEvent) -> StopEvent:
196194
response = await llm.acomplete(prompt)
197195
return StopEvent(result=str(response))
198196
```
197+
198+
## Examples
199+
200+
To help you become more familiar with the workflow concept and its features, LlamaIndex documentation offers example
201+
notebooks that you can run for hands-on learning:
202+
203+
- [Common Workflow Patterns](../../examples/workflow/workflows_cookbook.ipynb) walks you through common usage patterns
204+
like looping and state management using simple workflows. It's usually a great place to start.
205+
- [RAG + Reranking](../../examples/workflow/rag.ipynb) shows how to implement a real-world use case with a fairly
206+
simple workflow that performs both ingestion and querying.
207+
- [Citation Query Engine](../../examples/workflow/citation_query_engine.ipynb) similar to RAG + Reranking, the
208+
notebook focuses on how to implement intermediate steps in between retrieval and generation. A good example of how to
209+
use the [`Context`](#working-with-global-context-state) object in a workflow.
210+
- [Corrective RAG](../../examples/workflow/corrective_rag_pack.ipynb) adds some more complexity on top of a RAG
211+
workflow, showcasing how to query a web search engine after an evaluation step.
212+
- [Utilizing Concurrency](../../examples/workflow/parallel_execution.ipynb) explains how to manage the parallel
213+
execution of steps in a workflow, something that's important to know as your workflows grow in complexity.
214+
215+
RAG applications are easy to understand and offer a great opportunity to learn the basics of workflows. However, more complex agentic scenarios involving tool calling, memory, and routing are where workflows excel.
216+
217+
The examples below highlight some of these use-cases.
218+
219+
- [ReAct Agent](../../examples/workflow/react_agent.ipynb) is obviously the perfect example to show how to implement
220+
tools in a workflow.
221+
- [Function Calling Agent](../../examples/workflow/function_calling_agent.ipynb) is a great example of how to use the
222+
LlamaIndex framework primitives in a workflow, keeping it small and tidy even in complex scenarios like function
223+
calling.
224+
- [CodeAct Agent](../../examples/agent/from_scratch_code_act_agent.ipynb) is a great example of how to create a CodeAct Agent from scratch.
225+
- [Human In The Loop: Story Crafting](../../examples/workflow/human_in_the_loop_story_crafting.ipynb) is a powerful
226+
example showing how workflow runs can be interactive and stateful. In this case, to collect input from a human.
227+
- [Reliable Structured Generation](../../examples/workflow/reflection.ipynb) shows how to implement loops in a
228+
workflow, in this case to improve structured output through reflection.
229+
- [Query Planning with Workflows](../../examples/workflow/planning_workflow.ipynb) is an example of a workflow
230+
that plans a query by breaking it down into smaller items, and executing those smaller items. It highlights how
231+
to stream events from a workflow, execute steps in parallel, and looping until a condition is met.
232+
- [Checkpointing Workflows](../../examples/workflow/checkpointing_workflows.ipynb) is a more exhaustive demonstration of how to make full use of `WorkflowCheckpointer` to checkpoint Workflow runs.
233+
234+
Last but not least, a few more advanced use cases that demonstrate how workflows can be extremely handy if you need
235+
to quickly implement prototypes, for example from literature:
236+
237+
- [Advanced Text-to-SQL](../../examples/workflow/advanced_text_to_sql.ipynb)
238+
- [JSON Query Engine](../../examples/workflow/JSONalyze_query_engine.ipynb)
239+
- [Long RAG](../../examples/workflow/long_rag_pack.ipynb)
240+
- [Multi-Step Query Engine](../../examples/workflow/multi_step_query_engine.ipynb)
241+
- [Multi-Strategy Workflow](../../examples/workflow/multi_strategy_workflow.ipynb)
242+
- [Router Query Engine](../../examples/workflow/router_query_engine.ipynb)
243+
- [Self Discover Workflow](../../examples/workflow/self_discover_workflow.ipynb)
244+
- [Sub-Question Query Engine](../../examples/workflow/sub_question_query_engine.ipynb)

docs/docs/workflows/v2.x/managing_events.md renamed to docs/docs/workflows/v2/managing_events.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ Normally, events are triggered by returning another event during a step. However
4040
Here is a short toy example showing how this would be used:
4141

4242
```python
43-
from llama_index.core.workflow import step, Context, Event, Workflow
43+
from workflows import Workflow, step
44+
from workflows.events import (
45+
Event,
46+
StartEvent,
47+
StopEvent,
48+
)
4449

4550

4651
class MyEvent(Event):
@@ -117,7 +122,7 @@ Since workflows are so flexible, there are many possible ways to implement human
117122
The easiest way to implement a human-in-the-loop is to use the `InputRequiredEvent` and `HumanResponseEvent` events during event streaming.
118123

119124
```python
120-
from llama_index.core.workflow import InputRequiredEvent, HumanResponseEvent
125+
from workflows.events import InputRequiredEvent, HumanResponseEvent
121126

122127

123128
class HumanInTheLoopWorkflow(Workflow):

docs/docs/workflows/v2.x/managing_state.md renamed to docs/docs/workflows/v2/managing_state.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ class MyState(BaseModel):
5252
Then, simply annotate your workflow state with the state model:
5353

5454
```python
55-
from llama_index.core.workflow import (
56-
Context,
55+
from workflows import Workflow, step
56+
from workflows.events import (
57+
Event,
5758
StartEvent,
5859
StopEvent,
59-
Workflow,
60-
step,
6160
)
6261

6362

docs/docs/workflows/v2.x/resources.md renamed to docs/docs/workflows/v2/resources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Resources are external dependencies you can inject into the steps of a workflow.
55
As a simple example, look at `memory` in the following workflow:
66

77
```python
8-
from llama_index.core.workflow.resource import Resource
8+
from workflows.resource import Resource
99
from llama_index.core.memory import Memory
1010

1111

docs/docs/workflows/v2.x/retry_steps.md renamed to docs/docs/workflows/v2/retry_steps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To set a policy for a specific step, all you have to do is passing a policy obje
1313

1414

1515
```python
16-
from llama_index.core.workflow.retry_policy import ConstantDelayRetryPolicy
16+
from workflows.retry_policy import ConstantDelayRetryPolicy
1717

1818

1919
class MyWorkflow(Workflow):

docs/mkdocs.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ nav:
1717
- API Reference:
1818
- Workflows:
1919
- api_reference/workflow
20-
- Component Guides:
21-
- Workflows:
22-
- module_guides/workflow
23-
- Understanding:
24-
- Workflows:
25-
- understanding/workflows
20+
- Workflows:
21+
- v2:
22+
- ./workflows/v2/index.md
23+
- ./workflows/v2/customizing_entry_exit_points.md
24+
- ./workflows/v2/drawing.md
25+
- ./workflows/v2/managing_events.md
26+
- ./workflows/v2/managing_state.md
27+
- ./workflows/v2/retry_steps.md
28+
- ./workflows/v2/resources.md
29+
- ./workflows/v2/deployment.md
2630
plugins:
2731
- search
2832
- include_dir_to_nav

0 commit comments

Comments
 (0)