Skip to content

Commit

Permalink
working implementation with async
Browse files Browse the repository at this point in the history
  • Loading branch information
amakropoulos committed Feb 26, 2024
1 parent e10b86f commit d99f7e4
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions Tests/Runtime/TestLLM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using UnityEngine;
using System.Threading.Tasks;
using System.Collections.Generic;
using System;
using System.Collections;
using UnityEngine.TestTools;

namespace LLMUnityTests
{
Expand Down Expand Up @@ -39,7 +42,7 @@ public class TestLLM
LLMNoAwake llm;
int port = 15555;
string AIReply = ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";

Exception error = null;

public TestLLM()
{
Expand Down Expand Up @@ -67,13 +70,14 @@ public async Task Init()
llm.seed = 0;
llm.stream = false;
llm.numPredict = 128;
llm.parallelPrompts = 1;

gameObject.SetActive(true);
}

[Test]
public async void RunTests()
public async Task RunTests()
{
error = null;
try
{
Assert.That(!llm.IsPortInUse());
Expand All @@ -88,9 +92,22 @@ public async void RunTests()
await llm.SetPrompt("You are");
TestInitParameters();
}
finally
catch (Exception e)
{
error = e;
}
}

[UnityTest]
public IEnumerator RunTestsWait()
{
Task task = RunTests();
while (!task.IsCompleted) yield return null;
llm.CallOnDestroy();
if (error != null)
{
llm.CallOnDestroy();
Debug.LogError(error.ToString());
throw (error);
}
}

Expand Down

0 comments on commit d99f7e4

Please sign in to comment.