Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added openai completer_tests #281

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions app/pkg/oai/completer_test.go
Original file line number Diff line number Diff line change
@@ -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.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)
}

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))
}