Skip to content

Commit 7c12697

Browse files
committed
feat: add support for openai
1 parent a47ff73 commit 7c12697

File tree

8 files changed

+324
-186
lines changed

8 files changed

+324
-186
lines changed

Diff for: README.md

+22-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ exif-ai -i example.jpeg -a ollama
3333

3434
Required options:
3535

36-
- `-a, --api-provider <value>`: Name of the AI provider to use (`ollama` for Ollama, `zhipu` for ZhipuAI, `google` for Google Gemini, `coze_bot` for Coze Bot).
36+
- `-a, --api-provider <value>`: Name of the AI provider to use (`ollama` for Ollama, `zhipu` for ZhipuAI, `google` for Google Gemini, `coze_bot` for Coze Bot, `openai` for OpenAI).
3737

3838
Optional options:
3939

@@ -133,21 +133,36 @@ Please ensure that you securely manage your API keys. Do not expose them in publ
133133

134134
## API Providers
135135

136-
Exif AI relies on API providers to generate image descriptions and tags. Currently, we support four providers: ZhipuAI, Ollama, Google Gemini and Coze.
136+
Exif AI is designed to leverage various API providers for generating image descriptions and tags. We currently support five prominent providers, each offering unique capabilities and integration options. Below is a summary of the supported providers, including details on their requirements and features.
137137

138138
### Supported Providers
139139

140-
- ZhipuAI: A leading AI service provider. Requires an API key.
141-
- Ollama: A local AI service that runs on your machine, eliminating the need for an API key.
142-
- Google Gemini: A powerful AI service provided by Google.
143-
- Coze: Coze is a next-generation AI application and chatbot developing platform for everyone.
140+
- ZhipuAI: A cutting-edge AI service provider known for its advanced algorithms. Access to this service requires an API key.
141+
- Ollama: An innovative local AI service that operates directly on your machine. This option does not require an API key, offering a seamless and private experience.
142+
- Google Gemini: A robust AI service powered by Google, renowned for its high-quality image processing capabilities.
143+
- Coze: Coze is a state-of-the-art AI platform designed for everyone, enabling the development of next-generation applications and chatbots.
144+
- OpenAI: A preeminent AI service provider, recognized for its wide range of AI-powered tools and applications. Like ZhipuAI, it requires an API key for access.
144145

145146
### Custom Providers
146147

147-
You can also develop your own custom provider by implementing the provider interface. This allows you to integrate with other AI services or customize the description generation process.
148+
For users seeking to extend the functionality of Exif AI or integrate with additional AI services, we offer the flexibility to develop custom providers. By implementing the provider interface, you can create a custom provider to integrate with other AI services or tailor the image description generation process to your specific needs.
148149

149150
## Configuration
150151

