GithubHelp home page GithubHelp logo

eerfree / deeplx-serverless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from legendleo/deeplx-serverless

0.0 0.0 0.0 5 KB

DeepLX Free API for Serverless

Home Page: https://deeplx-serverless-tau.vercel.app

License: MIT License

Shell 1.26% JavaScript 98.74%

deeplx-serverless's Introduction

DeepLX Serverless

DeepLX 免费翻译API腾讯云函数部署版,与原项目DeepLX的区别在于利用了云函数的请求IP不固定的特性,极大程度上避免了429请求太频繁报错

感谢原项目OwO-Network/DeepLX提供的灵感,这是本项目的坚实基础

Usage | 用法

Prerequisites | 你需要准备什么

  • 一台电脑或平板
  • 一个腾讯旗下的账号或者手机号

Deploy | 部署

https://cloud.tencent.com/ 注册账号

进入云函数控制台:https://console.cloud.tencent.com/scf/list

依次点击【新建】->【从头开始】,然后按照以下配置,没写出来的就不用管,使用默认设置

  • 函数类型:Web函数
  • 函数名称:deeplx(名字随便取)
  • 地域:任意(国内也可直连)
  • 运行环境:Nodejs 16.13(或者更高的版本)
  • 高级配置:
    • 内存:64M
    • 执行超时时间:60 秒
    • 请求多并发:5 并发(个人体验下来,2个都行)
  • 日志配置 -> 日志投递:启用(可以选择不开,开的话一个月应该几分钱)
  • 函数代码:本地上传zip包(点我下载 ZIP 包
  • 触发器配置(这里可能要创建一个新的触发器):
    • 默认触发器
    • 触发别名/版本:默认流量
    • 请求方法:ANY
    • 发布环境:发布
    • 鉴权方法:免鉴权

此时已部署完成,可以点击“完成”按钮,进入【函数管理】,点击【函数代码】,往下拉,找到【访问路径】并复制后续使用

How to use | 如何使用

建议搭配浏览器插件沉浸式翻译一同使用,使用的时候需要把访问路径里的 /release 部分替换为翻译路径translate

例如:https://service-aaaaa.gz.apigw.tencentcs.com/release/ 改为:https://service-aaaaa.gz.apigw.tencentcs.com/translate

请求示例:

curl --location 'https://service-aaaaa.gz.apigw.tencentcs.com/translate' \
--header 'Content-Type: application/json' \
--data '{
    "text": "你好,世界",
    "source_lang": "zh",
    "target_lang": "en"
}'

响应示例:

{
  "code": 200,
  "message": "success",
  "data": "Hello, world.",
  "source_lang": "zh",
  "target_lang": "en",
  "alternatives": ["Hello, World.", "Hello, world!", "Hi, world."]
}

沉浸式翻译设置

  1. 在浏览器上安装最新的 沉浸式翻译
  2. 点击左下角的 "开发者设置"。启用测试版实验功能。
  3. 翻译服务选中 DeepLX(beta)
  4. 设置 URL 为刚才获取的访问路径(需带translate)。

沉浸式翻译

自托管

尽管本项目是专为 serverless 适配的方案,但是也能使用自己提供服务器进行部署

git clone https://github.com/LegendLeo/deeplx-serverless
cd deeplx-serverless
npm install
npm run start

deeplx-serverless's People

Contributors

legendleo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.