From a97361fe7f1407c4316d009b82e58d116090c117 Mon Sep 17 00:00:00 2001 From: Charles Xu Date: Mon, 7 Oct 2024 02:07:30 -0400 Subject: [PATCH 1/2] Added openai completer_tests --- app/pkg/oai/completer_test.go | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/pkg/oai/completer_test.go diff --git a/app/pkg/oai/completer_test.go b/app/pkg/oai/completer_test.go new file mode 100644 index 0000000..c845206 --- /dev/null +++ b/app/pkg/oai/completer_test.go @@ -0,0 +1,39 @@ +package oai + +import ( + "context" + "os" + "testing" + + "github.com/jlewi/foyle/app/pkg/config" + "github.com/jlewi/foyle/app/pkg/docs" + "github.com/sashabaranov/go-openai" +) + +func TestOaiCompleter(t *testing.T) { + if os.Getenv("GITHUB_ACTIONS") != "" { + t.Skipf("TestAnthropicCompleter is a manual test that is skipped in CICD") + } + + if err := config.InitViper(nil); err != nil { + t.Fatalf("Failed to initialize Viper: %v", err) + } + + cfg := config.GetConfig() + cfg.Agent.Model = openai.GPT3Dot5Turbo // Not sure if this is a good model, just dug up one through one of the imports in completer.go + client, err := NewClient(*cfg) + if err != nil { + t.Fatalf("Failed to create OpenAI client: %v", err) + } + + completer, err := NewCompleter(*cfg, client) + if err != nil { + t.Fatalf("Failed to create Completer: %v", err) + } + blocks, err := completer.Complete(context.Background(), "You are a helpful assistant.", "Use gcloud to list GKE clusters") + if err != nil { + t.Fatalf("Failed to complete: %v", err) + } + + t.Logf("Blocks: %+v", docs.BlocksToMarkdown(blocks)) +} From 7e02fc439dfe7332d9b4f45cd7c16723deb80c56 Mon Sep 17 00:00:00 2001 From: Charles Xu Date: Mon, 7 Oct 2024 19:39:20 -0400 Subject: [PATCH 2/2] Updated oai model in oai completer test --- app/pkg/oai/completer_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pkg/oai/completer_test.go b/app/pkg/oai/completer_test.go index c845206..1a3dfc9 100644 --- a/app/pkg/oai/completer_test.go +++ b/app/pkg/oai/completer_test.go @@ -20,7 +20,7 @@ func TestOaiCompleter(t *testing.T) { } cfg := config.GetConfig() - cfg.Agent.Model = openai.GPT3Dot5Turbo // Not sure if this is a good model, just dug up one through one of the imports in completer.go + cfg.Agent.Model = openai.GPT4oMini // Not sure if this is a good model, just dug up one through one of the imports in completer.go client, err := NewClient(*cfg) if err != nil { t.Fatalf("Failed to create OpenAI client: %v", err)