2024-10-31 15:31:37 +08:00
|
|
|
|
# 火山引擎AI能力
|
2024-10-02 17:28:33 +08:00
|
|
|
|
|
2024-10-31 15:31:37 +08:00
|
|
|
|
### 配置 Access Key ID & Secret Access Key
|
|
|
|
|
|
|
|
|
|
在火山引擎的[控制台中](https://console.volcengine.com/iam/keymanage/),获取Access Key ID & Secret Access Key(建议使用子账号)
|
|
|
|
|
|
|
|
|
|
将 AK 和 SK 以逗号分隔的形式填入 ai.yml 或 env.yml 中
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
ai:
|
|
|
|
|
huoshan:
|
|
|
|
|
apiKey: AK,SK
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
建议将 AK&SK 加密,使用工具[sskey](https://github.com/ssgo/tool)
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
sskey -e 'AK,SK'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
复制url base64编码后的字符串填入 ai.yml 或 env.yml 中
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 火山方舟大模型
|
|
|
|
|
|
|
|
|
|
在[控制台](https://console.volcengine.com/ark/)的在线推理中创建接入点,使用接入点ID(ep-开头)作为模型名称配置到chat中并赋予一个名称
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
ai:
|
|
|
|
|
huoshan:
|
|
|
|
|
chat:
|
|
|
|
|
fastAsk:
|
|
|
|
|
model: ep-20241030164919-wql26
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
调用时的代码为:
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
import co from 'apigo.cc/gojs/console'
|
|
|
|
|
import ai from 'apigo.cc/ai'
|
|
|
|
|
|
|
|
|
|
return ai.huoshan.fastAsk('用一句话介绍一下你的主人', co.info, {
|
|
|
|
|
systemPrompt: '你的主人叫张三,是个程序员'
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 图片生成
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
import co from 'apigo.cc/gojs/console'
|
|
|
|
|
import ai from 'apigo.cc/ai'
|
|
|
|
|
|
|
|
|
|
return ai.huoshan.makeImage({
|
|
|
|
|
prompt: '在山顶,一位美丽的主人,头戴精致帽子,优雅地坐在藤椅上,手中端着一杯香浓的咖啡,身旁是云雾缭绕的美景,阳光洒在她身上,仿佛一幅宁静而美好的画面'
|
|
|
|
|
})
|
|
|
|
|
```
|