Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
e5b5e9f
chore: replace Python examples with llama-deploy
thucpn Jul 3, 2025
d96d830
use fixed version for ts-server package
thucpn Jul 3, 2025
b6fc63b
update readme
thucpn Jul 3, 2025
fad3414
update pyproject.toml
thucpn Jul 3, 2025
2a00cad
fix load env
thucpn Jul 3, 2025
b701ca3
update readme for .env
thucpn Jul 3, 2025
b991ca8
use absolute logo
thucpn Jul 3, 2025
1f25c9d
update comment
thucpn Jul 3, 2025
a20dd66
document generator
thucpn Jul 3, 2025
d01876a
fix doc
thucpn Jul 3, 2025
e25b63a
fix format
thucpn Jul 3, 2025
2846364
fix doc
thucpn Jul 3, 2025
d5edd2c
fix imports
thucpn Jul 3, 2025
e2812ed
update ui config
thucpn Jul 3, 2025
6451777
keep create workflow contract
thucpn Jul 3, 2025
b0e4c60
agentic rag
thucpn Jul 3, 2025
bb6bebc
fix generate
thucpn Jul 3, 2025
f5bc6c4
prerequisites
thucpn Jul 3, 2025
07cea8c
fix pyproject.toml
thucpn Jul 3, 2025
4beefa8
fix typo
thucpn Jul 3, 2025
c61dfe6
fix: define wheel
thucpn Jul 3, 2025
2b202a5
fix generate
thucpn Jul 3, 2025
7a165c4
fix rag worklow
thucpn Jul 3, 2025
11052af
feat: HITL use case
thucpn Jul 4, 2025
a434e34
update doc
thucpn Jul 4, 2025
72ea59b
update doc
thucpn Jul 4, 2025
d881f5a
add todo
thucpn Jul 4, 2025
97dcd8c
arrage imports
thucpn Jul 4, 2025
00675f7
feat: deep research
thucpn Jul 4, 2025
a7c8a06
fix: deep research
thucpn Jul 4, 2025
07bdf6c
update deep research
thucpn Jul 4, 2025
eb8b01c
fix ecoding when genearing index
thucpn Jul 4, 2025
436f9f6
package src
thucpn Jul 4, 2025
c4b2e48
fix: deep research prepare messages
thucpn Jul 7, 2025
a3e3a7a
support financial report
thucpn Jul 7, 2025
643ad98
fix: implement save file
thucpn Jul 7, 2025
02e36df
missing e2b for finance
thucpn Jul 7, 2025
0b5a7d9
missing deps
thucpn Jul 7, 2025
5791412
file_server_url_prefix
thucpn Jul 7, 2025
f314528
add file server url when init chat workflow
thucpn Jul 7, 2025
586998c
update llamacloud gen
thucpn Jul 7, 2025
e969631
copy llamacloud vectordbs
thucpn Jul 7, 2025
3083fd6
fix download
thucpn Jul 7, 2025
edf1a37
fix download
thucpn Jul 7, 2025
59ddab2
remove Python HITL
thucpn Jul 8, 2025
eea1aed
write response to stream
thucpn Jul 8, 2025
63d94e0
fix messages
thucpn Jul 8, 2025
6662e6e
fix document gen
thucpn Jul 8, 2025
fe6f62f
data inside ui dir for python llamadeloy
thucpn Jul 8, 2025
46186a9
construct file server url
thucpn Jul 8, 2025
ed027be
fix basePath
thucpn Jul 8, 2025
5045e77
fix data path
thucpn Jul 8, 2025
4187651
use current host if not set
thucpn Jul 8, 2025
c3a56ae
fix data path for llamacloud
thucpn Jul 8, 2025
637a616
fix fin use case
thucpn Jul 9, 2025
13ce350
update comment
thucpn Jul 9, 2025
b85b4b7
remove generate and index if not needed
thucpn Jul 9, 2025
4872403
support custom starter questions
thucpn Jul 9, 2025
80c6b64
fix: generate report inside temp dir
thucpn Jul 9, 2025
2099bf0
bump chat-ui
thucpn Jul 9, 2025
e4ce715
missing __init
thucpn Jul 9, 2025
07e19de
simplify test
thucpn Jul 9, 2025
1c8eb67
fix run app
thucpn Jul 9, 2025
3e66f6d
fix uv mypy
thucpn Jul 9, 2025
deac8e3
frontend url and submit chat api for testing
thucpn Jul 9, 2025
b7ffea8
custom port
thucpn Jul 9, 2025
dabd040
specify port for running llama-deploy
thucpn Jul 10, 2025
05c5354
cleanup
thucpn Jul 10, 2025
b602e7d
revert server
thucpn Jul 10, 2025
92fb8c7
skip test
thucpn Jul 10, 2025
cdd7265
Merge branch 'main' into tp/replace-python-examples-with-llamadeploy
thucpn Jul 10, 2025
a30a7fb
typo
thucpn Jul 10, 2025
b0e8342
Merge branch 'tp/replace-python-examples-with-llamadeploy' of github.…
thucpn Jul 10, 2025
5639ed8
clean up
thucpn Jul 10, 2025
0e48683
use case configs
thucpn Jul 10, 2025
e1b32f3
Merge branch 'main' into tp/replace-python-examples-with-llamadeploy
thucpn Jul 10, 2025
8250c40
refactor usecase
thucpn Jul 10, 2025
51077db
remove default proxy port
thucpn Jul 10, 2025
6b989e9
skip llamacloud for codegen docgen
thucpn Jul 10, 2025
aeaf7e1
Create good-avocados-try.md
thucpn Jul 10, 2025
1bb685c
revert e2e
thucpn Jul 10, 2025
7e72b2c
bump server package in create-llama
thucpn Jul 10, 2025
62d82ed
fix run
thucpn Jul 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/good-avocados-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-llama": patch
---

