game-dev #8
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,20 +4,20 @@ using System.Net.Cache;
|
|||||||
|
|
||||||
public partial class Playbutton : Button
|
public partial class Playbutton : Button
|
||||||
{
|
{
|
||||||
private LLMApiRequest llmApiRequest;
|
// private LLMApiRequest llmApiRequest;
|
||||||
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
SetProcess(false);
|
SetProcess(false);
|
||||||
llmApiRequest = GetNode<LLMApiRequest>("/root/Node2D/HTTPRequests");
|
// llmApiRequest = GetNode<LLMApiRequest>("/root/Node2D/HTTPRequests");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Pressed()
|
public override void _Pressed()
|
||||||
{
|
{
|
||||||
// llmApiRequest.RequestCompleted += OnRequestCompleted;
|
// llmApiRequest.RequestCompleted += OnRequestCompleted;
|
||||||
// llmApiRequest.Request("https://api.github.com/repos/godotengine/godot/releases/latest");
|
// llmApiRequest.Request("https://api.github.com/repos/godotengine/godot/releases/latest");
|
||||||
llmApiRequest?.PostToApi(OnRequestCompleted);
|
// llmApiRequest?.PostToApi(OnRequestCompleted);
|
||||||
|
|
||||||
|
|
||||||
GD.Print("a");
|
GD.Print("a");
|
||||||
|
@ -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="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="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://Playbutton.cs" id="3_ucfae"]
|
||||||
[ext_resource type="Script" path="res://LLMApiRequests.cs" id="5_pukni"]
|
|
||||||
|
|
||||||
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_ncw85"]
|
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_ncw85"]
|
||||||
|
|
||||||
@ -263,9 +262,6 @@ size_flags_vertical = 3
|
|||||||
text = " PLAY "
|
text = " PLAY "
|
||||||
script = ExtResource("3_ucfae")
|
script = ExtResource("3_ucfae")
|
||||||
|
|
||||||
[node name="LLMApiRequests" type="HTTPRequest" parent="."]
|
|
||||||
script = ExtResource("5_pukni")
|
|
||||||
|
|
||||||
[node name="Ingame" type="Node2D" parent="."]
|
[node name="Ingame" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="IngameCanvas" type="CanvasLayer" parent="Ingame"]
|
[node name="IngameCanvas" type="CanvasLayer" parent="Ingame"]
|
||||||
|
Reference in New Issue
Block a user