33 lines
885 B
C#
33 lines
885 B
C#
|
using Godot;
|
||
|
using Newtonsoft.Json;
|
||
|
using System;
|
||
|
using System.Linq;
|
||
|
|
||
|
public partial class SendIngamePrompt : Button
|
||
|
{
|
||
|
private LLMApiRequests llmApiRequests;
|
||
|
private TextEdit input;
|
||
|
private TextEdit story;
|
||
|
|
||
|
public override void _Ready()
|
||
|
{
|
||
|
SetProcess(false);
|
||
|
llmApiRequests = GetTree().Root.GetNode<LLMApiRequests>("Root/LLMApiRequests");
|
||
|
input = GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Eingabe/TextEdit");
|
||
|
story = GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Story/TextEdit");
|
||
|
}
|
||
|
|
||
|
public override void _Pressed()
|
||
|
{
|
||
|
llmApiRequests?.PostToApi();
|
||
|
|
||
|
var temp = llmApiRequests.Context.Where(c => c.Role != "system").Select(c => c.Content.Trim()).ToList();
|
||
|
temp.Add(llmApiRequests.Choices.ElementAt(0).Message.Content.Trim());
|
||
|
temp.Add(input.Text);
|
||
|
story.Text = string.Join("\n", temp);
|
||
|
input.Text = string.Empty;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|