152+
### OpenAI
153+
154+
To use [OpenAI](https://openai.com/), you need to set the API key. You can do this by setting an environment variable:
155+
156+
```bash
157+
export OPENAI_API_KEY=your_openai_api_key
158+
```
159+
160+
If you wish to use a custom API service provider that is compatible with the OpenAI API, you can set the `OPEN_API_BASEURL` environment variable to point to the desired endpoint.
161+
162+
```bash
163+
export OPEN_API_BASEURL=https://api.customprovider.com/v1
164+
```
165+
151166
### Zhipu AI
152167

153168
To use [ZhipuAI](https://open.bigmodel.cn/usercenter/apikeys), you need to set the API key. You can do this by setting an environment variable:

Diff for: README.zh-CN.md

+66-45
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
## 关于
66

7-
_Exif AI_ 是一个强大的命令行工具,旨在直接将AI生成的图像描述和/或标签写入图像文件的元数据。此工具利用先进的AI模型来分析图像内容并生成描述性元数据,从而提高图像的可用性和可搜索性
7+
_Exif AI_ 是一款功能强大的命令行工具,专为直接将AI生成的图像描述和/或标签写入图像文件的元数据而设计。该工具运用先进的AI模型来深入分析图像内容,并自动生成相应的描述性元数据,显著提升图像的检索效率和可用性
88

99
## 使用示例
1010

1111
### 命令行
1212

13-
#### 免安装
13+
#### 无需安装
1414

15-
如果您不想全局安装 Exif AI,可以使用 npx 命令直接运行。
15+
如果您不想全局安装 Exif AI,完全可以选择使用 npx 命令来直接运行它。这样操作非常简单:
1616

1717
```bash
1818
npx exif-ai -i example.jpeg -a ollama
1919
```
2020

21-
#### 安装版
21+
#### 全局安装版
2222

23-
如果您已经全局安装了 Exif AI,则可以直接从命令行运行它
23+
如果您已经将 Exif AI 全局安装到您的系统,那么您可以直接在命令行中直接调用它来使用
2424

2525
```bash
2626
exif-ai -i example.jpeg -a ollama
@@ -30,36 +30,41 @@ exif-ai -i example.jpeg -a ollama
3030

3131
必选项:
3232

33-
- `-a, --api-provider <value>`: 要使用的AI供应商名称`ollama`代表Ollama`zhipu`代表ZhipuAI`google`代表Google Gemini)
33+
- `-a, --api-provider <value>`: 选择要使用的AI供应商,请指定以下名称之一`ollama`对应Ollama`zhipu`对应ZhipuAI`google`对应Google Gemini`coze_bot`对应扣子bot,`openai`对应OpenAI
3434

3535
可选项:
3636

37-
- `-T, --tasks <tasks...>`: 要执行的任务列表(`description`代表生成描述,`tags`代表生成标签,`face`代表面部识别)。
38-
- `-i, --input <file>` : 要处理的图像文件
39-
- `-p, --description-prompt <text>`: 自定义AI供应商生成描述的提示。默认为通用的图像描述提示
40-
- `--tag-prompt <text>`: 自定义AI供应商生成标签的提示。默认为通用的图像标签提示
41-
- `-m, --model <name>`: 指定要使用的AI模型,如果AI供应商支持
42-
- `-t, --description-tags <tags...>`: 要写入描述的EXIF标签列表。默认为常见的描述标签。
43-
- `--tag-tags <tags...>`: 要写入标签的EXIF标签列表。默认为常见的标签。
44-
- `-v, --verbose`: 启用调试输出
45-
- `-d, --dry-run`: 预览AI生成的内容而不写入图像文件
46-
- `--exif-tool-write-args <args...>`: 用于写入元数据的ExifTool的额外参数
47-
- `--provider-args <args...>`: AI供应商的额外参数
48-
- `-w, --watch <path>`: 监视要处理的目录中的新文件
49-
- `--avoid-overwrite`: 如果文件中已经存在EXIF标签,则避免覆盖
50-
- `--ext <extensions...>`: 要监视的文件扩展名。只有具有这些扩展名的文件才会被处理
51-
- `--concurrency <number>`: 在监视模式下同时处理的文件数量
52-
- `--face-group-ids <group...>`: 要用于面部识别的面部组ID列表
37+
- `-T, --tasks <tasks...>`: 指定要执行的任务列表,支持的选项有`description`(生成描述)、`tag`(生成标签)和`face`(面部识别)。
38+
- `-i, --input <file>` : 指定要处理的图像文件路径
39+
- `-p, --description-prompt <text>`: 自定义AI供应商生成描述的提示语,默认使用通用的图像描述提示
40+
- `--tag-prompt <text>`: 自定义AI供应商生成标签的提示语,默认使用通用的图像标签提示
41+
- `-m, --model <name>`: 指定要使用的AI模型,如果AI供应商支持自定义模型
42+
- `-t, --description-tags <tags...>`: 指定要写入描述的EXIF标签名称列表,默认为常见的描述标签。
43+
- `--tag-tags <tags...>`: 指定要写入标签的EXIF标签名称列表,默认为常见的标签。
44+
- `-v, --verbose`: 启用详细输出,以便在调试时查看更多信息
45+
- `-d, --dry-run`: 进行dry run,预览AI生成的内容但不实际写入图像文件
46+
- `--exif-tool-write-args <args...>`: 提供额外的参数给ExifTool,用于写入元数据
47+
- `--provider-args <args...>`: 提供额外的参数给AI供应商
48+
- `-w, --watch <path>`: 监视指定路径中的新文件,当检测到新文件时自动处理
49+
- `--avoid-overwrite`: 如果文件中已存在EXIF标签,则避免覆盖现有标签
50+
- `--ext <extensions...>`: 指定要监视的文件扩展名,只有符合这些扩展名的文件会被处理
51+
- `--concurrency <number>`: 在监视模式下,同时处理的文件数量上限
52+
- `--face-group-ids <group...>`: 指定用于面部识别的面部组ID列表
5353

5454
示例用法:
5555

5656
```bash
5757
exif-ai -i example.jpg -a ollama -p "描述这张图片"
5858
```
5959

60-
### 作为库使用
60+
### 作为库集成
6161

62-
要在您的项目中将Exif AI用作库,请导入它并使用提供的函数:
62+
若要在您的项目中将Exif AI作为库使用,请按照以下步骤进行:
63+
64+
1. 导入Exif AI库。
65+
2. 使用库中提供的函数进行操作。
66+
67+
具体代码示例如下:
6368

6469
```typescript
6570
import { execute } from "exif-ai";
@@ -89,9 +94,9 @@ execute(options)
8994
});
9095
```
9196

92-
## 安装
97+
## 安装指南
9398

94-
要全局安装 Exif AI,请使用以下命令
99+
要全局安装 Exif AI,请执行以下命令
95100

96101
```bash
97102
npm install -g exif-ai
@@ -101,17 +106,17 @@ npm install -g exif-ai
101106

