add missing stream field

This commit is contained in:
MaysWind
2026-02-01 15:22:15 +08:00
parent 7647f4f5b9
commit 4177ac3d46
2 changed files with 6 additions and 4 deletions
@@ -28,6 +28,7 @@ type LMStudioLargeLanguageModelAdapter struct {
// LMStudioChatRequest defines the structure of LM Studio chat request
type LMStudioChatRequest struct {
Model string `json:"model"`
Stream bool `json:"stream"`
SystemPrompt string `json:"system_prompt,omitempty"`
Input []*LMStudioChatRequestInput `json:"input"`
}
@@ -100,8 +101,9 @@ func (p *LMStudioLargeLanguageModelAdapter) buildJsonRequestBody(c core.Context,
}
chatRequest := &LMStudioChatRequest{
Model: p.LMStudioModelID,
Input: make([]*LMStudioChatRequestInput, 0, 1),
Model: p.LMStudioModelID,
Stream: request.Stream,
Input: make([]*LMStudioChatRequestInput, 0, 1),
}
if request.SystemPrompt != "" {
@@ -27,7 +27,7 @@ func TestLMStudioLargeLanguageModelAdapter_buildJsonRequestBody_TextualUserPromp
err = json.Unmarshal(bodyBytes, &body)
assert.Nil(t, err)
assert.Equal(t, "{\"model\":\"test\",\"system_prompt\":\"You are a helpful assistant.\",\"input\":[{\"type\":\"text\",\"content\":\"Hello, how are you?\"}]}", string(bodyBytes))
assert.Equal(t, "{\"model\":\"test\",\"stream\":false,\"system_prompt\":\"You are a helpful assistant.\",\"input\":[{\"type\":\"text\",\"content\":\"Hello, how are you?\"}]}", string(bodyBytes))
}
func TestLMStudioLargeLanguageModelAdapter_buildJsonRequestBody_ImageUserPrompt(t *testing.T) {
@@ -49,7 +49,7 @@ func TestLMStudioLargeLanguageModelAdapter_buildJsonRequestBody_ImageUserPrompt(
err = json.Unmarshal(bodyBytes, &body)
assert.Nil(t, err)
assert.Equal(t, "{\"model\":\"test\",\"system_prompt\":\"What's in this image?\",\"input\":[{\"type\":\"image\",\"data_url\":\"data:image/png;base64,ZmFrZWRhdGE=\"}]}", string(bodyBytes))
assert.Equal(t, "{\"model\":\"test\",\"stream\":false,\"system_prompt\":\"What's in this image?\",\"input\":[{\"type\":\"image\",\"data_url\":\"data:image/png;base64,ZmFrZWRhdGE=\"}]}", string(bodyBytes))
}
func TestLMStudioLargeLanguageModelAdapter_ParseTextualResponse_ValidJsonResponse(t *testing.T) {