mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
fix(EX-0000): use chat completions API for DeepSeek
Some checks failed
CI / checks (push) Has been cancelled
Some checks failed
CI / checks (push) Has been cancelled
DeepSeek does not support the /responses endpoint. Switch to /v1/chat/completions which is compatible.
This commit is contained in:
parent
e94ad257b1
commit
05d4a31156
1 changed files with 10 additions and 7 deletions
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"github.com/openai/openai-go"
|
||||
"github.com/openai/openai-go/option"
|
||||
"github.com/openai/openai-go/responses"
|
||||
"github.com/openai/openai-go/shared"
|
||||
|
||||
"github.com/rjNemo/rentease/internal/service/booking"
|
||||
)
|
||||
|
|
@ -74,11 +74,15 @@ func (p *BookingAgentParser) Parse(rawContent string) (*booking.Booking, error)
|
|||
|
||||
ctx := context.Background()
|
||||
|
||||
prompt := p.systemPrompt + "\n" + rawContent
|
||||
|
||||
resp, err := p.llmClient.Responses.New(ctx, responses.ResponseNewParams{
|
||||
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String(prompt)},
|
||||
resp, err := p.llmClient.Chat.Completions.New(ctx, openai.ChatCompletionNewParams{
|
||||
Model: p.model,
|
||||
Messages: []openai.ChatCompletionMessageParamUnion{
|
||||
openai.SystemMessage(p.systemPrompt),
|
||||
openai.UserMessage(rawContent),
|
||||
},
|
||||
ResponseFormat: openai.ChatCompletionNewParamsResponseFormatUnion{
|
||||
OfJSONObject: &shared.ResponseFormatJSONObjectParam{},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error sending request to DeepSeek: %w", err)
|
||||
|
|
@ -88,8 +92,7 @@ func (p *BookingAgentParser) Parse(rawContent string) (*booking.Booking, error)
|
|||
Data ResponseData `json:"data"`
|
||||
}
|
||||
|
||||
// The LLM is instructed to return the JSON for ResponseData directly, so parse it
|
||||
err = json.Unmarshal([]byte(resp.OutputText()), &r)
|
||||
err = json.Unmarshal([]byte(resp.Choices[0].Message.Content), &r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding response from DeepSeek: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue