Skip to content

Commit

Permalink
#153: Updating tests to feed chat params instead of request schema
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-glushko committed Jun 4, 2024
1 parent 942a9d9 commit 85e7646
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
8 changes: 6 additions & 2 deletions pkg/providers/azureopenai/chat_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ func TestAzureOpenAIClient_ChatStreamRequest(t *testing.T) {
client, err := NewClient(providerCfg, clientCfg, telemetry.NewTelemetryMock())
require.NoError(t, err)

req := schemas.NewChatStreamFromStr("What's the capital of the United Kingdom?")
stream, err := client.ChatStream(ctx, req)
chatParams := schemas.ChatParams{Messages: []schemas.ChatMessage{{
Role: "user",
Content: "What's the capital of the United Kingdom?",
}}}

stream, err := client.ChatStream(ctx, &chatParams)
require.NoError(t, err)

err = stream.Open()
Expand Down
6 changes: 3 additions & 3 deletions pkg/providers/bedrock/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ func TestBedrockClient_ChatRequest(t *testing.T) {
client, err := NewClient(providerCfg, clientCfg, telemetry.NewTelemetryMock())
require.NoError(t, err)

request := schemas.ChatRequest{Message: schemas.ChatMessage{
chatParams := schemas.ChatParams{Messages: []schemas.ChatMessage{{
Role: "user",
Content: "What's the biggest animal?",
}}
}}}

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

responseString := fmt.Sprintf("%+v", response)
// errString := fmt.Sprintf("%+v", err)
Expand Down
25 changes: 13 additions & 12 deletions pkg/providers/octoml/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ func TestOctoMLClient_ChatRequest(t *testing.T) {
client, err := NewClient(providerCfg, clientCfg, telemetry.NewTelemetryMock())
require.NoError(t, err)

request := schemas.ChatRequest{Message: schemas.ChatMessage{
chatParams := schemas.ChatParams{Messages: []schemas.ChatMessage{{
Role: "human",
Content: "What's the biggest animal?",
}}
}}}

response, err := client.Chat(ctx, &request)
response, err := client.Chat(ctx, &chatParams)
require.NoError(t, err)

require.Equal(t, providerCfg.ModelName, response.ModelName)
Expand Down Expand Up @@ -88,15 +88,13 @@ func TestOctoMLClient_Chat_Error(t *testing.T) {
require.NoError(t, err)

// Create a chat request
request := schemas.ChatRequest{
Message: schemas.ChatMessage{
Role: "human",
Content: "What's the biggest animal?",
},
}
chatParams := schemas.ChatParams{Messages: []schemas.ChatMessage{{
Role: "human",
Content: "What's the biggest animal?",
}}}

// Call the Chat function
_, err = client.Chat(ctx, &request)
_, err = client.Chat(ctx, &chatParams)

// Check the error
require.Error(t, err)
Expand All @@ -122,9 +120,12 @@ func TestDoChatRequest_ErrorResponse(t *testing.T) {
require.NoError(t, err)

// Create a chat request payload
payload := schemas.NewChatFromStr("What's the dealio?")
chatParams := schemas.ChatParams{Messages: []schemas.ChatMessage{{
Role: "user",
Content: "What's the dealeo?",
}}}

_, err = client.Chat(ctx, payload)
_, err = client.Chat(ctx, &chatParams)

require.Error(t, err)
require.Contains(t, err.Error(), "provider is not available")
Expand Down
6 changes: 3 additions & 3 deletions pkg/providers/ollama/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ func TestOllamaClient_ChatRequest(t *testing.T) {
client, err := NewClient(providerCfg, clientCfg, telemetry.NewTelemetryMock())
require.NoError(t, err)

request := schemas.ChatRequest{Message: schemas.ChatMessage{
chatParams := schemas.ChatParams{Messages: []schemas.ChatMessage{{
Role: "user",
Content: "What's the biggest animal?",
}}
}}}

_, err = client.Chat(ctx, &request)
_, err = client.Chat(ctx, &chatParams)

// require.NoError(t, err)

Expand Down
8 changes: 6 additions & 2 deletions pkg/providers/openai/chat_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ func TestOpenAIClient_ChatStreamRequest(t *testing.T) {
client, err := NewClient(providerCfg, clientCfg, telemetry.NewTelemetryMock())
require.NoError(t, err)

req := schemas.NewChatStreamFromStr("What's the capital of the United Kingdom?")
stream, err := client.ChatStream(ctx, req)
chatParams := schemas.ChatParams{Messages: []schemas.ChatMessage{{
Role: "user",
Content: "What's the capital of the United Kingdom?",
}}}

stream, err := client.ChatStream(ctx, &chatParams)
require.NoError(t, err)

err = stream.Open()
Expand Down

0 comments on commit 85e7646

Please sign in to comment.