Files
BABA_YAGA/Assets/Scripts/AI NPC/GeminiTest.cs

29 lines
1.1 KiB
C#
Raw Normal View History

2026-06-05 18:46:19 +07:00
using UnityEngine;
using Hallucinate.AI;
public class GeminiTest : MonoBehaviour
{
void Start()
{
Debug.Log("<color=cyan>[Gemini Test]</color> Bắt đầu kiểm tra kết nối API...");
if (GeminiService.Instance == null)
{
Debug.LogError("<color=red>[Gemini Test]</color> Không tìm thấy GeminiService Instance! Hãy đảm bảo bạn đã kéo script GeminiService vào một GameObject trong Scene.");
return;
}
string testPersona = "Bạn là một robot kiểm tra hệ thống.";
string testPrompt = "Chào bạn, nếu bạn nhận được tin nhắn này, hãy trả lời: 'Kết nối Gemini thành công!'";
GeminiService.Instance.GetResponse(testPersona, testPrompt, (response) => {
2026-06-05 21:24:41 +07:00
string finalMsg = response;
try {
DialogueResult result = JsonUtility.FromJson<DialogueResult>(response);
finalMsg = result.text;
} catch { }
Debug.Log($"<color=green>[Gemini Test] Phản hồi từ API:</color> {finalMsg}");
2026-06-05 18:46:19 +07:00
});
}
}