Add mocked content field
This commit is contained in:
+9
-3
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user