Skip to content

Commit

Permalink
migrate baidu provider to v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
cr7258 committed Nov 20, 2024
1 parent 6efb310 commit 13dae0b
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 206 deletions.
10 changes: 9 additions & 1 deletion plugins/wasm-go/extensions/ai-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,15 @@ Groq 所对应的 `type` 为 `groq`。它并无特有的配置字段。

#### 文心一言(Baidu)

文心一言所对应的 `type``baidu`。它并无特有的配置字段。
文心一言所对应的 `type``baidu`。它特有的配置字段如下:

| 名称 | 数据类型 | 填写要求 | 默认值 | 描述 |
|--------------------|-----------------|------|-----|-----------------------------------------------------------|
| `baiduAccessKeyAndSecret` | array of string | 必填 | - | Baidu 的 Access Key 和 Secret Key,中间用 `:` 分隔,用于申请 apiToken。 |
| `baiduApiTokenServiceName` | string | 必填 | - | 请求刷新百度 apiToken 服务名称。 |
| `baiduApiTokenServiceHost` | string | 非必填 | - | 请求刷新百度 apiToken 服务域名,默认是 iam.bj.baidubce.com。 |
| `baiduApiTokenServicePort` | int64 | 非必填 | - | 请求刷新百度 apiToken 服务端口,默认是 443。 |


#### 360智脑

Expand Down
5 changes: 5 additions & 0 deletions plugins/wasm-go/extensions/ai-proxy/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func (c *PluginConfig) Complete(log wrapper.Log) error {
providerConfig := c.GetProviderConfig()
err = providerConfig.SetApiTokensFailover(log, c.activeProvider)

if handler, ok := c.activeProvider.(provider.TickFuncHandler); ok {
tickPeriod, tickFunc := handler.GetTickFunc(log)
wrapper.RegisteTickFunc(tickPeriod, tickFunc)
}

return err
}

Expand Down
Loading

0 comments on commit 13dae0b

Please sign in to comment.