Coder Social home page Coder Social logo

enzo2333 / claude-free Goto Github PK

View Code? Open in Web Editor NEW
19.0 1.0 4.0 12 KB

This project can achieve the purpose of using claude-ai for free, can conduct multiple rounds of dialogue at the same time, and can completely replace the official claude-api.本项目可以达到免费使用claude-ai的目的,可以同时进行多轮对话,可以完全替代官方的claude-api。

Python 99.30% Batchfile 0.70%
claude claude-api claude-slack

claude-free's Introduction

Claude-free

English | 中文简体

The project took advantage of the claude service on slack and extracted it to be a perfect alternative to claude's official api service.

1.First you need to configure the config.py file. All you need to do is configure slack's token,claude's user id, and your channel_id. Whether channel_id is configured depends on whether you want to carry a custom channel_id on request. If channel_id is not configured, a channel_id must be passed in to the api requesting the message. If this parameter is specified, if channel_id is missing in the request, the specified channel_id is used by default. If channel_id in the request is not empty, the requested channel_id value is always used.

For instructions on how to sign up and configure parameters such as slack, you can refer to this video(PS: Chinese video): [SLACK CONFIG VIDEO]

However, in addition to the permissions in the video, users:read permissions need to be configured when configuring permissions, which is used to detect whether the configured claude_id exists. Summary:[channels:history,channels:read,channels:write,groups:history,groups:read,groups:write,chat:write, im:history, im:write, mpi,users:read]

channel_id should be the channel id, please do not use private chat, and please add claude to the channel.

WORKERS indicates the number of requests that can be processed at the same time. The value can be adjusted based on the actual situation.

Related links:

token Obtain: https://api.slack.com/

The API documentation: https://api.slack.com/methods

Websocket document: https://api.slack.com/apis/connections

2.Once you have configured config.py and installed python correctly, you can start the service by clicking start_service.bat, which will automatically install the dependencies and start.

Related interfaces:

  1. Send and receive replies:

URL: 127.0.0.1:8000/claude/send

REQUEST BODY:

{ "channel_id" : "", "conversation_key" : "", "message": "Write a story for me" }

channel_id is optional. It can send messages to different channels, or not send messages to the channels configured in config.py.

conversation_key represents the key of a conversation. If you want to start a new conversation, you can leave it blank. The conversation_key generated by the new conversation will be displayed in the response.

  1. Query the specified reply:

URL: 127.0.0.1:8000/claude/receive_reply

REQUEST BODY:

{ "channel_id" : "channel_id", "conversation_key" : "conversation_key", "message_key": "message_key" }

The parameter part is basically the same as that of interface 1. message_key can be obtained in the response of interface 1.

claude-free's People

Contributors

enzo2333 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

claude-free's Issues

127.0.0.1:8000/claude/send 接口没有返回回复内容,json数据解析失败

image

