Skip to content

Commit

Permalink
SetContentByTag for ChatHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Jul 16, 2023
1 parent ac1037d commit 8f5276c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions OpenAI.Utils.ChatHistory.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TChatHistory = class(TList<TChatMessageBuild>)
procedure New(Role: TMessageRole; Content, Tag: string);
procedure NewFunc(const FuncName, FuncResult, Tag: string);
procedure NewAsistantFunc(const FuncName, Args, Tag: string);
procedure SetContentByTag(const Tag, Text: string);
function TextLength: Int64;
property AutoTrim: Boolean read FAutoTrim write SetAutoTrim;
property MaxTokensForQuery: Int64 read FMaxTokensForQuery write SetMaxTokensForQuery;
Expand Down Expand Up @@ -64,6 +65,18 @@ procedure TChatHistory.DeleteByTag(const Tag: string);
end;
end;

procedure TChatHistory.SetContentByTag(const Tag, Text: string);
begin
for var i := 0 to Count - 1 do
if Items[i].Tag = Tag then
begin
var Item := Items[i];
Item.Content := Text;
Items[i] := Item;
Exit;
end;
end;

procedure TChatHistory.New(Role: TMessageRole; Content, Tag: string);
var
Item: TChatMessageBuild;
Expand Down

0 comments on commit 8f5276c

Please sign in to comment.