Skip to content

Commit 1b06980

Browse files
author
linzehao
committed
docs(README): 添加 API 连接问题常见问答
- 新增 FAQ 部分解答 API连接相关问题 - 解释跨域问题 (CORS) 是导致连接失败的主要原因 - 提供 Ollama 连接问题的解决方案 - 介绍使用Vercel 代理和自部署 API 中转服务的方法 - 提醒使用 Vercel 代理可能触发的风险控制问题
1 parent bd1dab6 commit 1b06980

File tree

5 files changed

+69
-7
lines changed

5 files changed

+69
-7
lines changed

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Prompt Optimizer (提示词优化器) 🚀
22

3+
[English](README_EN.md) | [中文](README.md)
4+
35
<div align="center">
46

57
[![GitHub stars](https://img.shields.io/github/stars/linshenkx/prompt-optimizer)](https://github.com/linshenkx/prompt-optimizer/stargazers)
@@ -12,8 +14,6 @@
1214

1315
[在线体验](https://prompt.always200.com) | [安装指南](#快速开始) | [开发文档](dev.md) | [Chrome插件](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna)
1416

15-
[English](README_EN.md) | [中文](README.md)
16-
1717
</div>
1818

1919
## 📖 项目简介
@@ -125,6 +125,7 @@ pnpm dev:fresh # 完整重置并重新启动开发环境
125125
- [项目状态](docs/project-status.md) - 当前进度和计划
126126
- [产品需求](docs/prd.md) - 产品需求文档
127127

128+
128129
## Star History
129130

130131
<a href="https://star-history.com/#linshenkx/prompt-optimizer&Date">
@@ -135,6 +136,36 @@ pnpm dev:fresh # 完整重置并重新启动开发环境
135136
</picture>
136137
</a>
137138

139+
## ❓ 常见问题解答(FAQ)
140+
141+
### API连接问题
142+
143+
#### Q1: 为什么配置好API密钥后仍然无法连接到模型服务?
144+
**A**: 大多数连接失败是由**跨域问题**(CORS)导致的。由于本项目是纯前端应用,浏览器出于安全考虑会阻止直接访问不同源的API服务。模型服务如未正确配置CORS策略,会拒绝来自浏览器的直接请求。
145+
146+
#### Q2: 如何解决本地Ollama的连接问题?
147+
**A**: Ollama完全支持OpenAI标准接口,只需配置正确的跨域策略:
148+
1. 设置环境变量 `OLLAMA_ORIGINS=*` 允许任意来源的请求
149+
2. 如仍有问题,设置 `OLLAMA_HOST=0.0.0.0:11434` 监听任意IP地址
150+
151+
#### Q3: 如何解决商业API(如Nvidia的DS API、字节跳动的火山API)的跨域问题?
152+
**A**: 这些平台通常有严格的跨域限制,推荐以下解决方案:
153+
154+
1. **使用Vercel代理**(便捷方案)
155+
- 使用在线版本:[prompt.always200.com](https://prompt.always200.com)
156+
- 或自行部署到Vercel平台
157+
- 在模型设置中勾选"使用Vercel代理"选项
158+
- 请求流向:浏览器→Vercel→模型服务提供商
159+
160+
2. **使用自部署的API中转服务**(可靠方案)
161+
- 部署如OneAPI等开源API聚合/代理工具
162+
- 在设置中配置为自定义API端点
163+
- 请求流向:浏览器→中转服务→模型服务提供商
164+
165+
#### Q4: Vercel代理有什么缺点或风险?
166+
**A**: 使用Vercel代理可能会触发某些模型服务提供商的风控机制。部分厂商可能会将来自Vercel的请求判定为代理行为,从而限制或拒绝服务。如遇此问题,建议使用自部署的中转服务。
167+
168+
138169
## 🤝 参与贡献
139170

140171
1. Fork 本仓库

README_EN.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Prompt Optimizer 🚀
22

3+
[English](README_EN.md) | [中文](README.md)
4+
35
<div align="center">
46

57
[![GitHub stars](https://img.shields.io/github/stars/linshenkx/prompt-optimizer)](https://github.com/linshenkx/prompt-optimizer/stargazers)
@@ -12,8 +14,6 @@
1214

1315
[Live Demo](https://prompt.always200.com) | [Installation](#quick-start) | [Development Docs](dev.md) | [Chrome Extension](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna)
1416

15-
[English](README_EN.md) | [中文](README.md)
16-
1717
</div>
1818

1919
## 📖 Project Introduction
@@ -135,6 +135,35 @@ For detailed project status, see [Project Status Document](docs/project-status.m
135135
</picture>
136136
</a>
137137

138+
## ❓ Frequently Asked Questions (FAQ)
139+
140+
### API Connection Issues
141+
142+
#### Q1: Why can't I connect to the model service after configuring the API key?
143+
**A**: Most connection failures are caused by **Cross-Origin Resource Sharing (CORS)** issues. As this project is a pure frontend application, browsers block direct access to API services from different origins for security reasons. Model services will reject direct requests from browsers if CORS policies are not correctly configured.
144+
145+
#### Q2: How to solve Ollama connection issues?
146+
**A**: Ollama fully supports the OpenAI standard interface, just configure the correct CORS policy:
147+
1. Set environment variable `OLLAMA_ORIGINS=*` to allow requests from any origin
148+
2. If issues persist, set `OLLAMA_HOST=0.0.0.0:11434` to listen on any IP address
149+
150+
#### Q3: How to solve CORS issues with commercial APIs (such as Nvidia's DS API, ByteDance's Volcano API)?
151+
**A**: These platforms typically have strict CORS restrictions. Recommended solutions:
152+
153+
1. **Use Vercel Proxy** (Convenient solution)
154+
- Use the online version: [prompt.always200.com](https://prompt.always200.com)
155+
- Or deploy to your own Vercel platform
156+
- Check "Use Vercel Proxy" option in model settings
157+
- Request flow: Browser → Vercel → Model service provider
158+
159+
2. **Use self-deployed API proxy service** (Reliable solution)
160+
- Deploy open-source API aggregation/proxy tools like OneAPI
161+
- Configure as custom API endpoint in settings
162+
- Request flow: Browser → Proxy service → Model service provider
163+
164+
#### Q4: What are the drawbacks or risks of using Vercel proxy?
165+
**A**: Using Vercel proxy may trigger risk control mechanisms of some model service providers. Some vendors may identify requests from Vercel as proxy behavior, thereby limiting or denying service. If you encounter this issue, we recommend using a self-deployed proxy service.
166+
138167
## 🤝 Contributing
139168

140169
1. Fork the repository

packages/ui/src/components/ModelManager.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
/>
165165
<label :for="`vercel-proxy-${editingModel.key}`" class="text-sm font-medium theme-manager-text">
166166
{{ t('modelManager.useVercelProxy') }}
167+
<span class="cursor-help ml-1" :title="t('modelManager.useVercelProxyHint')">?</span>
167168
</label>
168169
</div>
169170
<div class="flex justify-end space-x-3 pt-4">
@@ -245,7 +246,8 @@
245246
class="w-4 h-4 text-purple-600 bg-black/20 border-purple-600/50 rounded focus:ring-purple-500/50"
246247
/>
247248
<label for="new-model-vercel-proxy" class="text-sm font-medium theme-manager-text">
248-
{{ t('modelManager.useVercelProxyHint') }}
249+
{{ t('modelManager.useVercelProxy') }}
250+
<span class="cursor-help ml-1" :title="t('modelManager.useVercelProxyHint')">?</span>
249251
</label>
250252
</div>
251253
<div class="flex justify-end space-x-3 pt-4">

packages/ui/src/i18n/locales/en-US.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default {
7979
clickToFetchModels: 'Click arrow to fetch model list',
8080
apiKey: 'API Key',
8181
useVercelProxy: 'Use Vercel Proxy',
82-
useVercelProxyHint: 'Using Vercel proxy can help resolve connection issues in certain regions',
82+
useVercelProxyHint: 'Using Vercel proxy can solve CORS issues, but may trigger risk control from some providers. Please use with caution',
8383
addModel: 'Add',
8484

8585
// Placeholders

packages/ui/src/i18n/locales/zh-CN.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default {
7979
clickToFetchModels: '点击箭头获取模型列表',
8080
apiKey: 'API密钥',
8181
useVercelProxy: '使用Vercel代理',
82-
useVercelProxyHint: '使用Vercel代理可以帮助解决某些地区的连接问题',
82+
useVercelProxyHint: '使用Vercel代理可以解决跨域问题,但可能触发部分厂商风控,请酌情使用',
8383
addModel: '添加',
8484

8585
// 占位符

0 commit comments

Comments
 (0)