-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: use milvus in chat llamaindex #4
feat: use milvus in chat llamaindex #4
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
app/api/chat/engine/index.ts
Outdated
); | ||
} | ||
|
||
return await VectorStoreIndex.fromVectorStore(store); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move a shared function getIndex to shared.ts?
app/api/chat/engine/generate.ts
Outdated
}); | ||
const storageContext = await storageContextFromDefaults({ vectorStore }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try using the shared function getIndex here and use is the index directly in fromDocuments below (without storage context)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can do:
const index = await getIndex(datasource);
const documents = await getDocuments(datasource);
// Set private=false to mark the document as public (required for filtering)
documents.forEach((doc) => {
doc.metadata["private"] = "false";
});
await runPipeline(index, documents);
But inside runPipeline
function, we are setting private
= true (we need to set private
= false when generating public documents)
I guess we shouldn't append metadata to documents inside runPipeline
function (can move it outside)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just updated to split the getIndex
function. Thank you! That's a cool idea that solves my pain.
Previously, when creating a new bot, users had to manually create a collection to start chatting.
But now, when creating a new bot, they can start by uploading a private file. It will automatically create a collection on Milvus
256bd96
to
3175f76
Compare
const isCollectionExist = await getMilvusClient().hasCollection({ | ||
collection_name: datasource, | ||
}); | ||
if (!isCollectionExist.value) { | ||
throw new Error( | ||
`Collection "${datasource}" does not exist! Run the generate script or try uploading a file.`, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about we move this check into getIndex
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't work when running generate (because when generating we will create a new collection)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about adding a checkExists
parameter to getIndex
then?
getIndex({datasource, checkExists: false})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let me try
} | ||
} | ||
|
||
export async function getIndex(datasource: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to mimize changes with base branch, call this getDatasource
and move it to index.ts
) { | ||
// Update documents with metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good we can also do this in CL directly
app/api/chat/upload/upload.ts
Outdated
@@ -14,6 +14,16 @@ export async function uploadDocument( | |||
const fileBuffer = Buffer.from(content, "base64"); | |||
const documents = await loadDocuments(fileBuffer, mimeType); | |||
const { filename } = await saveDocument(fileBuffer, mimeType); | |||
const index = await getDataSource(datasource); | |||
return await runPipeline(index, documents, filename); | |||
const index = await getIndex(datasource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good we can also do this in CL directly
@@ -20,7 +20,7 @@ npx -y create-llama@0.1.25 \ | |||
--post-install-action none \ | |||
--no-llama-parse \ | |||
--example-file \ | |||
--vector-db none \ | |||
--vector-db milvus \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goal: we just need to change this from none
to milvus
to use Milvus in chat llamaindex
Open new PR here: #5 |
No description provided.