Skip to content

Commit 3761b09

Browse files
Add LlamaIndex Python Integration (#82)
* wip * nit * add gitignore * wip * wip * remove non-working examples * improve agentic generative UI example * update to latest * move and rename * create llamaindex agent * add LlamaIndexAgent package * fix paths
1 parent 919db2c commit 3761b09

File tree

20 files changed

+2631
-0
lines changed

20 files changed

+2631
-0
lines changed

typescript-sdk/apps/dojo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@ag-ui/agno": "workspace:*",
1313
"@ag-ui/langgraph": "workspace:*",
14+
"@ag-ui/llamaindex": "workspace:*",
1415
"@ag-ui/mastra": "workspace:*",
1516
"@ag-ui/middleware-starter": "workspace:*",
1617
"@ag-ui/server-starter": "workspace:*",

typescript-sdk/apps/dojo/src/agents.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { VercelAISDKAgent } from "@ag-ui/vercel-ai-sdk";
88
import { openai } from "@ai-sdk/openai";
99
import { LangGraphAgent } from "@ag-ui/langgraph";
1010
import { AgnoAgent } from "@ag-ui/agno";
11+
import { LlamaIndexAgent } from "@ag-ui/llamaindex";
1112

1213
export const agentsIntegrations: AgentIntegrationConfig[] = [
1314
{
@@ -112,4 +113,23 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
112113
};
113114
},
114115
},
116+
{
117+
id: "llama-index",
118+
agents: async () => {
119+
return {
120+
agentic_chat: new LlamaIndexAgent({
121+
url: "http://localhost:9000/agentic_chat/run",
122+
}),
123+
human_in_the_loop: new LlamaIndexAgent({
124+
url: "http://localhost:9000/human_in_the_loop/run",
125+
}),
126+
agentic_generative_ui: new LlamaIndexAgent({
127+
url: "http://localhost:9000/agentic_generative_ui/run",
128+
}),
129+
shared_state: new LlamaIndexAgent({
130+
url: "http://localhost:9000/shared_state/run",
131+
}),
132+
};
133+
},
134+
}
115135
];

typescript-sdk/apps/dojo/src/menu.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,14 @@ export const menuIntegrations: MenuIntegrationConfig[] = [
5050
name: "Agno",
5151
features: ["agentic_chat"],
5252
},
53+
{
54+
id: "llama-index",
55+
name: "LlamaIndex",
56+
features: [
57+
"agentic_chat",
58+
"human_in_the_loop",
59+
"agentic_generative_ui",
60+
"shared_state",
61+
],
62+
},
5363
];
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__pycache__
2+
*egg-info
3+
.venv
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.turbo
2+
.DS_Store
3+
.git
4+
.gitignore
5+
.idea
6+
.vscode
7+
.env
8+
__tests__
9+
src
10+
tsup.config.ts
11+
tsconfig.json
12+
jest.config.js
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
testMatch: ["**/*.test.ts"],
6+
moduleNameMapper: {
7+
"^@/(.*)$": "<rootDir>/src/$1",
8+
},
9+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "@ag-ui/llamaindex",
3+
"author": "Logan Markewich <[email protected]>",
4+
"version": "0.1.0",
5+
"main": "./dist/index.js",
6+
"module": "./dist/index.mjs",
7+
"types": "./dist/index.d.ts",
8+
"sideEffects": false,
9+
"files": [
10+
"dist/**"
11+
],
12+
"scripts": {
13+
"build": "tsup",
14+
"dev": "tsup --watch",
15+
"clean": "rm -rf dist",
16+
"typecheck": "tsc --noEmit",
17+
"test": "jest",
18+
"link:global": "pnpm link --global",
19+
"unlink:global": "pnpm unlink --global"
20+
},
21+
"dependencies": {
22+
"@ag-ui/client": "workspace:*"
23+
},
24+
"peerDependencies": {
25+
"rxjs": "7.8.1"
26+
},
27+
"devDependencies": {
28+
"@types/jest": "^29.5.14",
29+
"@types/node": "^20.11.19",
30+
"jest": "^29.7.0",
31+
"ts-jest": "^29.1.2",
32+
"tsup": "^8.0.2",
33+
"typescript": "^5.3.3"
34+
}
35+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# LlamaIndex Python AG-UI Integration
2+
3+
This package provides a FastAPI server that is bootstrapped with several AG-UI+LlamaIndex endpoints. It can be used to communicate with AG-UI compatible frameworks like [CopilotKit](https://docs.copilotkit.ai/).
4+
5+
## Usage
6+
7+
Launch the server with:
8+
9+
```python
10+
uv sync
11+
uv run dev
12+
```
13+
14+
Launch the frontend dojo with:
15+
16+
```bash
17+
cd ../../
18+
pnpm install
19+
turbo run dev
20+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "server"
7+
version = "0.1.0"
8+
description = "Add your description here"
9+
readme = "README.md"
10+
requires-python = ">=3.9, <3.14"
11+
dependencies = [
12+
"llama-index-core>=0.12.41,<0.13",
13+
"llama-index-agent-openai>=0.4.9,<0.5",
14+
"llama-index-protocols-ag-ui>=0.1.2",
15+
"jsonpatch>=1.33",
16+
"uvicorn>=0.27.0",
17+
"fastapi>=0.100.0",
18+
]
19+
authors = [
20+
{ name = "Logan Markewich", email = "[email protected]" },
21+
]
22+
23+
[tool.hatch.build.targets.sdist]
24+
include = ["server/"]
25+
26+
[tool.hatch.build.targets.wheel]
27+
include = ["server/"]
28+
29+
[project.scripts]
30+
dev = "server:main"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import uvicorn
2+
from fastapi import FastAPI
3+
4+
from .routers.agentic_chat import agentic_chat_router
5+
from .routers.human_in_the_loop import human_in_the_loop_router
6+
from .routers.agentic_generative_ui import agentic_generative_ui_router
7+
from .routers.shared_state import shared_state_router
8+
9+
app = FastAPI(title="AG-UI Llama-Index Endpoint")
10+
11+
app.include_router(agentic_chat_router, prefix="/agentic_chat")
12+
app.include_router(human_in_the_loop_router, prefix="/human_in_the_loop")
13+
app.include_router(agentic_generative_ui_router, prefix="/agentic_generative_ui")
14+
app.include_router(shared_state_router, prefix="/shared_state")
15+
16+
def main():
17+
"""Main function to start the FastAPI server."""
18+
uvicorn.run(app, host="0.0.0.0", port=9000)
19+
20+
if __name__ == "__main__":
21+
main()
22+
23+
__all__ = ["main"]

0 commit comments

Comments
 (0)