Skip to content

Commit 5bfcd51

Browse files
feat: add llamaindex chat agent implementation
1 parent 60eadd5 commit 5bfcd51

14 files changed

Lines changed: 2656 additions & 1359 deletions

File tree

packages/uipath-llamaindex/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-llamaindex"
3-
version = "0.5.6"
3+
version = "0.5.7"
44
description = "Python SDK that enables developers to build and deploy LlamaIndex agents to the UiPath Cloud Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Literature Chat Agent
2+
3+
An AI assistant using Llamaindex and Tavily search for literature research and recommendations.
4+
5+
## Requirements
6+
7+
- Python 3.11+
8+
- OpenAI API key
9+
- Tavily API key
10+
11+
## Installation
12+
13+
```bash
14+
uv venv -p 3.11 .venv
15+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
16+
uv sync
17+
```
18+
19+
Set your API keys as environment variables in .env
20+
21+
```bash
22+
OPENAI_API_KEY=your_anthropic_api_key
23+
TAVILY_API_KEY=your_tavily_api_key
24+
```
25+
26+
## Usage
27+
28+
```bash
29+
uipath run agent 'uipath run agent '{"user_msg": "Tell me about 1984 by George Orwell"}''
30+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
flowchart TB
2+
__start__(__start__)
3+
aggregate_tool_results(aggregate_tool_results)
4+
call_tool(call_tool)
5+
init_run(init_run)
6+
parse_agent_output(parse_agent_output)
7+
run_agent_step(run_agent_step)
8+
setup_agent(setup_agent)
9+
__end__(__end__)
10+
aggregate_tool_results --> |AgentInput|setup_agent
11+
aggregate_tool_results --> |StopEvent|__end__
12+
call_tool --> |ToolCallResult|aggregate_tool_results
13+
__start__ --> |AgentWorkflowStartEvent|init_run
14+
init_run --> |AgentInput|setup_agent
15+
parse_agent_output --> |StopEvent|__end__
16+
parse_agent_output --> |AgentInput|setup_agent
17+
parse_agent_output --> |ToolCall|call_tool
18+
run_agent_step --> |AgentOutput|parse_agent_output
19+
setup_agent --> |AgentSetup|run_agent_step
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"workflows": {
3+
"agent": "main.py:agent"
4+
}
5+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
3+
from llama_index.core.agent.workflow import AgentWorkflow
4+
from llama_index.llms.openai import OpenAI
5+
from llama_index.tools.tavily_research import TavilyToolSpec
6+
7+
llm = OpenAI(model="gpt-4o-mini")
8+
tavily_tool = TavilyToolSpec(api_key=os.environ["TAVILY_API_KEY"])
9+
10+
SYSTEM_PROMPT = (
11+
"You are an advanced AI assistant specializing in book research and literature analysis. "
12+
"Your primary functions are:\n\n"
13+
"1. Book Information Research: Gather comprehensive information about books, including plot summaries, "
14+
"themes, publishing details, sales performance, critical reception, and awards.\n"
15+
"2. Author Research: Provide detailed information about authors, translators, editors, and other "
16+
"publishing industry professionals.\n"
17+
"3. Book Recommendations: Suggest books based on user preferences, genres, themes, or similar books "
18+
"they have enjoyed.\n"
19+
"4. Publishing Industry Analysis: Analyze trends, bestseller data, genre popularity, and insights "
20+
"from the literary world.\n"
21+
"5. Book Trivia and Facts: Share interesting facts, behind-the-scenes stories, and trivia about "
22+
"books, authors, and the publishing industry.\n\n"
23+
"Use the search tool for recent or factual information. "
24+
"Remember previous messages and maintain context across the discussion."
25+
)
26+
27+
agent = AgentWorkflow.from_tools_or_functions(
28+
tools_or_functions=tavily_tool.to_tool_list(), llm=llm, system_prompt=SYSTEM_PROMPT
29+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[project]
2+
name = "chat-agent-llama"
3+
version = "0.0.1"
4+
description = "chat-agent"
5+
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
6+
dependencies = [
7+
"uipath-llamaindex>=0.5.7, <0.6.0",
8+
"llama-index-llms-openai>=0.6.10",
9+
"llama-index-tools-tavily-research>=0.4.2",
10+
"llama-index-llms-openai>=0.6.18"
11+
]
12+
requires-python = ">=3.11"
13+
14+
15+
[dependency-groups]
16+
dev = [
17+
"uipath-dev>=0.0.19",
18+
]
19+
20+
[[tool.uv.index]]
21+
name = "testpypi"
22+
url = "https://test.pypi.org/simple/"
23+
publish-url = "https://test.pypi.org/legacy/"
24+
explicit = true
25+
26+
[tool.uv.sources]
27+
uipath-llamaindex = { index = "testpypi" }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://cloud.uipath.com/draft/2024-12/uipath",
3+
"runtimeOptions": {
4+
"isConversational": true
5+
},
6+
"packOptions": {
7+
"fileExtensionsIncluded": [],
8+
"filesIncluded": [],
9+
"filesExcluded": [],
10+
"directoriesExcluded": [],
11+
"includeUvLock": true
12+
},
13+
"functions": {}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from uipath_llamaindex.runtime.chat.messages import UiPathChatMessagesMapper
2+
3+
__all__ = ["UiPathChatMessagesMapper"]

0 commit comments

Comments
 (0)