From bfe3a3e5e696fc1d0aa9cab721f4952d5c61d826 Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 5 Aug 2023 02:24:15 +0100 Subject: [PATCH] Update README.MD --- README.MD | 48 ++++++++++++++++++++++++++++++++++-------------- src/main.py | 12 ++++++------ 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/README.MD b/README.MD index 6b04ee3..db98b3f 100644 --- a/README.MD +++ b/README.MD @@ -1,4 +1,5 @@ # Free Chatbot API + This project implements a Python web API that offers free access to three leading AI chatbots **ChatGPT**, **Google Bard**, and **Claude** through a single interface. **Key features:** @@ -7,14 +8,10 @@ This project implements a Python web API that offers free access to three leadin - Leverages the free web/browser versions of each AI service by managing cookies and sessions. Avoid costs of paid API access. - Simple API for text completion, question answering, and conversational queries. Integrate AI capabilities easily. - Lightweight Python server using FastAPI. Easily self-host locally or on your own infrastructure. -- Full support for streaming responses. - +- Full support for streaming responses.
-It's a personal project to use tools like [ShellGPT](https://github.com/TheR1D/shell_gpt) and others. - - - ✅ **_Google Bard_** integration available now. - ✅ **_Claude-2_** integration is also fully implemented and available. - ✅ **_ChatGPT_** integration is fully complete and available now. @@ -27,13 +24,13 @@ It's a personal project to use tools like [ShellGPT](https://github.com/TheR1D/s ## Upcoming Tasks -- Implement OpenAI endpoints for ChatGPT, (`v1/chat/completions`) -- Use proxy -- Use multiple accounts +- Implement OpenAI endpoints for ChatGPT, (`v1/chat/completions`) (The beta is now ready ⏳.) +- ~~Authorization is accomplished by logging into cloud.ai using a web browser, without requiring manual cookie configuration.~~ (Done ✅) -
+

-**NOTE:** This project is currently under active development. +**NOTE:** It's a personal project to use tools like [ShellGPT](https://github.com/TheR1D/shell_gpt) and others.
+This project is currently under active development.
@@ -45,6 +42,10 @@ First you need to add your tokens to the **`Config.conf`** file (see **[Configur
+**Note**: For Claude, all you need to do is [login](https://claude.ai/chats) to your account using your web browser. Alternatively, you can follow the instructions below. + +
+
@@ -78,6 +79,10 @@ which is your **Secure-1PSID** cookie, is included in the request. ([Screenshot] [![Image](assets/Claude-Thumb.jpg)](assets/Claude.jpg) +**Method 1:**
+For Claude, all you need to do is [login](https://claude.ai/chats) to your account using your web browser. (Firefox, Chrome, Safari) + +**Method 2:**
_`Claude:`_ You can get cookie from the browser's developer tools network tab ( see for any claude.ai requests check out cookie ,copy whole value ) or storage tab ( You can find cookie of claude.ai ,there will be four values ) ([Screenshot](assets/Claude.jpg)) 1. Login to [claude.ai/chats](https://claude.ai/chats) @@ -140,7 +145,7 @@ Then, add your token(s) to the **`Config.conf`** file. (see **[Configuration](#c ``` git clone https://github.com/Amm1rr/Free-Chatbot-API.git && cd Free-Chatbot-API -python -m .venv venv +python -m venv .venv source .venv/bin/activate @@ -155,15 +160,28 @@ pip install -r requirements.txt Navigate into the **`src`** directory, and run the web server using one of the methods below: ``` +cd src/ + +python main.py + + +-------------- or -------------- + + +cd src/ + uvicorn main:app --reload --port 8000 --- OR -- -python main.py +-------------- or -------------- + + +cd src/ --- OR -- +sudo chmod -x ./Run-Server.sh ./Run-Server.sh + ```
@@ -240,6 +258,8 @@ curl -X 'POST' \ [How to Find Your Free Tokens](#usage) +**Note**: Claude presents two authentication options - logging in through your browser or configuring Claude using the provided config file. + #### Config File Path: - Free-Chatbot-API\src\Config.conf diff --git a/src/main.py b/src/main.py index 1ebbec2..87f0e2a 100644 --- a/src/main.py +++ b/src/main.py @@ -5,6 +5,7 @@ import configparser import urllib.parse import itertools +import sys from anyio import Path import uvicorn import requests @@ -339,16 +340,16 @@ async def ask_claude(request: Request, message: Message): config.read(filenames=Free_Chatbot_API_CONFIG_PATH) cookie = config.get("Claude", "COOKIE", fallback=None) if not cookie: - answer = { + response_error = { f"Error": f"You should set 'COOKIE' in '{Free_Chatbot_API_CONFIG_FILE_NAME}' file for the Bard or send it as an argument." } - print(answer) - return answer + print(response_error) + return response_error # raise ValueError( # f"You should set 'COOKIE' in '{Free_Chatbot_API_CONFIG_FILE_NAME}' file for the Bard or send it as an argument." # ) - + cookie = f"sessionKey={cookie}" claude = Client(cookie) @@ -381,8 +382,6 @@ async def ask_claude(request: Request, message: Message): async def getChatGPTData(chat: Chatbot, message: MessageChatGPT): try: prev_text = "" - print(message.messages) - # for data in chat.ask(str(message.messages)): for data in chat.ask(str(message.messages[0])): # remove b' and ' at the beginning and end and ignore case # line = str(data)[2:-1] @@ -646,6 +645,7 @@ def get_claude_cookie(filter_text="sessionKey") -> str: return result + ######################################## #### #### ##### Main #####