Skip to content

Commit

Permalink
#131: remove unneeded test
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger12 committed Feb 12, 2024
1 parent 8aeeb00 commit 45d2dd6
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions pkg/providers/bedrock/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,54 +66,3 @@ func TestBedrockClient_ChatRequest(t *testing.T) {
require.Equal(t, "chatcmpl-123", response.ID)
}

func TestAWSBedrockClient_ChatRequest(t *testing.T) {
// OpenAI Chat API: https://platform.openai.com/docs/api-reference/chat/create
openAIMock := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
rawPayload, _ := io.ReadAll(r.Body)

var data interface{}
// Parse the JSON body
err := json.Unmarshal(rawPayload, &data)
if err != nil {
t.Errorf("error decoding payload (%q): %v", string(rawPayload), err)
}

chatResponse, err := os.ReadFile(filepath.Clean("./testdata/chat.success.json"))
if err != nil {
t.Errorf("error reading openai chat mock response: %v", err)
}

w.Header().Set("Content-Type", "application/json")

_, err = w.Write(chatResponse)
if err != nil {
t.Errorf("error on sending chat response: %v", err)
}
})

openAIServer := httptest.NewServer(openAIMock)
defer openAIServer.Close()

ctx := context.Background()
providerCfg := DefaultConfig()
clientCfg := clients.DefaultClientConfig()

providerCfg.BaseURL = openAIServer.URL
providerCfg.AWSRegion = "us-west-2"
providerCfg.AccessKey = ""
providerCfg.SecretKey = ""

client, err := NewClient(providerCfg, clientCfg, telemetry.NewTelemetryMock())
require.NoError(t, err)

request := schemas.UnifiedChatRequest{Message: schemas.ChatMessage{
Role: "user",
Content: "What's the biggest animal?",
}}

response, _ := client.Chat(ctx, &request)

r, _ := json.Marshal(response)

println(string(r))
}

0 comments on commit 45d2dd6

Please sign in to comment.