Add mocked content field

This commit is contained in:
Achim Rohn
2025-12-08 23:41:47 +01:00
parent 049fefed75
commit dcb2cabc7c
+9 -3
View File
@@ -4,9 +4,10 @@ import (
"bytes"
"encoding/json"
"fmt"
"git.gorlug.de/code/ersteller"
"io"
"net/http"
"git.gorlug.de/code/ersteller"
)
type ChatCompletionRequestResponseFormatType string
@@ -148,15 +149,20 @@ type MistralClient interface {
CreateChatCompletion(req *ChatCompletionRequest) (*ChatCompletionResponse, error)
}
type MistralClientMock struct{}
type MistralClientMock struct {
MockedContent string
}
func (m MistralClientMock) CreateChatCompletion(req *ChatCompletionRequest) (*ChatCompletionResponse, error) {
ersteller.Debug("mocking the mistral client")
if m.MockedContent == "" {
m.MockedContent = `{"name":"Meetup app","description":"An app to make notes for meetups","entities":[{"name":"Meetup","fields":[{"name":"name","type":"string"},{"name":"description","type":"string","longText":true},{"name":"date","type":"time"}],"entities":[{"name":"Notes","fields":[{"name":"title","type":"string"},{"name":"description","type":"string","longText":true}]}]}]}`
}
response := ChatCompletionResponse{
Choices: []ChatCompletionChoice{
{
Message: Message{
Content: `{"name":"Meetup app","description":"An app to make notes for meetups","entities":[{"name":"Meetup","fields":[{"name":"name","type":"string"},{"name":"description","type":"string","longText":true},{"name":"date","type":"time"}],"entities":[{"name":"Notes","fields":[{"name":"title","type":"string"},{"name":"description","type":"string","longText":true}]}]}]}`,
Content: m.MockedContent,
},
},
},