There is a feature on Kimi that talks after adding a document, for example, I have the following private document:
Session Topic: "How to Use C# to Improve Work Efficiency
Participants: Zhang San, Li Si, Wang Wu
Time: 2024.9.26 14:00-16:00
Conference content:
1. Automating Daily Tasks
Many daily tasks can be automated to save time and effort. For example, if you need to work with large amounts of data on a regular basis, you can use C# to write scripts to automate the process of importing, cleaning, and analyzing data.
2. Building Custom Tools
C# can be used to build a variety of custom tools to meet specific needs.
3. Integrate Existing Systems
C# can be used to easily integrate with existing systems and APIs to increase productivity.
4. Develop plug-ins and extensions
Many applications support plug-ins and extensions, and C# can be used to develop these plug-ins to enhance the functionality of existing applications.
5. Optimize existing code
C# provides a rich set of libraries and frameworks that can help you optimize existing code for improved performance and maintainability.
After I uploaded this document, I asked questions about what was in the document, as follows:
So how do we implement this feature ourselves?
We have previously contacted the RAG, that can be used to deal with the document content beyond the model context, but very often, we just upload a simple document, the document content is not much, and there is no need for storage, then at this point, you can read the file content directly, without RAG.
Below is the effect of your own realization:
The same effect was achieved.
Realization points
public async IAsyncEnumerable<string> GetAIResponse3(string question,string filePath)
GetAIResponse3(string question,string filePath)
string fileContent = (filePath);
string skPrompt = """
Get the content of the file: {{$FileContent}}.
Answer a question based on the fetched information: {{$Question}}.
If it is not mentioned in the file content, directly answer don't know.
""";
await foreach (var str in _kernel.InvokePromptStreamingAsync(skPrompt, new() { ["FileContent"] = fileContent, ["Question"] = question }))
{
yield return ();
}
}
This can be accomplished using this simple prompt.
Quick Experience
I've posted both framework-dependent and non-framework-dependent versions on github. Unzip it and fill in your api key in the file to start the experience.
SimpleRAG address:/Ming-jiayou/SimpleRAG