Skip to content

Commit

Permalink
fix variables context reusable bug (#15)
Browse files Browse the repository at this point in the history
* fix variables context reusable bug

* update version
  • Loading branch information
xbotter authored Aug 3, 2023
1 parent 520f0a4 commit 576d039
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Nullable>enable</Nullable>
<AvaloniaVersion>11.0.0</AvaloniaVersion>
<Version>0.2.1</Version>
<Version>0.2.2</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
4 changes: 2 additions & 2 deletions PromptPlayground/Services/PromptService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<GenerateResult> RunAsync(string prompt, PromptTemplateConfig c
TokenUsage = usage
};
}

public SKContext CreateContext() => _kernel.CreateNewContext();
}
public class GenerateResult
Expand All @@ -48,7 +48,7 @@ public class GenerateResult
public string ElapsedText => $"{Elapsed.TotalSeconds:0.000} s";
public string Error { get; set; } = string.Empty;
public ResultTokenUsage? TokenUsage { get; set; }
public string TokenUsageText => TokenUsage!=null ? $"{TokenUsage.Total}({TokenUsage.Prompt}|{TokenUsage.Completion})" : string.Empty;
public string TokenUsageText => TokenUsage != null ? $"{TokenUsage.Total}({TokenUsage.Prompt}|{TokenUsage.Completion})" : string.Empty;

public bool HasError => !string.IsNullOrWhiteSpace(Error);
}
Expand Down
2 changes: 1 addition & 1 deletion PromptPlayground/ViewModels/ResultsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public ResultsViewModel()
OnPropertyChanged(nameof(Results));
};
}
public ObservableCollection<GenerateResult> Results { get; set; }
public ObservableCollection<GenerateResult> Results { get; set; }
}
}
2 changes: 1 addition & 1 deletion PromptPlayground/ViewModels/VariablesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public bool Configured()
return true;
}
}
public class Variable: ObservableObject
public class Variable : ObservableObject
{
public string Name { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
Expand Down
3 changes: 2 additions & 1 deletion PromptPlayground/Views/EditorView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ private async Task GenerateAsync()
{
break;
}
var result = await service.RunAsync(model.Prompt.Text, model.PromptConfig, context, cancellationToken: cancellationTokenSource!.Token);

var result = await service.RunAsync(model.Prompt.Text, model.PromptConfig, context.Clone(), cancellationToken: cancellationTokenSource!.Token);
OnGeneratedResult?.Invoke(this, new GenerateResultArgs(result));
}
}
Expand Down

0 comments on commit 576d039

Please sign in to comment.