mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-16 03:10:52 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56a05d2cce | ||
|
|
3e09bc9470 | ||
|
|
5ed79e5aa3 | ||
|
|
f38b78dbe6 |
25
README.md
25
README.md
@@ -486,6 +486,31 @@ Run the following command to start the server:
|
||||
docker run --rm -p 8317:8317 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest
|
||||
```
|
||||
|
||||
## Run with Docker Compose
|
||||
|
||||
1. Create a `config.yaml` from `config.example.yaml` and customize it.
|
||||
|
||||
2. Build and start the services using Docker Compose:
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
3. To authenticate with providers, run the login command inside the container:
|
||||
- **Gemini**: `docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --login`
|
||||
- **OpenAI (Codex)**: `docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --codex-login`
|
||||
- **Claude**: `docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --claude-login`
|
||||
- **Qwen**: `docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --qwen-login`
|
||||
|
||||
4. To view the server logs:
|
||||
```bash
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
5. To stop the application:
|
||||
```bash
|
||||
docker compose down
|
||||
```
|
||||
|
||||
## Management API
|
||||
|
||||
see [MANAGEMENT_API.md](MANAGEMENT_API.md)
|
||||
|
||||
25
README_CN.md
25
README_CN.md
@@ -499,6 +499,31 @@ docker run -it -rm -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /pat
|
||||
docker run --rm -p 8317:8317 -v /path/to/your/config.yaml:/CLIProxyAPI/config.yaml -v /path/to/your/auth-dir:/root/.cli-proxy-api eceasy/cli-proxy-api:latest
|
||||
```
|
||||
|
||||
## 使用 Docker Compose 运行
|
||||
|
||||
1. 从 `config.example.yaml` 创建一个 `config.yaml` 文件并进行自定义。
|
||||
|
||||
2. 使用 Docker Compose 构建并启动服务:
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
3. 要在容器内运行登录命令进行身份验证:
|
||||
- **Gemini**: `docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --login`
|
||||
- **OpenAI (Codex)**: `docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --codex-login`
|
||||
- **Claude**: `docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --claude-login`
|
||||
- **Qwen**: `docker compose exec cli-proxy-api /CLIProxyAPI/CLIProxyAPI -no-browser --qwen-login`
|
||||
|
||||
4. 查看服务器日志:
|
||||
```bash
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
5. 停止应用程序:
|
||||
```bash
|
||||
docker compose down
|
||||
```
|
||||
|
||||
## 管理 API 文档
|
||||
|
||||
请参见 [MANAGEMENT_API_CN.md](MANAGEMENT_API_CN.md)
|
||||
|
||||
@@ -7,6 +7,9 @@ services:
|
||||
container_name: cli-proxy-api
|
||||
ports:
|
||||
- "8317:8317"
|
||||
- "8085:8085"
|
||||
- "1455:1455"
|
||||
- "54545:54545"
|
||||
volumes:
|
||||
- ./config.yaml:/CLIProxyAPI/config.yaml
|
||||
- ./auths:/root/.cli-proxy-api
|
||||
|
||||
@@ -38,8 +38,9 @@ const (
|
||||
|
||||
var (
|
||||
previewModels = map[string][]string{
|
||||
"gemini-2.5-pro": {"gemini-2.5-pro-preview-05-06", "gemini-2.5-pro-preview-06-05"},
|
||||
"gemini-2.5-flash": {"gemini-2.5-flash-preview-04-17", "gemini-2.5-flash-preview-05-20"},
|
||||
"gemini-2.5-pro": {"gemini-2.5-pro-preview-05-06", "gemini-2.5-pro-preview-06-05"},
|
||||
"gemini-2.5-flash": {"gemini-2.5-flash-preview-04-17", "gemini-2.5-flash-preview-05-20"},
|
||||
"gemini-2.5-flash-lite": {"gemini-2.5-flash-lite-preview-06-17"},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -99,6 +100,7 @@ func (c *GeminiCLIClient) CanProvideModel(modelName string) bool {
|
||||
models := []string{
|
||||
"gemini-2.5-pro",
|
||||
"gemini-2.5-flash",
|
||||
"gemini-2.5-flash-lite",
|
||||
}
|
||||
return util.InArray(models, modelName)
|
||||
}
|
||||
|
||||
@@ -130,6 +130,20 @@ func GetGeminiCLIModels() []*ModelInfo {
|
||||
OutputTokenLimit: 65536,
|
||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||
},
|
||||
{
|
||||
ID: "gemini-2.5-flash-lite",
|
||||
Object: "model",
|
||||
Created: time.Now().Unix(),
|
||||
OwnedBy: "google",
|
||||
Type: "gemini",
|
||||
Name: "models/gemini-2.5-flash-lite",
|
||||
Version: "2.5",
|
||||
DisplayName: "Gemini 2.5 Flash Lite",
|
||||
Description: "Our smallest and most cost effective model, built for at scale usage.",
|
||||
InputTokenLimit: 1048576,
|
||||
OutputTokenLimit: 65536,
|
||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ type Watcher struct {
|
||||
clientsMutex sync.RWMutex
|
||||
reloadCallback func(map[string]interfaces.Client, *config.Config)
|
||||
watcher *fsnotify.Watcher
|
||||
eventTimes map[string]time.Time
|
||||
eventMutex sync.Mutex
|
||||
}
|
||||
|
||||
// NewWatcher creates a new file watcher instance
|
||||
@@ -54,6 +56,7 @@ func NewWatcher(configPath, authDir string, reloadCallback func(map[string]inter
|
||||
reloadCallback: reloadCallback,
|
||||
watcher: watcher,
|
||||
clients: make(map[string]interfaces.Client),
|
||||
eventTimes: make(map[string]time.Time),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -123,6 +126,16 @@ func (w *Watcher) handleEvent(event fsnotify.Event) {
|
||||
now := time.Now()
|
||||
log.Debugf("file system event detected: %s %s", event.Op.String(), event.Name)
|
||||
|
||||
// Debounce logic to prevent rapid reloads
|
||||
w.eventMutex.Lock()
|
||||
if lastTime, ok := w.eventTimes[event.Name]; ok && now.Sub(lastTime) < 500*time.Millisecond {
|
||||
log.Debugf("debouncing event for %s", event.Name)
|
||||
w.eventMutex.Unlock()
|
||||
return
|
||||
}
|
||||
w.eventTimes[event.Name] = now
|
||||
w.eventMutex.Unlock()
|
||||
|
||||
// Handle config file changes
|
||||
if event.Name == w.configPath && (event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Create == fsnotify.Create) {
|
||||
log.Infof("config file changed, reloading: %s", w.configPath)
|
||||
|
||||
Reference in New Issue
Block a user