Giter VIP home page Giter VIP logo

silly-tavern-temp-proxy's Introduction

Chlamydomonos的酒馆临时SGP Claude3代理

这是一个反向代理服务端,用于把Sourcegraph Cody的Claude 3模型接口转换为酒馆可用的OpenAI格式。

用法

  • 保证电脑上有Node.js
  • 编辑config.hjson,确定使用的模型以及代理运行的端口。
  • 运行start.bat启动服务端。(也可手动运行npm installnpm start启动)
  • 打开酒馆,设置Proxy Server URL为http://127.0.0.1:<你设置的端口>/v1,Proxy Password为你的SGP Access Token。
  • 设置聊天补全源为OpenAI,并勾选Show "External" models (provided by API),在模型列表中找到claude-3并选择。
  • 完成以上设置后,理论上应该可以正常使用。

注意事项

  • Sourcegraph的Claude 3接口有如下限制:

    • 请求的第一条必须是system prompt(即rolesystem的消息)。
    • System prompt只能是第一条消息,对话记录中不能有其他system prompt。
    • 从system prompt之后,每条消息的role必须由userassistant交替出现。
    • 请求的最后一条消息role必须是user

    因此,本反向代理采取以下方式处理酒馆发来的请求:

    • 如果请求没有system prompt,则插入一条空白的system prompt。
    • 如果请求的开头有多条system prompt,则把它们合并,之间用\n\n分隔。
    • 如果请求的其他部分有system prompt,把其role转为user
    • 如果请求中有连续多条由userassistant发送的消息,同样把它们合并,中间用\n\n分隔。
    • 如果请求的最后一条消息的roleassistant,则再追加一条roleuser的消息,内容固定为[Start conversation]
  • 目前已经发现了Sourcegraph对请求的一条过滤机制:若请求的system prompt不以You are Cody开头且请求中含有字符串查看上文后分两次回复,这条请求会被视为非法请求。 本反向代理目前采用此方法规避这条机制:一旦发现查看上文后分两次回复处于请求中,自动在system prompt的开头加上You are Cody

  • Sourcegraph仍然可能会对请求做出其他限制,本反向代理目前还未发现。如果服务端无法正常访问Sourcegraph服务器,会在控制台输出error calling sgp。此时可以在config.hjson中把verboseError设为true来查看更多信息。

silly-tavern-temp-proxy's People

Contributors

chlamydomonos 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.