mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 06:57:35 +08:00
add missing stream field
This commit is contained in:
@@ -28,6 +28,7 @@ type LMStudioLargeLanguageModelAdapter struct {
|
|||||||
// LMStudioChatRequest defines the structure of LM Studio chat request
|
// LMStudioChatRequest defines the structure of LM Studio chat request
|
||||||
type LMStudioChatRequest struct {
|
type LMStudioChatRequest struct {
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
|
Stream bool `json:"stream"`
|
||||||
SystemPrompt string `json:"system_prompt,omitempty"`
|
SystemPrompt string `json:"system_prompt,omitempty"`
|
||||||
Input []*LMStudioChatRequestInput `json:"input"`
|
Input []*LMStudioChatRequestInput `json:"input"`
|
||||||
}
|
}
|
||||||
@@ -100,8 +101,9 @@ func (p *LMStudioLargeLanguageModelAdapter) buildJsonRequestBody(c core.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
chatRequest := &LMStudioChatRequest{
|
chatRequest := &LMStudioChatRequest{
|
||||||
Model: p.LMStudioModelID,
|
Model: p.LMStudioModelID,
|
||||||
Input: make([]*LMStudioChatRequestInput, 0, 1),
|
Stream: request.Stream,
|
||||||
|
Input: make([]*LMStudioChatRequestInput, 0, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.SystemPrompt != "" {
|
if request.SystemPrompt != "" {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func TestLMStudioLargeLanguageModelAdapter_buildJsonRequestBody_TextualUserPromp
|
|||||||
err = json.Unmarshal(bodyBytes, &body)
|
err = json.Unmarshal(bodyBytes, &body)
|
||||||
assert.Nil(t, err)
|
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) {
|
func TestLMStudioLargeLanguageModelAdapter_buildJsonRequestBody_ImageUserPrompt(t *testing.T) {
|
||||||
@@ -49,7 +49,7 @@ func TestLMStudioLargeLanguageModelAdapter_buildJsonRequestBody_ImageUserPrompt(
|
|||||||
err = json.Unmarshal(bodyBytes, &body)
|
err = json.Unmarshal(bodyBytes, &body)
|
||||||
assert.Nil(t, err)
|
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) {
|
func TestLMStudioLargeLanguageModelAdapter_ParseTextualResponse_ValidJsonResponse(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user