You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everyone, I’m working on implementing a RAG architecture in C# using a data retrieval with Kernel Functions. From my understanding, the result of this kernel function will be embedded as part of the prompt sent to the LLM, generating the intended response.
I’d like to know if it’s possible to store specific information retrieved from my vector search to make it accessible when calling InvokePromptAsync. Specifically, I’m looking to access details such as the source title or URL, which are part of the search results but aren’t directly embedded into the prompt sent to the LLM.
Here’s my kernel function:
`
[KernelFunction("GetData")]
public async Task Search(string prompt)
{
var embedding = await this.textEmbeddingGenerationService.GenerateEmbeddingAsync(prompt);
var searchClient = this.indexClient.GetSearchClient(this.CollectionName);
var vectorQuery = new VectorizedQuery(embedding);
vectorQuery.Fields.Add("Embedding");
var searchOptions = new SearchOptions() { VectorSearch = new() { Queries = { vectorQuery } } };
var response = await searchClient.SearchAsync<MyRecord>(searchOptions);
var recordResults = response.Value.GetResults();
var facts = string.Join(Environment.NewLine, recordResults
.OrderByDescending(record => record.Score)
.Take(10)
.Select(record => record.Document.Content));
return facts;
}
`
My MyRecord model includes not only Content for the LLM but also metadata like the document title and URL. I’d like to access this metadata directly within the InvokePromptAsync call without manually adding it to the prompt template or using KernelArguments. Ideally, I’d like to achieve this via the function itself or another method that keeps metadata accessible alongside the main prompt context.
Here’s an example of my prompt invocation:
var result = await this.semanticKernel.InvokePromptAsync(promptTemplate, arguments); var url = result.Metadata.Url;
Is there a way to embed or retrieve this metadata directly within the InvokePromptAsync scope? I can manually search in my vector database and add the context to my template using KernelArguments, but I’d prefer a more streamlined approach through the function if possible
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone, I’m working on implementing a RAG architecture in C# using a data retrieval with Kernel Functions. From my understanding, the result of this kernel function will be embedded as part of the prompt sent to the LLM, generating the intended response.
I’d like to know if it’s possible to store specific information retrieved from my vector search to make it accessible when calling InvokePromptAsync. Specifically, I’m looking to access details such as the source title or URL, which are part of the search results but aren’t directly embedded into the prompt sent to the LLM.
Here’s my kernel function:
`
[KernelFunction("GetData")]
public async Task Search(string prompt)
{
var embedding = await this.textEmbeddingGenerationService.GenerateEmbeddingAsync(prompt);
var searchClient = this.indexClient.GetSearchClient(this.CollectionName);
}
`
My MyRecord model includes not only Content for the LLM but also metadata like the document title and URL. I’d like to access this metadata directly within the InvokePromptAsync call without manually adding it to the prompt template or using KernelArguments. Ideally, I’d like to achieve this via the function itself or another method that keeps metadata accessible alongside the main prompt context.
Here’s an example of my prompt invocation:
var result = await this.semanticKernel.InvokePromptAsync(promptTemplate, arguments); var url = result.Metadata.Url;
Is there a way to embed or retrieve this metadata directly within the InvokePromptAsync scope? I can manually search in my vector database and add the context to my template using KernelArguments, but I’d prefer a more streamlined approach through the function if possible
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions