@@ -39,8 +39,10 @@ func main() {
3939 }
4040 defer client.Shutdown ()
4141
42- // All requests will now return: "This is a mock response from the Mocker plugin"
43- response , _ := client.ChatCompletionRequest (context.Background (), &schemas.BifrostChatRequest {
42+ // All chat and responses requests will now return: "This is a mock response from the Mocker plugin"
43+
44+ // Chat completion request
45+ chatResponse , _ := client.ChatCompletionRequest (context.Background (), &schemas.BifrostChatRequest {
4446 Provider: schemas.OpenAI ,
4547 Model: " gpt-4" ,
4648 Input: []schemas.ChatMessage {
@@ -52,6 +54,20 @@ func main() {
5254 },
5355 },
5456 })
57+
58+ // Responses request
59+ responsesResponse , _ := client.ResponsesRequest (context.Background (), &schemas.BifrostResponsesRequest {
60+ Provider: schemas.OpenAI ,
61+ Model: " gpt-4o" ,
62+ Input: []schemas.ResponsesMessage {
63+ {
64+ Role: bifrost.Ptr (schemas.ResponsesInputMessageRoleUser ),
65+ Content: &schemas.ResponsesMessageContent {
66+ ContentStr: bifrost.Ptr (" Hello!" ),
67+ },
68+ },
69+ },
70+ })
5571}
5672```
5773
@@ -86,6 +102,30 @@ plugin, err := mocker.NewMockerPlugin(mocker.MockerConfig{
86102})
87103```
88104
105+ ### Responses Request Example
106+
107+ The mocker plugin automatically handles both chat completion and responses requests with the same configuration:
108+
109+ ``` go
110+ // This rule will work for both ChatCompletionRequest and ResponsesRequest
111+ {
112+ Name : " universal-mock" ,
113+ Enabled : true ,
114+ Probability : 1.0 ,
115+ Conditions : mocker.Conditions {
116+ MessageRegex: stringPtr (" (?i).*hello.*" ),
117+ },
118+ Responses : []mocker.Response {
119+ {
120+ Type: mocker.ResponseTypeSuccess ,
121+ Content: &mocker.SuccessResponse {
122+ Message: " Hello! I'm a mock response that works for both request types." ,
123+ },
124+ },
125+ },
126+ }
127+ ```
128+
89129## Installation
90130
91131Add the plugin to your project:
@@ -137,6 +177,29 @@ config := mocker.MockerConfig{
137177}
138178```
139179
180+ ## Supported Request Types
181+
182+ The Mocker plugin supports the following Bifrost request types:
183+
184+ - ** Chat Completion Requests** (` ChatCompletionRequest ` ) - Standard chat-based interactions
185+ - ** Responses Requests** (` ResponsesRequest ` ) - OpenAI-compatible responses API format
186+ - ** Skip Context Key** - Use ` "skip-mocker" ` context key to bypass mocking per request
187+
188+ ### Skip Mocker for Specific Requests
189+
190+ You can skip the mocker plugin for specific requests by adding a context key:
191+
192+ ``` go
193+ import " github.com/maximhq/bifrost/core/schemas"
194+
195+ // Create context that skips mocker
196+ ctx := context.WithValue (context.Background (),
197+ schemas.BifrostContextKey (" skip-mocker" ), true )
198+
199+ // This request will bypass the mocker and go to the real provider
200+ response , err := client.ChatCompletionRequest (ctx, request)
201+ ```
202+
140203## Key Features
141204
142205### Template Variables
@@ -469,6 +532,27 @@ Response{
469532}
470533```
471534
535+ ### Skip Mocker Not Working
536+
537+ Ensure you're using the correct context key format:
538+
539+ ``` go
540+ // ✅ Correct
541+ ctx := context.WithValue (context.Background (),
542+ schemas.BifrostContextKey (" skip-mocker" ), true )
543+
544+ // ❌ Wrong
545+ ctx := context.WithValue (context.Background (), " skip-mocker" , true )
546+ ```
547+
548+ ### Responses Request Issues
549+
550+ If responses requests aren't being mocked:
551+
552+ 1 . Verify the plugin supports ` ResponsesRequest ` (version 1.2.13+)
553+ 2 . Check that your regex patterns match the message content
554+ 3 . Ensure the request type is ` schemas.ResponsesRequest `
555+
472556### Debug Mode
473557
474558Enable debug logging to troubleshoot:
0 commit comments