Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 test-proj/ui/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import { client as platformClient } from "@llamaindex/cloud/api";

const platformToken = import.meta.env.VITE_LLAMA_CLOUD_API_KEY;
const apiBaseUrl = import.meta.env.VITE_LLAMA_CLOUD_BASE_URL;
const projectId = import.meta.env.VITE_LLAMA_CLOUD_PROJECT_ID;

// Configure the platform client
platformClient.setConfig({
baseUrl: apiBaseUrl,
headers: {
// optionally use a backend API token scoped to a project. For local development,
...(platformToken && { authorization: `Bearer ${platformToken}` }),
// This header is required for requests to correctly scope to the agent's project
// when authenticating with a user cookie
...(projectId && { "Project-Id": projectId }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can integrate the whole auth into our sdk as well.
And we only expose some configurations out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "the whole auth?" Like, making the typescript sdk support reading the miscellaneous variables and configure its client automatically? Agree, that would be nice. It's a little awkward with the prefixed env vars

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

},
});

Expand Down
5 changes: 5 additions & 0 deletions test-proj/ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from "path";
export default defineConfig(({}) => {
const deploymentId = process.env.LLAMA_DEPLOY_NEXTJS_DEPLOYMENT_NAME;
const basePath = `/deployments/${deploymentId}/ui`;
const projectId = process.env.LLAMA_DEPLOY_PROJECT_ID;

return {
plugins: [react()],
Expand All @@ -30,6 +31,10 @@ export default defineConfig(({}) => {
"import.meta.env.VITE_LLAMA_DEPLOY_DEPLOYMENT_NAME":
JSON.stringify(deploymentId),
"import.meta.env.VITE_LLAMA_DEPLOY_BASE_PATH": JSON.stringify(basePath),
...(projectId && {
"import.meta.env.VITE_LLAMA_CLOUD_PROJECT_ID":
JSON.stringify(projectId),
}),
},
};
});
5 changes: 5 additions & 0 deletions ui/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import { client as platformClient } from "@llamaindex/cloud/api";

const platformToken = import.meta.env.VITE_LLAMA_CLOUD_API_KEY;
const apiBaseUrl = import.meta.env.VITE_LLAMA_CLOUD_BASE_URL;
const projectId = import.meta.env.VITE_LLAMA_CLOUD_PROJECT_ID;

// Configure the platform client
platformClient.setConfig({
baseUrl: apiBaseUrl,
headers: {
// optionally use a backend API token scoped to a project. For local development,
...(platformToken && { authorization: `Bearer ${platformToken}` }),
// This header is required for requests to correctly scope to the agent's project
// when authenticating with a user cookie
...(projectId && { "Project-Id": projectId }),
},
});

Expand Down
5 changes: 5 additions & 0 deletions ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from "path";
export default defineConfig(({}) => {
const deploymentId = process.env.LLAMA_DEPLOY_NEXTJS_DEPLOYMENT_NAME;
const basePath = `/deployments/${deploymentId}/ui`;
const projectId = process.env.LLAMA_DEPLOY_PROJECT_ID;

return {
plugins: [react()],
Expand All @@ -30,6 +31,10 @@ export default defineConfig(({}) => {
"import.meta.env.VITE_LLAMA_DEPLOY_DEPLOYMENT_NAME":
JSON.stringify(deploymentId),
"import.meta.env.VITE_LLAMA_DEPLOY_BASE_PATH": JSON.stringify(basePath),
...(projectId && {
"import.meta.env.VITE_LLAMA_CLOUD_PROJECT_ID":
JSON.stringify(projectId),
}),
},
};
});