对于Ai翻译功能实现的一些小思路
实现此功能所需要
- **DeepSeek API ** (提供不同语言的翻译能力)
- Supabase 账户(用作后端数据库处理)
- Supabase Edge Functions(作为后端API,调用DeepSeek)
- 前端 (你的博客)(监听用户请求,调用Supabase函数)
可选功能喵
可用Supabase建立一个表,将每一次的翻译结果缓存,以节省Token和提升速度。
由于我很懒(因为也没人看),所以我只叙述一下大概的方法吧。
安装完Supabase之后,可以在Supabase中建立一个数据库,以缓存每一次的翻译结果,
之后创建 Edge Funciton 编辑函数代码切记不要将 API 或 service_role key 直接写在代码中,可用supabase secrets set配置环境变量,最后只需在前端添加翻译功能即可喵
如果有疑问可以通过我的联系方式找到我喵
接下来对以下诗句测试一下翻译吧喵
The fountains mingle with the river
And the rivers with the ocean
The winds of heaven mix for ever
With a sweet emotion;
Nothing in the world is single;
All things by a law divine
In one spirit meet and mingle.
Why not I with thine?—
See the mountains kiss high heaven
And the waves clasp one another;
No sister-flower would be forgiven
If it disdained its brother;
And the sunlight clasps the earth
And the moonbeams kiss the sea:
What are all these kissings worth
If thou kiss not me?
所以~ 我喜欢你喵.宝宝,我喜欢你,我们要在一起~
说些什么吧!