-
Notifications
You must be signed in to change notification settings - Fork 183
feat: use llamacloud for chat #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c65daa3
feat: add llamacloud as vectordb
thucpn 286245b
feat: add question to select llamacloud
thucpn 52c848c
refactor: clean code in generate and chat
thucpn 226f4e4
Create tough-pugs-destroy.md
thucpn ba4c04d
add llama cloud query for fastapi
thucpn 0923a38
update to lastest llama-index and llama-cloud
thucpn 518931b
add required env variables
thucpn 0a19bc7
fix: env variable for LlamaCloud
marcusschiesser 831df3e
feat: ask for LLAMA_CLOUD_API_KEY for LlamaCloud
marcusschiesser 3bca368
fix: don't use system prompt for now
marcusschiesser 8328240
fix: python code
marcusschiesser 8fdf640
feat: use llamaparse if using llamacloud
marcusschiesser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-llama": patch | ||
--- | ||
|
||
use llamacloud for chat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
templates/components/vectordbs/typescript/llamacloud/generate.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as dotenv from "dotenv"; | ||
import { LlamaCloudIndex } from "llamaindex"; | ||
import { getDocuments } from "./loader"; | ||
import { initSettings } from "./settings"; | ||
import { checkRequiredEnvVars } from "./shared"; | ||
|
||
dotenv.config(); | ||
|
||
async function loadAndIndex() { | ||
const documents = await getDocuments(); | ||
await LlamaCloudIndex.fromDocuments({ | ||
documents, | ||
name: process.env.LLAMA_CLOUD_NAME!, | ||
projectName: process.env.LLAMA_CLOUD_PROJECT_NAME!, | ||
apiKey: process.env.LLAMA_CLOUD_API_KEY, | ||
baseUrl: process.env.LLAMA_CLOUD_BASE_URL, | ||
}); | ||
console.log(`Successfully created embeddings!`); | ||
} | ||
marcusschiesser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
(async () => { | ||
checkRequiredEnvVars(); | ||
initSettings(); | ||
await loadAndIndex(); | ||
console.log("Finished generating storage."); | ||
})(); |
13 changes: 13 additions & 0 deletions
13
templates/components/vectordbs/typescript/llamacloud/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { LlamaCloudIndex } from "llamaindex/cloud/LlamaCloudIndex"; | ||
import { checkRequiredEnvVars } from "./shared"; | ||
|
||
export async function getDataSource() { | ||
checkRequiredEnvVars(); | ||
const index = new LlamaCloudIndex({ | ||
name: process.env.LLAMA_CLOUD_NAME!, | ||
projectName: process.env.LLAMA_CLOUD_PROJECT_NAME!, | ||
apiKey: process.env.LLAMA_CLOUD_API_KEY, | ||
baseUrl: process.env.LLAMA_CLOUD_BASE_URL, | ||
}); | ||
return index; | ||
marcusschiesser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
22 changes: 22 additions & 0 deletions
22
templates/components/vectordbs/typescript/llamacloud/shared.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const REQUIRED_ENV_VARS = [ | ||
"LLAMA_CLOUD_NAME", | ||
"LLAMA_CLOUD_PROJECT_NAME", | ||
"LLAMA_CLOUD_API_KEY", | ||
]; | ||
|
||
export function checkRequiredEnvVars() { | ||
const missingEnvVars = REQUIRED_ENV_VARS.filter((envVar) => { | ||
return !process.env[envVar]; | ||
}); | ||
|
||
if (missingEnvVars.length > 0) { | ||
console.log( | ||
`The following environment variables are required but missing: ${missingEnvVars.join( | ||
", ", | ||
)}`, | ||
); | ||
throw new Error( | ||
`Missing environment variables: ${missingEnvVars.join(", ")}`, | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.