feedback
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
This commit is contained in:
parent
48cbe1fd06
commit
7d99198b97
|
@ -46,7 +46,7 @@ func NewTestConfig(componentName string) TestConfig {
|
|||
}
|
||||
|
||||
func ConformanceTests(t *testing.T, props map[string]string, conv conversation.Conversation, component string) {
|
||||
var finishStopReasonOfProviders = []string{"stop", "end_turn", "FinishReasonStop"}
|
||||
var providerStopReasons = []string{"stop", "end_turn", "FinishReasonStop"}
|
||||
|
||||
t.Run("init", func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
|
||||
|
@ -106,7 +106,7 @@ func ConformanceTests(t *testing.T, props map[string]string, conv conversation.C
|
|||
assert.Len(t, resp.Outputs, 1)
|
||||
assert.NotEmpty(t, resp.Outputs[0].Choices[0].Message.Content)
|
||||
// anthropic responds with end_turn but other llm providers return with stop
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp.Outputs[0].StopReason))
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp.Outputs[0].StopReason))
|
||||
assert.Empty(t, resp.Outputs[0].Choices[0].Message.ToolCallRequest)
|
||||
})
|
||||
t.Run("test system message type", func(t *testing.T) {
|
||||
|
@ -146,7 +146,7 @@ func ConformanceTests(t *testing.T, props map[string]string, conv conversation.C
|
|||
assert.Len(t, resp.Outputs, 1)
|
||||
assert.NotEmpty(t, resp.Outputs[0].Choices[0].Message.Content)
|
||||
// anthropic responds with end_turn but other llm providers return with stop
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp.Outputs[0].StopReason), resp.Outputs[0].StopReason)
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp.Outputs[0].StopReason), resp.Outputs[0].StopReason)
|
||||
assert.Empty(t, resp.Outputs[0].Choices[0].Message.ToolCallRequest)
|
||||
}
|
||||
})
|
||||
|
@ -240,7 +240,7 @@ func ConformanceTests(t *testing.T, props map[string]string, conv conversation.C
|
|||
assert.Len(t, resp.Outputs, 4)
|
||||
// Check the last output - human message
|
||||
assert.NotEmpty(t, resp.Outputs[3].Choices[0].Message.Content)
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp.Outputs[3].StopReason))
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp.Outputs[3].StopReason))
|
||||
// Check the tool call output - second output
|
||||
if resp.Outputs[1].Choices[0].Message.ToolCallRequest != nil && len(*resp.Outputs[1].Choices[0].Message.ToolCallRequest) > 0 {
|
||||
assert.NotEmpty(t, resp.Outputs[1].Choices[0].Message.ToolCallRequest)
|
||||
|
@ -250,7 +250,7 @@ func ConformanceTests(t *testing.T, props map[string]string, conv conversation.C
|
|||
assert.Len(t, resp.Outputs, 1)
|
||||
assert.NotEmpty(t, resp.Outputs[0].Choices[0].Message.Content)
|
||||
// anthropic responds with end_turn but other llm providers return with stop
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp.Outputs[0].StopReason))
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp.Outputs[0].StopReason))
|
||||
if resp.Outputs[0].Choices[0].Message.ToolCallRequest != nil && len(*resp.Outputs[0].Choices[0].Message.ToolCallRequest) > 0 {
|
||||
assert.NotEmpty(t, resp.Outputs[0].Choices[0].Message.ToolCallRequest)
|
||||
require.JSONEq(t, `{"test": "value"}`, (*resp.Outputs[0].Choices[0].Message.ToolCallRequest)[0].FunctionCall.Arguments)
|
||||
|
@ -279,7 +279,7 @@ func ConformanceTests(t *testing.T, props map[string]string, conv conversation.C
|
|||
assert.Len(t, resp.Outputs, 1)
|
||||
assert.NotEmpty(t, resp.Outputs[0].Choices[0].Message.Content)
|
||||
// anthropic responds with end_turn but other llm providers return with stop
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp.Outputs[0].StopReason))
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp.Outputs[0].StopReason))
|
||||
if resp.Outputs[0].Choices[0].Message.ToolCallRequest != nil {
|
||||
assert.Empty(t, *resp.Outputs[0].Choices[0].Message.ToolCallRequest)
|
||||
}
|
||||
|
@ -386,10 +386,10 @@ func ConformanceTests(t *testing.T, props map[string]string, conv conversation.C
|
|||
require.NoError(t, err2)
|
||||
assert.Len(t, resp2.Outputs, 1)
|
||||
assert.NotEmpty(t, resp2.Outputs[0].Choices[0].Message.Content)
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp2.Outputs[0].StopReason))
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp2.Outputs[0].StopReason))
|
||||
} else {
|
||||
assert.NotEmpty(t, resp.Outputs[0].Choices[0].Message.Content)
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp.Outputs[0].StopReason))
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp.Outputs[0].StopReason))
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -510,11 +510,11 @@ func ConformanceTests(t *testing.T, props map[string]string, conv conversation.C
|
|||
require.NoError(t, err)
|
||||
assert.Len(t, resp2.Outputs, 1)
|
||||
assert.NotEmpty(t, resp2.Outputs[0].Choices[0].Message.Content)
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp2.Outputs[0].StopReason))
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp2.Outputs[0].StopReason))
|
||||
} else {
|
||||
// it is valid too if no tool call was generated
|
||||
assert.NotEmpty(t, resp1.Outputs[0].Choices[0].Message.Content)
|
||||
assert.True(t, slices.Contains(finishStopReasonOfProviders, resp1.Outputs[0].StopReason))
|
||||
assert.True(t, slices.Contains(providerStopReasons, resp1.Outputs[0].StopReason))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue