spoc-bot-vr/ai_test.go

69 lines
1.3 KiB
Go

//go:build ai
package main
import (
"context"
"testing"
"time"
)
func TestAINoop(t *testing.T) {
t.Parallel()
ai := NewAINoop()
testAI(t, ai)
}
func TestAIOllama(t *testing.T) {
t.Parallel()
ai := NewAIOllama("http://localhost:11434", "llama3")
testAI(t, ai)
}
func testAI(t *testing.T, ai AI) {
ctx, can := context.WithTimeout(context.Background(), time.Minute)
defer can()
t.Run("mvp", func(t *testing.T) {
if result, err := ai.Do(ctx, "Tell me a fun fact."); err != nil {
t.Fatal(err)
} else if len(result) < 3 {
t.Error(result)
} else {
t.Logf("%s", result)
}
})
/*
t.Run("simulation", func(t *testing.T) {
d := NewRAM()
FillWithTestdata(ctx, d, renderAssetPattern, renderDatacenterPattern, renderEventNamePattern)
s := NewStorage(d)
threads, err := s.Threads(ctx)
if err != nil || len(threads) < 1 {
t.Fatal(err)
}
thread, err := s.Thread(ctx, threads[0])
if err != nil || len(thread) < 1 {
t.Fatal(err)
}
input := fmt.Sprintf(`
Summarize the following forum converstion.
---
%s
`, thread[0].Plaintext)
t.Logf("\n\t%s", input)
result, err := ai.Do(ctx, input)
if err != nil {
t.Fatal(err)
}
t.Logf("\n\t%s\n->\n\t%s", input, result)
})
*/
}