File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ OPENAI_API_KEY = xxx
Original file line number Diff line number Diff line change 1+ {
2+ "dependencies" : [" ." ],
3+ "workflows" : {
4+ "agentic_w" : " main.py:agent"
5+ },
6+ "env" : " .env"
7+ }
Original file line number Diff line number Diff line change 1+ from llama_index .core .workflow import (
2+ Event ,
3+ StartEvent ,
4+ StopEvent ,
5+ Workflow ,
6+ step ,
7+ )
8+ from llama_index .llms .openai import OpenAI
9+
10+
11+ class JokeEvent (Event ):
12+ joke : str
13+
14+
15+ class JokeFlow (Workflow ):
16+ llm = OpenAI ()
17+
18+ @step
19+ async def generate_joke (self , ev : StartEvent ) -> JokeEvent :
20+ topic = ev .topic
21+
22+ prompt = f"Write your best joke about { topic } ."
23+ response = await self .llm .acomplete (prompt )
24+ return JokeEvent (joke = str (response ))
25+
26+ @step
27+ async def critique_joke (self , ev : JokeEvent ) -> StopEvent :
28+ joke = ev .joke
29+
30+ prompt = f"Give a thorough analysis and critique of the following joke: { joke } "
31+ response = await self .llm .acomplete (prompt )
32+ return StopEvent (result = str (response ))
33+
34+
35+ agent = JokeFlow (timeout = 60 , verbose = False )
Original file line number Diff line number Diff line change 1+ [project ]
2+ name = " llama-demo"
3+ version = " 0.0.1"
4+ description = " UiPath LlamaIndex SDK"
5+ authors = [{ name = " John Doe" , email = " john.doe@myemail.com" }]
6+ readme = { file = " README.md" , content-type = " text/markdown" }
7+ requires-python = " >=3.10"
8+ dependencies = [
9+ " uipath-llamaindex>=0.0.4" ,
10+ " llama-index-llms-openai>=0.2.2"
11+ ]
You can’t perform that action at this time.
0 commit comments