Compare commits
2 Commits
b231650cc6
...
f70cef91bd
Author | SHA1 | Date | |
---|---|---|---|
f70cef91bd | |||
0b7257c971 |
10
godot/God of AI.csproj
Normal file
10
godot/God of AI.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Godot.NET.Sdk/4.1.1">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
<RootNamespace>GodofAI</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
19
godot/God of AI.sln
Normal file
19
godot/God of AI.sln
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "God of AI", "God of AI.csproj", "{9F042379-873C-42A6-B544-C877BAB3A96D}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||||
|
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{9F042379-873C-42A6-B544-C877BAB3A96D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9F042379-873C-42A6-B544-C877BAB3A96D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9F042379-873C-42A6-B544-C877BAB3A96D}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||||
|
{9F042379-873C-42A6-B544-C877BAB3A96D}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||||
|
{9F042379-873C-42A6-B544-C877BAB3A96D}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||||
|
{9F042379-873C-42A6-B544-C877BAB3A96D}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
37
godot/LLMApiRequests.cs
Normal file
37
godot/LLMApiRequests.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
@ -1,22 +1,25 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Net.Cache;
|
||||||
|
|
||||||
public partial class Playbutton : Button
|
public partial class Playbutton : Button
|
||||||
{
|
{
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
this.Pressed += ButtonPressed;
|
SetProcess(false);
|
||||||
|
llmApiRequest = GetNode<LLMApiRequest>("/root/Node2D/HTTPRequests");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
public override void _Pressed()
|
||||||
public override void _Process(double delta)
|
|
||||||
{
|
{
|
||||||
|
// llmApiRequest.RequestCompleted += OnRequestCompleted;
|
||||||
|
// llmApiRequest.Request("https://api.github.com/repos/godotengine/godot/releases/latest");
|
||||||
|
llmApiRequest?.PostToApi(OnRequestCompleted);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonPressed()
|
|
||||||
{
|
|
||||||
GD.Print("a");
|
GD.Print("a");
|
||||||
var node = this.GetNode<CanvasLayer>("Ingame/Ingame");
|
var node = this.GetNode<CanvasLayer>("Ingame/Ingame");
|
||||||
node.SetProcess(true);
|
node.SetProcess(true);
|
||||||
@ -24,4 +27,12 @@ public partial class Playbutton : Button
|
|||||||
var GParent = this.GetTree().Root.GetNode<CanvasLayer>("Root/Hauptmenü/HauptMenü");
|
var GParent = this.GetTree().Root.GetNode<CanvasLayer>("Root/Hauptmenü/HauptMenü");
|
||||||
GParent.Hide();
|
GParent.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
|
||||||
|
{
|
||||||
|
// Godot.Collections.Dictionary json = Json.ParseString(System.Text.Encoding.UTF8.GetString(body)).AsGodotDictionary();
|
||||||
|
// GD.Print(json["name"]);
|
||||||
|
// GD.Print(Json.ParseString(System.Text.Encoding.UTF8.GetString(body)).AsGodotDictionary());
|
||||||
|
GD.Print(System.Text.Encoding.UTF8.GetString(body));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://1gar30yhw8ay"]
|
[gd_scene load_steps=7 format=3 uid="uid://1gar30yhw8ay"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Hauptmenü.cs" id="1_4eu52"]
|
[ext_resource type="Script" path="res://Hauptmenü.cs" id="1_4eu52"]
|
||||||
[ext_resource type="Script" path="res://TextEdit.cs" id="1_5gfrp"]
|
[ext_resource type="Script" path="res://TextEdit.cs" id="1_5gfrp"]
|
||||||
[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"]
|
||||||
|
|
||||||
@ -364,3 +365,6 @@ offset_bottom = 719.0
|
|||||||
texture = SubResource("CompressedTexture2D_ncw85")
|
texture = SubResource("CompressedTexture2D_ncw85")
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
stretch_mode = 1
|
stretch_mode = 1
|
||||||
|
|
||||||
|
[node name="LLMApiRequests" type="HTTPRequest" parent="."]
|
||||||
|
script = ExtResource("5_pukni")
|
||||||
|
Reference in New Issue
Block a user