using UnityEngine;
using Hallucinate.AI;
public class GeminiTest : MonoBehaviour
{
void Start()
{
Debug.Log("[Gemini Test] Bắt đầu kiểm tra kết nối API...");
if (GeminiService.Instance == null)
{
Debug.LogError("[Gemini Test] 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) => {
string finalMsg = response;
try {
DialogueResult result = JsonUtility.FromJson(response);
finalMsg = result.text;
} catch { }
Debug.Log($"[Gemini Test] Phản hồi từ API: {finalMsg}");
});
}
}