Add mocked content field
This commit is contained in:
+9
-3
@@ -4,9 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.gorlug.de/code/ersteller"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"git.gorlug.de/code/ersteller"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ChatCompletionRequestResponseFormatType string
|
type ChatCompletionRequestResponseFormatType string
|
||||||
@@ -148,15 +149,20 @@ type MistralClient interface {
|
|||||||
CreateChatCompletion(req *ChatCompletionRequest) (*ChatCompletionResponse, error)
|
CreateChatCompletion(req *ChatCompletionRequest) (*ChatCompletionResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type MistralClientMock struct{}
|
type MistralClientMock struct {
|
||||||
|
MockedContent string
|
||||||
|
}
|
||||||
|
|
||||||
func (m MistralClientMock) CreateChatCompletion(req *ChatCompletionRequest) (*ChatCompletionResponse, error) {
|
func (m MistralClientMock) CreateChatCompletion(req *ChatCompletionRequest) (*ChatCompletionResponse, error) {
|
||||||
ersteller.Debug("mocking the mistral client")
|
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{
|
response := ChatCompletionResponse{
|
||||||
Choices: []ChatCompletionChoice{
|
Choices: []ChatCompletionChoice{
|
||||||
{
|
{
|
||||||
Message: Message{
|
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