game-dev #8

Merged
leon merged 9 commits from game-dev into dev/game 2023-09-24 13:32:16 +02:00
3 changed files with 4 additions and 45 deletions
Showing only changes of commit 15a7f27cee - Show all commits

View File

@ -1,37 +0,0 @@
using Godot;
using System;
public partial class LLMApiRequest : HttpRequest
{
public record AnswerRequest(
Message[] Context,
string Prompt
);
public record Message(
string Role,
string? Content
);
private bool PostToApiIsSet = false;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
SetProcess(false);
}
public void PostToApi(Action<long, long, string[], byte[]> action)
{
if(!PostToApiIsSet)
{
RequestCompleted += (long result, long responseCode, string[] headers, byte[] body) => action(result, responseCode, headers, body);
PostToApiIsSet = true;
}
var answerRequest = new AnswerRequest(new[] { new Message("user", "Hello!"), }, "aodneris");
Request($"http://localhost:5246/LLM/Test", new[] { "Content-Type: application/json" }, HttpClient.Method.Get, Newtonsoft.Json.JsonConvert.SerializeObject(answerRequest));
}
}

View File

@ -4,20 +4,20 @@ using System.Net.Cache;
public partial class Playbutton : Button
{
private LLMApiRequest llmApiRequest;
// private LLMApiRequest llmApiRequest;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
SetProcess(false);
llmApiRequest = GetNode<LLMApiRequest>("/root/Node2D/HTTPRequests");
// llmApiRequest = GetNode<LLMApiRequest>("/root/Node2D/HTTPRequests");
}
public override void _Pressed()
{
// llmApiRequest.RequestCompleted += OnRequestCompleted;
// llmApiRequest.Request("https://api.github.com/repos/godotengine/godot/releases/latest");
llmApiRequest?.PostToApi(OnRequestCompleted);
// llmApiRequest?.PostToApi(OnRequestCompleted);
GD.Print("a");

View File

@ -1,9 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://1gar30yhw8ay"]
[gd_scene load_steps=5 format=3 uid="uid://1gar30yhw8ay"]
[ext_resource type="Script" path="res://MainMenu.cs" id="1_m0gay"]
[ext_resource type="Texture2D" uid="uid://vn2ficr8n4n5" path="res://GodofAi.jpg" id="2_m684j"]
[ext_resource type="Script" path="res://Playbutton.cs" id="3_ucfae"]
[ext_resource type="Script" path="res://LLMApiRequests.cs" id="5_pukni"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_ncw85"]
@ -263,9 +262,6 @@ size_flags_vertical = 3
text = " PLAY "
script = ExtResource("3_ucfae")
[node name="LLMApiRequests" type="HTTPRequest" parent="."]
script = ExtResource("5_pukni")
[node name="Ingame" type="Node2D" parent="."]
[node name="IngameCanvas" type="CanvasLayer" parent="Ingame"]