Coco-AI 接入自定义数据源

忘机山人

发布于306天前
博客图片修整中,看不了可以先搜索公众号“忘机山人”看。

https://appstore.lazycat.cloud/#/shop/detail/xu.deploy.coco-ai


之前使用 Hugo Connector 接入和 hexo 和任意 Markdown,后来官方也支持了对于任意数据源的支持,主要是开放了这个接口:

![image-20250417194847718](https://raw.githubusercontent.com/cloudsmithy/picgo-imh/master/image-20250417194847718.png)

具体操作如下:



设置 - conntor - 新增,让输入名称和描述等信息,新建出来 conntor

![image-20250417194910829](https://raw.githubusercontent.com/cloudsmithy/picgo-imh/master/image-20250417194910829.png)

然后我们就能在数据源上的页面上看到刚刚添加的了 Customize Connector 了

![image-20250417195015291](https://raw.githubusercontent.com/cloudsmithy/picgo-imh/master/image-20250417195015291.png)

点开提示,给了一个 API

![image-20250417194847718](https://raw.githubusercontent.com/cloudsmithy/picgo-imh/master/image-20250417194847718.png)

然后我们去创建 token,如图

![image-20250417195602722](https://raw.githubusercontent.com/cloudsmithy/picgo-imh/master/image-20250417195602722.png)

我这边使用 Postman 进行设置

![](https://raw.githubusercontent.com/cloudsmithy/picgo-imh/master/image-20250417195729078.png)

如果你的请求没有带 token,就是这样的。

![image-20250417195729078](https://raw.githubusercontent.com/cloudsmithy/picgo-imh/master/image-20250417195729078.png)

转成代码的是这样的,当然也可以开发自己的 agent。

```python
import requests
import json

url = "http://localhost:9000/datasource/d00eeolvf2xxx/_doc"

payload = json.dumps({
  "title": "I am just a Coco doc that you can search",
  "summary": "Nothing but great start",
  "content": "Coco is a unified private search engien that you can trust.",
  "url": "http://coco.rs/",
  "icon": "default"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

评论

2
datadragonk302天前

很赞,请问这样的话,是不是可以直接接入miniflux的 api读取rss了?

忘机山人回复datadragonk299天前

新版本有rss的功能,我还没来得及移植

说点什么呢~
收藏
1
2
0