zh-plus / openlrc

Transcribe and translate voice into LRC file using Whisper and LLMs (GPT, Claude, et,al). 使用whisper和LLM(GPT,Claude等)来转录、翻译你的音频为字幕文件。
https://zh-plus.github.io/openlrc/
MIT License
459 stars 33 forks source link

自定义base_url不能用 #36

Closed deng-cy closed 5 months ago

deng-cy commented 6 months ago

试了一下base_url={'openai': 'https://api.g4f.icu'} ,在chatbox.py prompt_tokens = response.usage.prompt_tokens 这一行报错,response里面的信息是

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="/logo.png" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#ffffff" />
    <meta
      name="description"
      content="OpenAI 接口聚合管理,支持多种渠道包括 Azure,可用于二次分发管理 key,仅单可执行文件,已打包好 Docker 镜像,一键部署,开箱即用"
    />
    <title>New API</title>
    <script type="module" crossorigin src="/assets/index-HizBlsaI.js"></script>
    <link rel="modulepreload" crossorigin href="/assets/react-core-CLwr57uy.js">
    <link rel="modulepreload" crossorigin href="/assets/semi-ui-Dcxzo4Qw.js">
    <link rel="modulepreload" crossorigin href="/assets/tools-B1TmcgKL.js">
    <link rel="modulepreload" crossorigin href="/assets/react-components-CR2YBNem.js">
    <link rel="modulepreload" crossorigin href="/assets/semantic-C63L1wvK.js">
    <link rel="stylesheet" crossorigin href="/assets/semi-ui-Bs66SFli.css">
    <link rel="stylesheet" crossorigin href="/assets/index-CF9WWvgQ.css">
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>

试了一下修改 json_mode=True 没有用

如果用{'anthropic': 'https://api.g4f.icu'} 会有另一个错误,显示 https://api.g4f.icu/v1/messages "HTTP/1.1 404 Not Found"

zh-plus commented 6 months ago

Replace https://api.g4f.icu with https://api.g4f.icu/v1 to fix the issue.

deng-cy commented 6 months ago

Thanks, OPENAI works, but ANTHROPIC gives HTTP Request: POST https://api.g4f.icu/v1/v1/messages "HTTP/1.1 404 Not Found"

zh-plus commented 6 months ago

The request for anthropic models to g4f.icu should also be routed through the OpenAI SDK. I'm still looking for an appropriate solution.

zh-plus commented 6 months ago

Install the lastest version from github: pip install git+https://github.com/zh-plus/openlrc

and route claude model into OpenAI SDK by chatbot_model='openai: claude-3-haiku-20240307'

Example:

lrcer = LRCer(chatbot_model='openai: claude-3-haiku-20240307',
              base_url_config={'openai': 'https://api.g4f.icu/v1/'})