You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(core): update signature of warp-openai (#1383)
* feat(core): update signature of warp-openai
* docs(site): update createOpenAIClient API documentation
Update the documentation for createOpenAIClient to reflect the new signature:
- Changed from factory function to wrapper function
- Now receives base OpenAI instance and options
- Returns Promise<OpenAI | undefined>
- Updated examples to show async wrapper pattern
- Removed unnecessary OpenAI import from examples
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: quanruzhuoxiu <[email protected]>
Co-authored-by: Claude <[email protected]>
-`dangerouslyAllowBrowser: boolean` - Always true in Midscene
52
+
- Other OpenAI configuration options
53
+
54
+
**Return Value:**
55
+
- Return the wrapped OpenAI client instance, or `undefined` to use the original instance
53
56
54
57
**Example (LangSmith Integration):**
55
58
```typescript
56
-
importOpenAIfrom'openai';
57
59
import { wrapOpenAI } from'langsmith/wrappers';
58
60
59
61
const agent =newPuppeteerAgent(page, {
60
-
createOpenAIClient: (config) => {
61
-
const openai =newOpenAI({
62
-
apiKey: config.openaiApiKey,
63
-
baseURL: config.openaiBaseURL,
64
-
});
65
-
62
+
createOpenAIClient: async (openai, options) => {
66
63
// Wrap with LangSmith for planning tasks
67
-
if (config.intent==='planning') {
64
+
if (options.baseURL?.includes('planning')) {
68
65
returnwrapOpenAI(openai, {
69
66
metadata: { task: 'planning' }
70
67
});
71
68
}
72
69
70
+
// Return the original client for other tasks
73
71
returnopenai;
74
72
}
75
73
});
76
74
```
77
75
78
-
**Note:**`createOpenAIClient` overrides the behavior of the `MIDSCENE_LANGSMITH_DEBUG` environment variable. If you provide a custom client factory function, you need to handle the integration of LangSmith or other observability tools yourself.
76
+
**Note:**`createOpenAIClient` overrides the behavior of the `MIDSCENE_LANGSMITH_DEBUG` environment variable. If you provide a custom client wrapper function, you need to handle the integration of LangSmith or other observability tools yourself.
0 commit comments