102107
### 生成描述
103108

104-
`description`任务使用AI供应商生成图像的描述。该描述将被写入在`descriptionTags`
109+
`description`任务利用 AI 供应商生成图像的描述性文本。生成的描述将自动写入到指定的`descriptionTags`EXIF 标签中
105110

106111
### 生成标签
107112

108-
`tags`任务使用AI供应商生成图像的标签。标签将被写入在`tagTags`
113+
`tags`任务通过 AI 供应商为图像创建标签。这些标签将被记录在`tagTags`定义的 EXIF 标签里
109114

110115
### 面部识别
111116

112-
`face`任务使用腾讯云API在图像上执行面部识别。面部识别结果将写入在`tagTags`中定义的EXIF标签
117+
`face`任务利用腾讯云的 API 在图像上进行面部识别。识别结果将被记录在`tagTags`中指定的 EXIF 标签里
113118

114-
目前,`face`任务需要腾讯云API密钥,并且需要腾讯云人脸识别服务。如果您没有腾讯云账户,请先注册一个账户并启用人脸识别服务
119+
目前,`face`任务需要配置腾讯云 API 密钥,并且您必须已经开通了腾讯云的人脸识别服务。如果您尚未拥有腾讯云账户,请先注册并开通相关服务
115120

116121
```bash
117122
export TENCENTCLOUD_SECRET_ID=your_tencentcloud_secret_id
@@ -124,55 +129,69 @@ export TENCENTCLOUD_SECRET_KEY=your_tencentcloud_secret_key
124129

125130
## API供应商
126131

127-
Exif AI依赖于API供应商来生成图像描述和标签。目前,我们支持三个供应商:ZhipuAI、Ollama和Google Gemini
132+
Exif AI旨在利用各种API供应商来生成图像描述和标签。我们目前支持五个主流的供应商,每个供应商都提供独特的功能和集成选项。以下是支持供应商的摘要,包括它们的要求和功能详情
128133

129134
### 支持的供应商
130135

131-
- ZhipuAI:领先的AI服务供应商。需要API密钥。
132-
- Ollama:在您的机器上运行的本地AI服务,无需API密钥。
133-
- Google Gemini:由Google提供的强大AI服务。
134-
- Coze: 扣子是新一代 AI 大模型智能体开发平台。您可以使用API来调用扣子的bot或工作流。
136+
- ZhipuAI:一家以先进算法著称的尖端AI服务供应商。访问此服务需要API密钥。
137+
- Ollama:一种创新的本地AI服务,直接在您的机器上运行。此选项不需要API密钥,提供无缝且私密的体验。
138+
- Google Gemini:由Google提供支持的强大AI服务,以其高质量的图像处理能力而闻名。
139+
- Coze: 扣子是新一代AI大模型智能体开发平台。您可以使用API来调用扣子的bot或工作流。
140+
- OpenAI:一家领先的AI服务供应商,以其广泛的AI工具和应用而闻名。与ZhipuAI一样,它需要API密钥才能访问。
135141

136142
### 自定义供应商
137143

138-
您还可以通过实现供应商接口来开发您自己的自定义供应商。这允许您与其他AI服务集成或自定义描述生成过程
144+
对于寻求扩展Exif AI功能或与额外AI服务集成的用户,我们提供开发自定义供应商的灵活性。通过实现供应商接口,您可以创建自定义供应商以集成其他AI服务,或根据您的特定需求定制图像描述生成过程
139145

140146
## 配置
141147

148+
## OpenAI
149+
150+
要使用 OpenAI,您需要配置 API 密钥。您可以通过以下步骤设置环境变量:
151+
152+
```bash
153+
export OPENAI_API_KEY=your_openai_api_key
154+
```
155+
156+
如果您需要使用与 OpenAI API 兼容的自定义 API 服务,可以设置 `OPEN_API_BASEURL` 环境变量,指向所需的 API 端点:
157+
158+
```bash
159+
export OPEN_API_BASEURL=https://api.example.com
160+
```
161+
142162
### 智谱AI
143163

144-
要使用[智谱AI](https://open.bigmodel.cn/usercenter/apikeys)您需要设置API密钥。您可以通过设置环境变量来完成此操作
164+
要使用[智谱AI](https://open.bigmodel.cn/usercenter/apikeys)您需要设置 API 密钥。通过以下命令设置环境变量
145165

146166
```bash
147167
export ZHIPUAI_API_KEY=your_zhipuai_api_key
148168
```
149169

150-
如果你还没有智谱AI的API密钥,请[在此](https://www.bigmodel.cn/invite?icode=INWAHJuWBFUp07JYI6oBveZLO2QH3C0EBTSr%2BArzMw4%3D)注册并获取API密钥
170+
如果您还没有智谱AI的 API 密钥,可以前往[智谱AI官网](https://www.bigmodel.cn/invite?icode=INWAHJuWBFUp07JYI6oBveZLO2QH3C0EBTSr%2BArzMw4%3D)注册并获取
151171

152172
### Google Gemini
153173

154-
要使用[Google Gemini](https://ai.google.dev/),您需要设置API密钥。您可以通过设置环境变量来完成此操作
174+
使用[Google Gemini](https://ai.google.dev/)时,您需要设置 API 密钥。以下是设置环境变量的命令
155175

156176
```bash
157177
export API_KEY=your_google_api_key
158178
```
159179

160180
### Coze
161181

162-
要使用[Coze](https://www.coze.com/) Bot,您需要设置API密钥。您可以通过设置环境变量来完成此操作
182+
要使用[Coze](https://www.coze.com/) Bot,您需要设置 API 密钥。设置环境变量的命令如下
163183

164184
```bash
165185
export COZE_API_KEY=your_coze_api_key
166186
```
167187

168-
在中国地区使用Coze时,请按照以下方式配置端点设置
188+
在中国大陆地区使用 Coze 时,请确保配置正确的端点设置
169189

170190
```bash
171191
export COZE_ENDPOINT=https://api.coze.cn
172192
```
173193

174-
在Coze中,`model`参数对应于bot的id。要使用Coze API进行交互,请使用以下命令格式:
175-
194+
与 Coze API 交互时,您可以使用以下命令格式,其中 `-m` 参数指定了 bot 的 id:
176195

177196
```bash
178197
exif-ai -a coze_bot -i image.jpg -m 7402199305639034921
@@ -182,14 +201,16 @@ exif-ai -a coze_bot -i image.jpg -m 7402199305639034921
182201

183202
### Ollama
184203

185-
Ollama在本地运行,不需要API密钥。请确保Ollama已安装在您的机器上并正确配置。有关安装和设置说明,请参考[Ollama](https://github.com/ollama/ollama)
204+
Ollama 在本地运行,因此不需要 API 密钥。请确保已正确安装和配置 Ollama。更多安装和设置信息,请参阅[Ollama](https://github.com/ollama/ollama)的官方文档。
186205

187-
要使用远程Ollama服务,您可以在`providerArgs`中定义URL
206+
若要使用远程 Ollama 服务,您可以在`providerArgs`中指定服务 URL
188207

189208
```bash
190209
exif-ai --providerArgs "http://ollama.example.com:8080" -a ollama -i image.jpg
191210
```
192211

212+
在使用库集成时,`providerArgs`可以这样设置:
213+
193214
```js
194215
providerArgs: ["http://ollama.example.com:8080"],
195216
```

0 commit comments

Comments
 (0)