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
2 changes: 1 addition & 1 deletion LLama.Examples/LLama.Examples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.9" />
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.98.250508.3" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.64.0" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.44.0-alpha" />
Expand Down
11 changes: 8 additions & 3 deletions LLama/Extensions/LLamaExecutorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void Dispose() { }
public async Task<ChatResponse> GetResponseAsync(
IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
{
var result = _executor.InferAsync(CreatePrompt(messages), CreateInferenceParams(options), cancellationToken);
var result = _executor.InferAsync(CreatePrompt(messages, options), CreateInferenceParams(options), cancellationToken);

StringBuilder text = new();
await foreach (var token in _outputTransform.TransformAsync(result))
Expand All @@ -86,7 +86,7 @@ public async Task<ChatResponse> GetResponseAsync(
public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
IEnumerable<ChatMessage> messages, ChatOptions? options = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var result = _executor.InferAsync(CreatePrompt(messages), CreateInferenceParams(options), cancellationToken);
var result = _executor.InferAsync(CreatePrompt(messages, options), CreateInferenceParams(options), cancellationToken);

string messageId = Guid.NewGuid().ToString("N");
await foreach (var token in _outputTransform.TransformAsync(result))
Expand All @@ -100,7 +100,7 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
}

/// <summary>Format the chat messages into a string prompt.</summary>
private string CreatePrompt(IEnumerable<ChatMessage> messages)
private string CreatePrompt(IEnumerable<ChatMessage> messages, ChatOptions? options = null)
{
if (messages is null)
{
Expand All @@ -120,6 +120,11 @@ private string CreatePrompt(IEnumerable<ChatMessage> messages)
AuthorRole.User,
string.Concat(message.Contents.OfType<TextContent>()));
}

if (options?.Instructions is { } instructions)
{
history.AddMessage(AuthorRole.System, instructions);
}
}
else
{
Expand Down
10 changes: 5 additions & 5 deletions LLama/LLamaSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
<PackageReference Include="IsExternalInit" Version="1.0.3" PrivateAssets="all" />
<PackageReference Include="System.Memory" Version="4.6.3" PrivateAssets="all" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
<PackageReference Include="System.Text.Json" Version="9.0.8" />
<PackageReference Include="System.Text.Json" Version="9.0.9" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.4.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.8.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.8" />
<PackageReference Include="System.Numerics.Tensors" Version="9.0.8" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.9" />
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.9.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.9" />
<PackageReference Include="System.Numerics.Tensors" Version="9.0.9" />
</ItemGroup>

<PropertyGroup>
Expand Down
Loading