Skip to content

Commit

Permalink
define current result placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
hoseinzadehashraf committed Jan 3, 2024
1 parent 32262c0 commit 3657fed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Olive.Gpt/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Olive.Gpt
{
public class Api
{
public const string CurrentResultPlaceholder = "#CURRENT_RESULT#";
static readonly JsonSerializerSettings Settings = new() { NullValueHandling = NullValueHandling.Ignore };
static readonly HttpClient Client = new(CreateForgivingHandler()) { Timeout = 5.Minutes() };
readonly string _model;
Expand All @@ -37,13 +38,13 @@ public Api(string apiKey, string model = "gpt-3.5-turbo")
public async Task<string> GetTransformationResponse(IEnumerable<string> steps)
{
var enumerable = steps as string[] ?? steps.ToArray();
if (!enumerable.Any())
throw new Exception("Transformation steps is empty");
if (!enumerable.Any())
throw new Exception("Transformation steps is empty");

var result = "";
foreach (var step in enumerable)
{
var stepCommand = step.Replace("#CURRENT_RESULT#", result);
var stepCommand = step.Replace(CurrentResultPlaceholder, result);
result = await GetResponse(new[] { new ChatMessage("user", stepCommand) });
}

Expand Down
2 changes: 1 addition & 1 deletion Olive.Gpt/Olive.Gpt.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.0.112</Version>
<Version>1.0.113</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 3657fed

Please sign in to comment.