chore: replace Python examples with llama-deploy
9 changes: 0 additions & 9 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ jobs:
run: pnpm run pack-install
working-directory: packages/create-llama

- name: Build and store server package
run: |
pnpm run build
wheel_file=$(ls dist/*.whl | head -n 1)
mkdir -p "${{ runner.temp }}"
cp "$wheel_file" "${{ runner.temp }}/"
echo "SERVER_PACKAGE_PATH=${{ runner.temp }}/$(basename "$wheel_file")" >> $GITHUB_ENV
working-directory: python/llama-index-server

- name: Run Playwright tests for Python
run: pnpm run e2e:python
env:
Expand Down
13 changes: 7 additions & 6 deletions packages/create-llama/e2e/python/resolve_dependencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import { exec } from "child_process";
import fs from "fs";
import path from "path";
import util from "util";
import {
ALL_USE_CASES,
TemplateFramework,
TemplateVectorDB,
} from "../../helpers/types";
import { TemplateFramework, TemplateUseCase, TemplateVectorDB } from "../../helpers";
import { ALL_PYTHON_USE_CASES } from "../../helpers/use-case";
import { RunCreateLlamaOptions, createTestDir, runCreateLlama } from "../utils";

const execAsync = util.promisify(exec);
Expand All @@ -17,11 +14,15 @@ const vectorDb: TemplateVectorDB = process.env.VECTORDB
? (process.env.VECTORDB as TemplateVectorDB)
: "none";

const useCases: TemplateUseCase[] = vectorDb === "llamacloud" ? [
"agentic_rag", "deep_research", "financial_report"
] : ALL_PYTHON_USE_CASES

test.describe("Mypy check", () => {
test.describe.configure({ retries: 0 });

test.describe("LlamaIndexServer", async () => {
for (const useCase of ALL_USE_CASES) {
for (const useCase of useCases) {
test(`should pass mypy for use case: ${useCase}`, async () => {
const cwd = await createTestDir();
await createAndCheckLlamaProject({
Expand Down
28 changes: 20 additions & 8 deletions packages/create-llama/e2e/shared/llamaindexserver_template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { expect, test } from "@playwright/test";
import { ChildProcess } from "child_process";
import fs from "fs";
import path from "path";
import { type TemplateFramework, type TemplateVectorDB } from "../../helpers";
import {
ALL_USE_CASES,
type TemplateFramework,
type TemplateVectorDB,
} from "../../helpers";
ALL_PYTHON_USE_CASES,
ALL_TYPESCRIPT_USE_CASES,
} from "../../helpers/use-case";
import { createTestDir, runCreateLlama } from "../utils";

const templateFramework: TemplateFramework = process.env.FRAMEWORK
Expand All @@ -17,10 +17,15 @@ const vectorDb: TemplateVectorDB = process.env.VECTORDB
: "none";
const llamaCloudProjectName = "create-llama";
const llamaCloudIndexName = "e2e-test";
const allUseCases =
templateFramework === "nextjs"
? ALL_TYPESCRIPT_USE_CASES
: ALL_PYTHON_USE_CASES;
const isPythonLlamaDeploy = templateFramework === "fastapi";

const userMessage = "Write a blog post about physical standards for letters";

for (const useCase of ALL_USE_CASES) {
for (const useCase of allUseCases) {
test.describe(`Test use case ${useCase} ${templateFramework} ${vectorDb}`, async () => {
let port: number;
let cwd: string;
Expand All @@ -35,7 +40,7 @@ for (const useCase of ALL_USE_CASES) {
templateFramework,
vectorDb,
port,
postInstallAction: "runApp",
postInstallAction: isPythonLlamaDeploy ? "dependencies" : "runApp",
useCase,
llamaCloudProjectName,
llamaCloudIndexName,
Expand All @@ -50,6 +55,11 @@ for (const useCase of ALL_USE_CASES) {
});

test("Frontend should have a title", async ({ page }) => {
test.skip(
isPythonLlamaDeploy,
"Skip frontend tests for Python LllamaDeploy",
);

await page.goto(`http://localhost:${port}`);
await expect(page.getByText("Built by LlamaIndex")).toBeVisible({
timeout: 5 * 60 * 1000,
Expand All @@ -60,8 +70,10 @@ for (const useCase of ALL_USE_CASES) {
page,
}) => {
test.skip(
useCase === "financial_report" || useCase === "deep_research",
"Skip chat tests for financial report and deep research.",
useCase === "financial_report" ||
useCase === "deep_research" ||
isPythonLlamaDeploy,
"Skip chat tests for financial report and deep research. Also skip for Python LlamaDeploy",
);
await page.goto(`http://localhost:${port}`);
await page.fill("form textarea", userMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import fs from "fs";
import path from "path";
import util from "util";
import {
ALL_USE_CASES,
TemplateFramework,
TemplateUseCase,
TemplateVectorDB,
} from "../../helpers/types";
import { ALL_TYPESCRIPT_USE_CASES } from "../../helpers/use-case";
import { createTestDir, runCreateLlama } from "../utils";

const execAsync = util.promisify(exec);
Expand All @@ -21,7 +21,7 @@ const vectorDb: TemplateVectorDB = process.env.VECTORDB
test.describe("Test resolve TS dependencies", () => {
test.describe.configure({ retries: 0 });

for (const useCase of ALL_USE_CASES) {
for (const useCase of ALL_TYPESCRIPT_USE_CASES) {
const optionDescription = `useCase: ${useCase}, vectorDb: ${vectorDb}`;
test.describe(`${optionDescription}`, () => {
test(`${optionDescription}`, async () => {
Expand Down
88 changes: 65 additions & 23 deletions packages/create-llama/helpers/env-variables.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import fs from "fs/promises";
import path from "path";
import {
EnvVar,
InstallTemplateArgs,
ModelConfig,
TemplateFramework,
TemplateType,
TemplateUseCase,
TemplateVectorDB,
} from "./types";

import { TSYSTEMS_LLMHUB_API_URL } from "./providers/llmhub";

export type EnvVar = {
name?: string;
description?: string;
value?: string;
};
import { USE_CASE_CONFIGS } from "./use-case";

const renderEnvVar = (envVars: EnvVar[]): string => {
return envVars.reduce(
Expand Down Expand Up @@ -228,7 +225,15 @@ Otherwise, use CHROMA_HOST and CHROMA_PORT config above`,
}
};

const getModelEnvs = (modelConfig: ModelConfig): EnvVar[] => {
const getModelEnvs = (
modelConfig: ModelConfig,
framework: TemplateFramework,
template: TemplateType,
useCase: TemplateUseCase,
): EnvVar[] => {
const isPythonLlamaDeploy =
framework === "fastapi" && template === "llamaindexserver";

return [
{
name: "MODEL",
Expand All @@ -240,25 +245,44 @@ const getModelEnvs = (modelConfig: ModelConfig): EnvVar[] => {
description: "Name of the embedding model to use.",
value: modelConfig.embeddingModel,
},
{
name: "CONVERSATION_STARTERS",
description: "The questions to help users get started (multi-line).",
},
...(modelConfig.provider === "openai"
...(isPythonLlamaDeploy
? [
{
name: "OPENAI_API_KEY",
description: "The OpenAI API key to use.",
value: modelConfig.apiKey,
name: "NEXT_PUBLIC_STARTER_QUESTIONS",
description:
"Initial questions to display in the chat (`starterQuestions`)",
value: JSON.stringify(
USE_CASE_CONFIGS[useCase]?.starterQuestions ?? [],
),
},
]
: [
{
name: "LLM_TEMPERATURE",
description: "Temperature for sampling from the model.",
name: "CONVERSATION_STARTERS",
description:
"The questions to help users get started (multi-line).",
},
]),
...(USE_CASE_CONFIGS[useCase]?.additionalEnvVars ?? []),
...(modelConfig.provider === "openai"
? [
{
name: "LLM_MAX_TOKENS",
description: "Maximum number of tokens to generate.",
name: "OPENAI_API_KEY",
description: "The OpenAI API key to use.",
value: modelConfig.apiKey,
},
...(isPythonLlamaDeploy
? []
: [
{
name: "LLM_TEMPERATURE",
description: "Temperature for sampling from the model.",
},
{
name: "LLM_MAX_TOKENS",
description: "Maximum number of tokens to generate.",
},
]),
]
: []),
...(modelConfig.provider === "anthropic"
Expand Down Expand Up @@ -367,11 +391,12 @@ const getModelEnvs = (modelConfig: ModelConfig): EnvVar[] => {

const getFrameworkEnvs = (
framework: TemplateFramework,
template?: TemplateType,
port?: number,
): EnvVar[] => {
const sPort = port?.toString() || "8000";
const result: EnvVar[] = [];
if (framework === "fastapi") {
if (framework === "fastapi" && template !== "llamaindexserver") {
result.push(
...[
{
Expand Down Expand Up @@ -403,6 +428,7 @@ export const createBackendEnvFile = async (
| "template"
| "port"
| "useLlamaParse"
| "useCase"
>,
) => {
// Init env values
Expand All @@ -418,11 +444,27 @@ export const createBackendEnvFile = async (
]
: []),
...getVectorDBEnvs(opts.vectorDb, opts.framework, opts.template),
...getFrameworkEnvs(opts.framework, opts.port),
...getModelEnvs(opts.modelConfig),
...getFrameworkEnvs(opts.framework, opts.template, opts.port),
...getModelEnvs(
opts.modelConfig,
opts.framework,
opts.template,
opts.useCase,
),
];
// Render and write env file
const content = renderEnvVar(envVars);
await fs.writeFile(path.join(root, envFileName), content);

const isPythonLlamaDeploy =
opts.framework === "fastapi" && opts.template === "llamaindexserver";

// each llama-deploy service will need a .env inside its directory
// this .env will be copied along with workflow code when service is deployed
// so that we need to put the .env file inside src/ instead of root
const envPath = isPythonLlamaDeploy
? path.join(root, "src", envFileName)
: path.join(root, envFileName);

await fs.writeFile(envPath, content);
console.log(`Created '${envFileName}' file. Please check the settings.`);
};
30 changes: 18 additions & 12 deletions packages/create-llama/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,13 @@ const downloadFile = async (url: string, destPath: string) => {
const prepareContextData = async (
root: string,
dataSources: TemplateDataSource[],
isPythonLlamaDeploy: boolean,
) => {
await makeDir(path.join(root, "data"));
const dataDir = isPythonLlamaDeploy
? path.join(root, "ui", "data")
: path.join(root, "data");

await makeDir(dataDir);
for (const dataSource of dataSources) {
const dataSourceConfig = dataSource?.config as FileSourceConfig;
// If the path is URLs, download the data and save it to the data directory
Expand All @@ -128,20 +133,15 @@ const prepareContextData = async (
dataSourceConfig.url.toString(),
);
const destPath = path.join(
root,
"data",
dataDir,
dataSourceConfig.filename ??
path.basename(dataSourceConfig.url.toString()),
);
await downloadFile(dataSourceConfig.url.toString(), destPath);
} else {
// Copy local data
console.log("Copying data from path:", dataSourceConfig.path);
const destPath = path.join(
root,
"data",
path.basename(dataSourceConfig.path),
);
const destPath = path.join(dataDir, path.basename(dataSourceConfig.path));
await fsExtra.copy(dataSourceConfig.path, destPath);
}
}
Expand All @@ -156,6 +156,9 @@ export const installTemplate = async (props: InstallTemplateArgs) => {
await installTSTemplate(props);
}

const isPythonLlamaDeploy =
props.framework === "fastapi" && props.template === "llamaindexserver";

// This is a backend, so we need to copy the test data and create the env file.

// Copy the environment file to the target directory.
Expand All @@ -164,6 +167,7 @@ export const installTemplate = async (props: InstallTemplateArgs) => {
await prepareContextData(
props.root,
props.dataSources.filter((ds) => ds.type === "file"),
isPythonLlamaDeploy,
);

if (
Expand All @@ -183,10 +187,12 @@ export const installTemplate = async (props: InstallTemplateArgs) => {
);
}

// Create outputs directory
await makeDir(path.join(props.root, "output/tools"));
await makeDir(path.join(props.root, "output/uploaded"));
await makeDir(path.join(props.root, "output/llamacloud"));
if (!isPythonLlamaDeploy) {
// Create outputs directory (llama-deploy doesn't need this)
await makeDir(path.join(props.root, "output/tools"));
await makeDir(path.join(props.root, "output/uploaded"));
await makeDir(path.join(props.root, "output/llamacloud"));
}
};

export * from "./types";
Loading
Loading