Skip to content

Commit ca9bba3

Browse files
authored
refactor: standardize Gemini config to use project_id consistently (#241)
- Rename the configuration key gemini.project to gemini.project_id throughout documentation and code - Update all related code, flags, and validation to use projectID instead of project in the Gemini provider configuration Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 22675de commit ca9bba3

File tree

8 files changed

+35
-35
lines changed

8 files changed

+35
-35
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,14 @@ Update the following parameters in your config file.
245245

246246
#### Configuration Options
247247

248-
| Option | Description | Example Value | Required | Default |
249-
| ------------------- | ------------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
250-
| **openai.provider** | Set to `gemini` to use Gemini provider | `gemini` | Yes | |
251-
| **gemini.api_key** | API key for Gemini or VertexAI | `xxxxxxx` | Yes | |
252-
| **gemini.model** | Model name (see [Gemini models][61]) | `gemini-2.0-flash` | Yes | |
253-
| **gemini.backend** | Gemini backend: `BackendGeminiAPI` (default, for Gemini API) or `BackendVertexAI` (for VertexAI) | `BackendGeminiAPI` | No | `BackendGeminiAPI` |
254-
| **gemini.project** | VertexAI project ID (required if using `BackendVertexAI`) | `my-gcp-project` | Cond. | |
255-
| **gemini.location** | VertexAI location (required if using `BackendVertexAI`) | `us-central1` | Cond. | |
248+
| Option | Description | Example Value | Required | Default |
249+
| --------------------- | ------------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
250+
| **openai.provider** | Set to `gemini` to use Gemini provider | `gemini` | Yes | |
251+
| **gemini.api_key** | API key for Gemini or VertexAI | `xxxxxxx` | Yes | |
252+
| **gemini.model** | Model name (see [Gemini models][61]) | `gemini-2.0-flash` | Yes | |
253+
| **gemini.backend** | Gemini backend: `BackendGeminiAPI` (default, for Gemini API) or `BackendVertexAI` (for VertexAI) | `BackendGeminiAPI` | No | `BackendGeminiAPI` |
254+
| **gemini.project_id** | VertexAI project ID (required if using `BackendVertexAI`) | `my-gcp-project` | Cond. | |
255+
| **gemini.location** | VertexAI location (required if using `BackendVertexAI`) | `us-central1` | Cond. | |
256256

257257
#### Example: Gemini API (default backend)
258258

@@ -269,7 +269,7 @@ codegpt config set gemini.api_key xxxxxxx
269269
codegpt config set openai.provider gemini
270270
codegpt config set openai.model gemini-2.0-flash
271271
codegpt config set gemini.backend BackendVertexAI
272-
codegpt config set gemini.project my-gcp-project
272+
codegpt config set gemini.project_id my-gcp-project
273273
codegpt config set gemini.location us-central1
274274
```
275275

README.zh-cn.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,14 @@ codegpt config set openai.model xxxxx-gpt-4o
233233

234234
#### 配置选项
235235

236-
| 选项 | 描述 | 示例值 | 是否必填 | 默认值 |
237-
| ------------------- | ------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
238-
| **openai.provider** | 设置为 `gemini` 以使用 Gemini 提供商 | `gemini` || |
239-
| **gemini.api_key** | Gemini 或 VertexAI 的 API key | `xxxxxxx` || |
240-
| **gemini.model** | 模型名称(参见 [Gemini 模型][61]| `gemini-2.0-flash` || |
241-
| **gemini.backend** | Gemini 后端:`BackendGeminiAPI`(默认,适用于 Gemini API)或 `BackendVertexAI`(VertexAI) | `BackendGeminiAPI` || `BackendGeminiAPI` |
242-
| **gemini.project** | VertexAI 项目 ID(如使用 `BackendVertexAI` 必填) | `my-gcp-project` | 条件必填 | |
243-
| **gemini.location** | VertexAI 区域(如使用 `BackendVertexAI` 必填) | `us-central1` | 条件必填 | |
236+
| 选项 | 描述 | 示例值 | 是否必填 | 默认值 |
237+
| --------------------- | ------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
238+
| **openai.provider** | 设置为 `gemini` 以使用 Gemini 提供商 | `gemini` || |
239+
| **gemini.api_key** | Gemini 或 VertexAI 的 API key | `xxxxxxx` || |
240+
| **gemini.model** | 模型名称(参见 [Gemini 模型][61]| `gemini-2.0-flash` || |
241+
| **gemini.backend** | Gemini 后端:`BackendGeminiAPI`(默认,适用于 Gemini API)或 `BackendVertexAI`(VertexAI) | `BackendGeminiAPI` || `BackendGeminiAPI` |
242+
| **gemini.project_id** | VertexAI 项目 ID(如使用 `BackendVertexAI` 必填) | `my-gcp-project` | 条件必填 | |
243+
| **gemini.location** | VertexAI 区域(如使用 `BackendVertexAI` 必填) | `us-central1` | 条件必填 | |
244244

245245
#### 示例:Gemini API(默认后端)
246246

@@ -257,7 +257,7 @@ codegpt config set openai.model gemini-2.0-flash
257257
codegpt config set openai.provider gemini
258258
codegpt config set openai.model gemini-1.5-pro-preview-0409
259259
codegpt config set gemini.backend BackendVertexAI
260-
codegpt config set gemini.project my-gcp-project
260+
codegpt config set gemini.project_id my-gcp-project
261261
codegpt config set gemini.location us-central1
262262
```
263263

README.zh-tw.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,14 @@ codegpt config set openai.model xxxxx-gpt-4o
244244

245245
#### 設定選項
246246

247-
| 選項 | 說明 | 範例值 | 必填 | 預設值 |
248-
| ------------------- | ------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
249-
| **openai.provider** | 設為 `gemini` 以使用 Gemini 提供者 | `gemini` || |
250-
| **gemini.api_key** | Gemini 或 VertexAI 的 API 金鑰 | `xxxxxxx` || |
251-
| **gemini.model** | 模型名稱(參見 [Gemini 模型][61]| `gemini-2.0-flash` || |
252-
| **gemini.backend** | Gemini 後端:`BackendGeminiAPI`(預設,適用於 Gemini API)或 `BackendVertexAI`(VertexAI) | `BackendGeminiAPI` || `BackendGeminiAPI` |
253-
| **gemini.project** | VertexAI 專案 ID(如使用 `BackendVertexAI` 必填) | `my-gcp-project` | 條件必填 | |
254-
| **gemini.location** | VertexAI 區域(如使用 `BackendVertexAI` 必填) | `us-central1` | 條件必填 | |
247+
| 選項 | 說明 | 範例值 | 必填 | 預設值 |
248+
| --------------------- | ------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
249+
| **openai.provider** | 設為 `gemini` 以使用 Gemini 提供者 | `gemini` || |
250+
| **gemini.api_key** | Gemini 或 VertexAI 的 API 金鑰 | `xxxxxxx` || |
251+
| **gemini.model** | 模型名稱(參見 [Gemini 模型][61]| `gemini-2.0-flash` || |
252+
| **gemini.backend** | Gemini 後端:`BackendGeminiAPI`(預設,適用於 Gemini API)或 `BackendVertexAI`(VertexAI) | `BackendGeminiAPI` || `BackendGeminiAPI` |
253+
| **gemini.project_id** | VertexAI 專案 ID(如使用 `BackendVertexAI` 必填) | `my-gcp-project` | 條件必填 | |
254+
| **gemini.location** | VertexAI 區域(如使用 `BackendVertexAI` 必填) | `us-central1` | 條件必填 | |
255255

256256
#### 範例:Gemini API(預設後端)
257257

@@ -268,7 +268,7 @@ codegpt config set openai.model gemini-2.0-flash
268268
codegpt config set openai.provider gemini
269269
codegpt config set openai.model gemini-1.5-pro-preview-0409
270270
codegpt config set gemini.backend BackendVertexAI
271-
codegpt config set gemini.project my-gcp-project
271+
codegpt config set gemini.project_id my-gcp-project
272272
codegpt config set gemini.location us-central1
273273
```
274274

cmd/config_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var availableKeys = map[string]string{
3737
"openai.frequency_penalty": "Parameter to reduce repetition by penalizing tokens based on their frequency",
3838
"openai.presence_penalty": "Parameter to encourage topic diversity by penalizing previously used tokens",
3939
"prompt.folder": "Directory path for custom prompt templates",
40-
"gemini.project": "VertexAI project for Gemini provider",
40+
"gemini.project_id": "VertexAI project for Gemini provider",
4141
"gemini.location": "VertexAI location for Gemini provider",
4242
"gemini.backend": "Gemini backend (BackendGeminiAPI or BackendVertexAI)",
4343
"gemini.api_key": "API key for Gemini provider",

cmd/config_set.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func init() {
3434
configSetCmd.Flags().StringP("api_version", "", "", availableKeys["openai.api_version"])
3535
configSetCmd.Flags().StringP("prompt_folder", "", "", availableKeys["prompt.folder"])
3636
// Gemini flags
37-
configSetCmd.Flags().String("gemini.project", "", availableKeys["gemini.project"])
37+
configSetCmd.Flags().String("gemini.project_id", "", availableKeys["gemini.project_id"])
3838
configSetCmd.Flags().String("gemini.location", "", availableKeys["gemini.location"])
3939
configSetCmd.Flags().String("gemini.backend", "BackendGeminiAPI", availableKeys["gemini.backend"])
4040
configSetCmd.Flags().String("gemini.api_key", "", availableKeys["gemini.api_key"])
@@ -58,7 +58,7 @@ func init() {
5858
_ = viper.BindPFlag("openai.headers", configSetCmd.Flags().Lookup("headers"))
5959
_ = viper.BindPFlag("openai.api_version", configSetCmd.Flags().Lookup("api_version"))
6060
_ = viper.BindPFlag("prompt.folder", configSetCmd.Flags().Lookup("prompt_folder"))
61-
_ = viper.BindPFlag("gemini.project", configSetCmd.Flags().Lookup("gemini.project"))
61+
_ = viper.BindPFlag("gemini.project_id", configSetCmd.Flags().Lookup("gemini.project_id"))
6262
_ = viper.BindPFlag("gemini.location", configSetCmd.Flags().Lookup("gemini.location"))
6363
_ = viper.BindPFlag("gemini.backend", configSetCmd.Flags().Lookup("gemini.backend"))
6464
_ = viper.BindPFlag("gemini.api_key", configSetCmd.Flags().Lookup("gemini.api_key"))

cmd/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func NewGemini(ctx context.Context) (*gemini.Client, error) {
4747
gemini.WithTemperature(float32(viper.GetFloat64("openai.temperature"))),
4848
gemini.WithTopP(float32(viper.GetFloat64("openai.top_p"))),
4949
gemini.WithBackend(viper.GetString("gemini.backend")),
50-
gemini.WithProject(viper.GetString("gemini.project")),
50+
gemini.WithProject(viper.GetString("gemini.project_id")),
5151
gemini.WithLocation(viper.GetString("gemini.location")),
5252
)
5353
}

provider/gemini/gemini.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func New(ctx context.Context, opts ...Option) (c *Client, err error) {
165165
clientConfig = &genai.ClientConfig{
166166
HTTPClient: httpClient,
167167
Backend: cfg.backend,
168-
Project: cfg.project,
168+
Project: cfg.projectID,
169169
Location: cfg.location,
170170
}
171171
case genai.BackendGeminiAPI, genai.BackendUnspecified:

provider/gemini/options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ type config struct {
8888
maxTokens int32
8989
temperature float32
9090
topP float32
91-
project string
91+
projectID string
9292
location string
9393
backend genai.Backend
9494
}
9595

9696
func (cfg *config) valid() error {
9797
if cfg.backend == genai.BackendVertexAI {
98-
if cfg.project == "" || cfg.location == "" {
98+
if cfg.projectID == "" || cfg.location == "" {
9999
return errorsMissingTokenOrProject
100100
}
101101
} else {
@@ -132,7 +132,7 @@ func WithBackend(val string) Option {
132132

133133
func WithProject(val string) Option {
134134
return optionFunc(func(c *config) {
135-
c.project = val
135+
c.projectID = val
136136
})
137137
}
138138

0 commit comments

Comments
 (0)