|
| 1 | +package fake |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + "github.com/go-deepseek/deepseek/request" |
| 7 | + "github.com/go-deepseek/deepseek/response" |
| 8 | +) |
| 9 | + |
| 10 | +type Callbacks struct { |
| 11 | + CallChatCompletionsChatCallback func(ctx context.Context, chatReq *request.ChatCompletionsRequest) (*response.ChatCompletionsResponse, error) |
| 12 | + CallChatCompletionsReasonerCallback func(ctx context.Context, chatReq *request.ChatCompletionsRequest) (*response.ChatCompletionsResponse, error) |
| 13 | + |
| 14 | + StreamChatCompletionsChatCallback func(ctx context.Context, chatReq *request.ChatCompletionsRequest) (response.StreamReader, error) |
| 15 | + StreamChatCompletionsReasonerCallback func(ctx context.Context, chatReq *request.ChatCompletionsRequest) (response.StreamReader, error) |
| 16 | + |
| 17 | + PingChatCompletionsCallback func(ctx context.Context, inputMessage string) (outputMessge string, err error) |
| 18 | +} |
| 19 | + |
| 20 | +type FakeCallbackClient struct { |
| 21 | + callbacks Callbacks |
| 22 | +} |
| 23 | + |
| 24 | +func NewFakeCallbackClient(callbacks Callbacks) *FakeCallbackClient { |
| 25 | + fc := &FakeCallbackClient{ |
| 26 | + callbacks: callbacks, |
| 27 | + } |
| 28 | + return fc |
| 29 | +} |
| 30 | + |
| 31 | +func (c *FakeCallbackClient) CallChatCompletionsChat(ctx context.Context, chatReq *request.ChatCompletionsRequest) (*response.ChatCompletionsResponse, error) { |
| 32 | + if c.callbacks.CallChatCompletionsChatCallback == nil { |
| 33 | + panic("err: CallChatCompletionsChatCallback is nil") |
| 34 | + } |
| 35 | + return c.callbacks.CallChatCompletionsChatCallback(ctx, chatReq) |
| 36 | +} |
| 37 | + |
| 38 | +func (c *FakeCallbackClient) CallChatCompletionsReasoner(ctx context.Context, chatReq *request.ChatCompletionsRequest) (*response.ChatCompletionsResponse, error) { |
| 39 | + if c.callbacks.CallChatCompletionsReasonerCallback == nil { |
| 40 | + panic("err: CallChatCompletionsReasonerCallback is nil") |
| 41 | + } |
| 42 | + return c.callbacks.CallChatCompletionsReasonerCallback(ctx, chatReq) |
| 43 | +} |
| 44 | + |
| 45 | +func (c *FakeCallbackClient) StreamChatCompletionsChat(ctx context.Context, chatReq *request.ChatCompletionsRequest) (response.StreamReader, error) { |
| 46 | + if c.callbacks.StreamChatCompletionsChatCallback == nil { |
| 47 | + panic("err: StreamChatCompletionsChatCallback is nil") |
| 48 | + } |
| 49 | + return c.callbacks.StreamChatCompletionsChatCallback(ctx, chatReq) |
| 50 | +} |
| 51 | + |
| 52 | +func (c *FakeCallbackClient) StreamChatCompletionsReasoner(ctx context.Context, chatReq *request.ChatCompletionsRequest) (response.StreamReader, error) { |
| 53 | + if c.callbacks.StreamChatCompletionsReasonerCallback == nil { |
| 54 | + panic("err: StreamChatCompletionsReasonerCallback is nil") |
| 55 | + } |
| 56 | + return c.callbacks.StreamChatCompletionsReasonerCallback(ctx, chatReq) |
| 57 | +} |
| 58 | + |
| 59 | +func (c *FakeCallbackClient) PingChatCompletions(ctx context.Context, inputMessage string) (outputMessge string, err error) { |
| 60 | + if c.callbacks.PingChatCompletionsCallback == nil { |
| 61 | + panic("err: PingChatCompletionsCallback is nil") |
| 62 | + } |
| 63 | + return c.callbacks.PingChatCompletionsCallback(ctx, inputMessage) |
| 64 | +} |
0 commit comments