Giter Club home page Giter Club logo

Comments (1)

XHXJ avatar XHXJ commented on August 19, 2024

你是自己编写了翻译代码吗?
你可以参考以下代码
ChatGptTranslationServiceImpl.java 翻译开始的实现代码
com.xhxj.jsongpttranslator.translation.TranslationModeSwitcher 策略模式的实现

gpt-translator/src/main/java/com/xhxj/jsongpttranslator/translation/mode 你可以在这个包下新建你的翻译实现逻辑分别实现:

    /**
     * 批量翻译
     * @param data
     */
    void batchTranslate(List<TranslationData> data);

    void translateOne(List<TranslationData> data);

    /**
     * 停止翻译
     */
    void stopTranslate();

批量翻译的逻辑和单条翻译的逻辑,停止的可以不用写可以参考:
com.xhxj.jsongpttranslator.translation.mode.ChatTranslationMode

如果你想限制每分钟调用速率请在你请求发送的地方使用:

            //限制每分钟的API调用
            apiLimiter.waitForApiCallAvailability(0);

如果你想修改翻译速率修改:
ApiLimiter.java

    private static int MAX_API_CALLS_PER_MINUTE = 3000; // 每分钟的API调用限制 (RPM)
    private static int MAX_TOKENS_PER_MINUTE = 300000; // 每分钟的令牌限制 (TPM)
    private static int MAX_REQUESTS_PER_SECOND = 2; // 每秒最大请求速率

from json-gpt-translator.

Related Issues (16)

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.