2023-08-05 23:04:20,139 - slack_sdk.web.base_client - DEBUG - Sending a request - url: https://www.slack.com/api/chat.postMessage, query_params: {}, body_params: {}, files: {}, json_body: {'channel': 'xxxxxxx', 'text': '<@xxxxxxx> 为我写个故事'}, headers: {'Content-Type': 'application/json;charset=utf-8', 'Authorization': '(redacted)', 'User-Agent': 'Python/3.10.11 slackclient/3.21.3 Windows/10'}
2023-08-05 23:04:21,048 - slack_sdk.web.base_client - DEBUG - Received the following response - status: 200, headers: {'date': 'Sat, 05 Aug 2023 15:04:22 GMT', 'server': 'Apache', 'vary': 'Accept-Encoding', 'x-slack-req-id': 'xxxxxxx', 'x-content-type-options': 'nosniff', 'x-xss-protection': '0', 'pragma': 'no-cache', 'cache-control': 'private, no-cache, no-store, must-revalidate', 'expires': 'Sat, 26 Jul 1997 05:00:00 GMT', 'content-type': 'application/json; charset=utf-8', 'x-accepted-oauth-scopes': 'chat:write', 'x-oauth-scopes': 'identify,channels:history,groups:history,im:history,mpim:history,channels:read,groups:read,im:read,mpim:read,users:read,channels:write,chat:write,groups:write,im:write,mpim:write', 'access-control-expose-headers': 'x-slack-req-id, retry-after', 'access-control-allow-headers': 'slack-route, x-slack-version-ts, x-b3-traceid, x-b3-spanid, x-b3-parentspanid, x-b3-sampled, x-b3-flags', 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload', 'x-slack-unique-id': 'xxxxxx', 'x-slack-backend': 'r', 'referrer-policy': 'no-referrer', 'access-control-allow-origin': '*', 'content-length': '852', 'via': '1.1 slack-prod.tinyspeck.com, envoy-www-iad-crutwtyo, envoy-edge-pdx-vubsnftl', 'x-envoy-upstream-service-time': '118', 'x-backend': 'main_normal main_canary_with_overflow main_control_with_overflow', 'x-server': 'slack-www-hhvm-main-iad-luxr', 'x-slack-shared-secret-outcome': 'no-match', 'x-edge-backend': 'envoy-www', 'x-slack-edge-shared-secret-outcome': 'no-match', 'connection': 'close'}, body: {"ok":true,"channel":"xxxxx","ts":"1691247862.795989","message":{"bot_id":"xxxxx","type":"message","text":"<@xxxx> \u4e3a\u6211\u5199\u4e2a\u6545\u4e8b","user":"xxxx","ts":"1691247862.795989","app_id":"xxxxx","blocks":[{"type":"rich_text","block_id":"nEo9","elements":[{"type":"rich_text_section","elements":[{"type":"user","user_id":"xxxx"},{"type":"text","text":" \u4e3a\u6211\u5199\u4e2a\u6545\u4e8b"}]}]}],"team":"xxxx","bot_profile":{"id":"xxxx","app_id":"xxxx","name":"test","icons":{"image_36":"https:\/\/a.slack-edge.com\/80588\/img\/plugins\/app\/bot_36.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/plugins\/app\/bot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/plugins\/app\/service_72.png"},"deleted":false,"updated":1691246209,"team_id":"xxxx"}}}
2023-08-05 23:04:31,054 - slack_sdk.web.base_client - DEBUG - Sending a request - url: https://www.slack.com/api/conversations.replies, query_params: {}, body_params: {'channel': 'xxxx', 'ts': '1691247862.795989', 'oldest': '1691247862.795989'}, files: {}, json_body: None, headers: {'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': '(redacted)', 'User-Agent': 'Python/3.10.11 slackclient/3.21.3 Windows/10'}
2023-08-05 23:04:31,869 - slack_sdk.web.base_client - DEBUG - Received the following response - status: 200, headers: {'date': 'Sat, 05 Aug 2023 15:04:33 GMT', 'server': 'Apache', 'vary': 'Accept-Encoding', 'x-slack-req-id': 'xxxxx', 'x-content-type-options': 'nosniff', 'x-xss-protection': '0', 'pragma': 'no-cache', 'cache-control': 'private, no-cache, no-store, must-revalidate', 'expires': 'Sat, 26 Jul 1997 05:00:00 GMT', 'content-type': 'application/json; charset=utf-8', 'x-accepted-oauth-scopes': 'channels:history,groups:history,mpim:history,im:history,read', 'x-oauth-scopes': 'identify,channels:history,groups:history,im:history,mpim:history,channels:read,groups:read,im:read,mpim:read,users:read,channels:write,chat:write,groups:write,im:write,mpim:write', 'access-control-expose-headers': 'x-slack-req-id, retry-after', 'access-control-allow-headers': 'slack-route, x-slack-version-ts, x-b3-traceid, x-b3-spanid, x-b3-parentspanid, x-b3-sampled, x-b3-flags', 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload', 'x-slack-unique-id': 'xxxx', 'x-slack-backend': 'r', 'referrer-policy': 'no-referrer', 'access-control-allow-origin': '*', 'content-length': '822', 'via': '1.1 slack-prod.tinyspeck.com, envoy-www-iad-dhreatko, envoy-edge-pdx-ozqjwpgy', 'x-envoy-upstream-service-time': '101', 'x-backend': 'main_normal main_canary_with_overflow main_control_with_overflow', 'x-server': 'slack-www-hhvm-main-iad-gmve', 'x-slack-shared-secret-outcome': 'no-match', 'x-edge-backend': 'envoy-www', 'x-slack-edge-shared-secret-outcome': 'no-match', 'connection': 'close'}, body: {"ok":true,"messages":[{"bot_id":"xxxx","type":"message","text":"<@xxxx> \u4e3a\u6211\u5199\u4e2a\u6545\u4e8b","user":"xxxx","ts":"1691247862.795989","app_id":"xxxx","blocks":[{"type":"rich_text","block_id":"wFH","elements":[{"type":"rich_text_section","elements":[{"type":"user","user_id":"xxxx"},{"type":"text","text":" \u4e3a\u6211\u5199\u4e2a\u6545\u4e8b"}]}]}],"team":"xxxx","bot_profile":{"id":"xxxx","deleted":false,"name":"test","updated":1691246209,"app_id":"xxxx","icons":{"image_36":"https:\/\/a.slack-edge.com\/80588\/img\/plugins\/app\/bot_36.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/plugins\/app\/bot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/plugins\/app\/service_72.png"},"team_id":"xxxx"}}],"has_more":false}
list index out of range
    await self.app(scope, receive, send)
  File "D:\GitHub_pro\AI-Vtuber\venv\lib\site-packages\starlette\routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "D:\GitHub_pro\AI-Vtuber\venv\lib\site-packages\starlette\routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "D:\GitHub_pro\AI-Vtuber\venv\lib\site-packages\starlette\routing.py", line 66, in app
    response = await func(request)
  File "D:\GitHub_pro\AI-Vtuber\venv\lib\site-packages\fastapi\routing.py", line 273, in app
    raw_response = await run_endpoint_function(
  File "D:\GitHub_pro\AI-Vtuber\venv\lib\site-packages\fastapi\routing.py", line 190, in run_endpoint_function
    return await dependant.call(**values)
  File "D:\GitHub_pro\AI-Vtuber\test\Claude-free\controller\claude_apis.py", line 17, in send
    return send_message(data)
  File "D:\GitHub_pro\AI-Vtuber\test\Claude-free\service\claude_service.py", line 7, in send_message
    conversation_key, message_key, message = client.send_message_and_get_reply_on_channel(channel_id=data.channel_id,
  File "D:\GitHub_pro\AI-Vtuber\test\Claude-free\ai_models\model.py", line 70, in send_message_and_get_reply_on_channel
    return ts, ts, self.get_reply(channel_id=channel_id, oldest_ts=ts, thread_ts=ts)
  File "D:\GitHub_pro\AI-Vtuber\test\Claude-free\ai_models\model.py", line 60, in get_reply
    raise RuntimeError("No reply for the time being!")
RuntimeError: No reply for the time being!

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.