Skip to content

Commit 46ffc1d

Browse files
quanruclaudeyuyutaotaoCopilot
authored
refactor(core): remove non-OpenAI SDK support and upgrade to OpenAI 6.x (#1325)
* refactor(core): remove non-OpenAI SDK support and upgrade to OpenAI 6.x This commit removes support for Anthropic SDK and Azure OpenAI, simplifying the codebase to use only the standard OpenAI SDK with OpenAI-style APIs. Changes: - Remove Anthropic SDK (@anthropic-ai/sdk) dependency - Remove Azure OpenAI specific code and @azure/identity dependency - Remove langsmith wrapper support - Remove proxy agent support (https-proxy-agent, socks-proxy-agent) - Upgrade OpenAI SDK from 4.81.0 to 6.3.0 - Simplify createChatClient function to only create standard OpenAI clients - Remove 'style' parameter from createChatClient return type - Remove all Anthropic-specific message handling code - Add openai 6.3.0 as devDependency to @midscene/shared Benefits: - Cleaner, more maintainable codebase - Reduced dependencies (removed 5 packages) - All AI providers can now be accessed through OpenAI-compatible APIs Breaking Changes: - Anthropic SDK mode no longer supported - Azure OpenAI specific configuration removed - MIDSCENE_LANGSMITH_DEBUG no longer supported - httpAgent/socksProxy removed from createChatClient 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor(core): model provider documentation and remove Azure and Anthropic configurations * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * feat(core): add proxy support for OpenAI client with HTTP and SOCKS configurations * feat(core): add qwen-vl specific configuration for high resolution images --------- Co-authored-by: Claude <[email protected]> Co-authored-by: yuyutaotao <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent c1a3398 commit 46ffc1d

File tree

16 files changed

+710
-1310
lines changed

16 files changed

+710
-1310
lines changed

apps/site/docs/en/model-provider.mdx

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Some advanced configs are also supported. Usually you don't need to use them.
4343

4444
| Name | Description |
4545
|------|-------------|
46-
| `OPENAI_USE_AZURE` | Optional. Set to "true" to use Azure OpenAI Service. See more details in the following section. |
4746
| `MIDSCENE_OPENAI_INIT_CONFIG_JSON` | Optional. Custom JSON config for OpenAI SDK initialization |
4847
| `MIDSCENE_OPENAI_HTTP_PROXY` | Optional. HTTP/HTTPS proxy configuration (e.g. `http://127.0.0.1:8080` or `https://proxy.example.com:8080`). This option has higher priority than `MIDSCENE_OPENAI_SOCKS_PROXY` |
4948
| `MIDSCENE_OPENAI_SOCKS_PROXY` | Optional. SOCKS proxy configuration (e.g. "socks5://127.0.0.1:1080") |
@@ -99,34 +98,6 @@ Import the dotenv module in your script. It will automatically read the environm
9998
import 'dotenv/config';
10099
```
101100

102-
## Using Azure OpenAI Service
103-
104-
There are some extra configs when using Azure OpenAI Service.
105-
106-
### Use ADT token provider
107-
108-
This mode cannot be used in Chrome extension.
109-
110-
```bash
111-
# this is always true when using Azure OpenAI Service
112-
export MIDSCENE_USE_AZURE_OPENAI=1
113-
114-
export MIDSCENE_AZURE_OPENAI_SCOPE="https://cognitiveservices.azure.com/.default"
115-
export AZURE_OPENAI_ENDPOINT="..."
116-
export AZURE_OPENAI_API_VERSION="2024-05-01-preview"
117-
export AZURE_OPENAI_DEPLOYMENT="gpt-4o"
118-
```
119-
120-
### Use keyless authentication
121-
122-
```bash
123-
export MIDSCENE_USE_AZURE_OPENAI=1
124-
export AZURE_OPENAI_ENDPOINT="..."
125-
export AZURE_OPENAI_KEY="..."
126-
export AZURE_OPENAI_API_VERSION="2024-05-01-preview"
127-
export AZURE_OPENAI_DEPLOYMENT="gpt-4o"
128-
```
129-
130101
## Set config by JavaScript
131102

132103
You can also override the config by javascript. Remember to call this before running Midscene codes.
@@ -188,18 +159,6 @@ export MIDSCENE_MODEL_NAME="ui-tars-72b-sft"
188159
export MIDSCENE_USE_VLM_UI_TARS=1
189160
```
190161

191-
## Example: config `claude-3-opus-20240229` from Anthropic
192-
193-
When configuring `MIDSCENE_USE_ANTHROPIC_SDK=1`, Midscene will use Anthropic SDK (`@anthropic-ai/sdk`) to call the model.
194-
195-
Configure the environment variables:
196-
197-
```bash
198-
export MIDSCENE_USE_ANTHROPIC_SDK=1
199-
export ANTHROPIC_API_KEY="....."
200-
export MIDSCENE_MODEL_NAME="claude-3-opus-20240229"
201-
```
202-
203162
## Example: config request headers (like for openrouter)
204163

205164
```bash

apps/site/docs/zh/model-provider.mdx

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Midscene 默认集成了 OpenAI SDK 调用 AI 服务。使用这个 SDK 限定
4646

4747
| 名称 | 描述 |
4848
|------|-------------|
49-
| `OPENAI_USE_AZURE` | 可选。设置为 "true" 以使用 Azure OpenAI Service。更多详情请参阅后文 |
5049
| `MIDSCENE_OPENAI_INIT_CONFIG_JSON` | 可选。OpenAI SDK 的初始化配置 JSON |
5150
| `MIDSCENE_OPENAI_HTTP_PROXY` | 可选。HTTP/HTTPS 代理配置 (如 `http://127.0.0.1:8080``https://proxy.example.com:8080`)。这个选项优先级高于 `MIDSCENE_OPENAI_SOCKS_PROXY` |
5251
| `MIDSCENE_OPENAI_SOCKS_PROXY` | 可选。SOCKS 代理配置 (如 "socks5://127.0.0.1:1080") |
@@ -102,32 +101,6 @@ OPENAI_API_KEY="sk-abcdefghijklmnopqrstuvwxyz"
102101
import 'dotenv/config';
103102
```
104103

105-
## 使用 Azure OpenAI 服务时的配置
106-
107-
### 使用 ADT token provider
108-
109-
此种模式无法运行在浏览器插件中。
110-
111-
```bash
112-
# 使用 Azure OpenAI 服务时,配置为 1
113-
export MIDSCENE_USE_AZURE_OPENAI=1
114-
115-
export MIDSCENE_AZURE_OPENAI_SCOPE="https://cognitiveservices.azure.com/.default"
116-
export AZURE_OPENAI_ENDPOINT="..."
117-
export AZURE_OPENAI_API_VERSION="2024-05-01-preview"
118-
export AZURE_OPENAI_DEPLOYMENT="gpt-4o"
119-
```
120-
121-
### 使用 keyless 模式
122-
123-
```bash
124-
export MIDSCENE_USE_AZURE_OPENAI=1
125-
export AZURE_OPENAI_ENDPOINT="..."
126-
export AZURE_OPENAI_KEY="..."
127-
export AZURE_OPENAI_API_VERSION="2024-05-01-preview"
128-
export AZURE_OPENAI_DEPLOYMENT="gpt-4o"
129-
```
130-
131104
## 使用 Javascript 配置 AI 服务
132105

133106
你也可以在运行 Midscene 代码之前,使用 Javascript 来配置 AI 服务。
@@ -186,17 +159,5 @@ export MIDSCENE_MODEL_NAME="ui-tars-72b-sft"
186159
export MIDSCENE_USE_VLM_UI_TARS=1
187160
```
188161

189-
## 示例:使用 Anthropic 的 `claude-3-opus-20240229` 模型
190-
191-
当配置 `MIDSCENE_USE_ANTHROPIC_SDK=1` 时,Midscene 会使用 Anthropic SDK (`@anthropic-ai/sdk`) 来调用模型。
192-
193-
配置环境变量:
194-
195-
```bash
196-
export MIDSCENE_USE_ANTHROPIC_SDK=1
197-
export ANTHROPIC_API_KEY="....."
198-
export MIDSCENE_MODEL_NAME="claude-3-opus-20240229"
199-
```
200-
201162

202163
<TroubleshootingLLMConnectivity />

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,14 @@
7272
"test:parse-action": "npm run test:ai -- tests/ai/parse-action.test.ts"
7373
},
7474
"dependencies": {
75-
"@anthropic-ai/sdk": "0.33.1",
76-
"@azure/identity": "4.5.0",
7775
"@langchain/core": "0.3.26",
7876
"@midscene/recorder": "workspace:*",
7977
"@midscene/shared": "workspace:*",
8078
"@ui-tars/action-parser": "1.2.3",
8179
"dotenv": "^16.4.5",
8280
"https-proxy-agent": "7.0.2",
8381
"jsonrepair": "3.12.0",
84-
"langsmith": "0.3.7",
85-
"openai": "4.81.0",
82+
"openai": "6.3.0",
8683
"socks-proxy-agent": "8.0.4",
8784
"zod": "3.24.3",
8885
"semver": "7.5.2",

0 commit comments

Comments
 (0)