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
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"type": "generated",
"generator": "constant",
"parameters": {
"value": "llama3.1"
"value": "llama3.2"
}
},
"OllamaEmbeddingModelDefault": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
Use only simple markdown to format your responses.

Use the search tool to find relevant information. When you do this, end your
reply with citations in the special format, always formatted as XML:
<citation filename='string' page_number='number'>exact quote here</citation>.
reply with citations in the special XML format:

<citation filename='string' page_number='number'>exact quote here</citation>

Always include the citation in your response if there are results.

The quote must be max 5 words, taken word-for-word from the search result, and is the basis for why the citation is relevant.
Don't refer to the presence of citations; just emit these tags right at the end, with no surrounding text.
";
Expand All @@ -52,14 +56,14 @@
chatSuggestions?.Clear();
await chatInput!.FocusAsync();

#if (IsOllama)
@*#if (IsOllama)
// Display a new response from the IChatClient, streaming responses
// aren't supported because Ollama will not support both streaming and using Tools
currentResponseCancellation = new();
ChatCompletion response = await ChatClient.CompleteAsync(messages, chatOptions, currentResponseCancellation.Token);
currentResponseMessage = response.Message;
ChatMessageItem.NotifyChanged(currentResponseMessage);
#else
#else*@
// Stream and display a new response from the IChatClient
var responseText = new TextContent("");
currentResponseMessage = new ChatMessage(ChatRole.Assistant, [responseText]);
Expand All @@ -69,7 +73,7 @@
responseText.Text += chunk.Text;
ChatMessageItem.NotifyChanged(currentResponseMessage);
}
#endif
@*#endif*@

// Store the final response in the conversation, and begin getting suggestions
messages.Add(currentResponseMessage!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
<textarea @ref="@textArea" @bind="@messageText" placeholder="Type your message..." rows="1"></textarea>

<div class="tools">
<button type="button" title="Attach media file" class="btn-default attach">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="tool-icon">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Add content
</button>

<button type="submit" title="Send" class="send-button">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="tool-icon">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 12 3.269 3.125A59.769 59.769 0 0 1 21.485 12 59.768 59.768 0 0 1 3.27 20.875L5.999 12Zm0 0h7.5" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.VectorData;
using ChatWithCustomData.Web.Components;
using ChatWithCustomData.Web.Services;
using ChatWithCustomData.Web.Services.Ingestion;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.FileProviders.Physical;
#if(IsAzureOpenAi || UseAzureAISearch)
using Azure;
#endif
#if (IsOllama)
using OllamaSharp;
#elif (IsOpenAi || IsGHModels)
using OpenAI;
using System.ClientModel;
#else
using Azure.AI.OpenAI;
#if (UseManagedIdentity)
using Azure;
using Azure.Identity;
#else
using System.ClientModel;
#endif
#endif
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.VectorData;
using ChatWithCustomData.Web.Components;
using ChatWithCustomData.Web.Services;
using ChatWithCustomData.Web.Services.Ingestion;
using System.ClientModel;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.FileProviders.Physical;
#if (UseAzureAISearch)
using Azure.Search.Documents.Indexes;
using Microsoft.SemanticKernel.Connectors.AzureAISearch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ public async Task IngestDataAsync(IIngestionSource source)
{
logger.LogInformation("Processing {file}", modifiedDoc.Id);

await vectorCollection.DeleteBatchAsync(modifiedDoc.Records.Select(r => r.Id));

if (modifiedDoc.Records.Count > 0)
{
await vectorCollection.DeleteBatchAsync(modifiedDoc.Records.Select(r => r.Id));
}

var newRecords = await source.CreateRecordsForDocumentAsync(embeddingGenerator, modifiedDoc.Id);
await foreach (var id in vectorCollection.UpsertBatchAsync(newRecords)) { }

Expand Down