summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-26 21:45:53 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-26 21:45:53 +0100
commitfd92918b77e36f83a8b7a59469df35f3f23a48f1 (patch)
tree732d16b41c991c22b17683ca88e68aa62ddef834
parentNo arkose token and .har files (diff)
downloadgpt4free-fd92918b77e36f83a8b7a59469df35f3f23a48f1.tar
gpt4free-fd92918b77e36f83a8b7a59469df35f3f23a48f1.tar.gz
gpt4free-fd92918b77e36f83a8b7a59469df35f3f23a48f1.tar.bz2
gpt4free-fd92918b77e36f83a8b7a59469df35f3f23a48f1.tar.lz
gpt4free-fd92918b77e36f83a8b7a59469df35f3f23a48f1.tar.xz
gpt4free-fd92918b77e36f83a8b7a59469df35f3f23a48f1.tar.zst
gpt4free-fd92918b77e36f83a8b7a59469df35f3f23a48f1.zip
-rw-r--r--.gitignore3
-rw-r--r--README.md35
-rw-r--r--docker/Dockerfile9
-rw-r--r--g4f/Provider/needs_auth/OpenaiChat.py2
-rw-r--r--g4f/Provider/openai/har_file.py4
-rw-r--r--hardir/.gitkeep0
6 files changed, 38 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index 71d27a86..a4c228ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,4 +53,5 @@ info.txt
local.py
*.gguf
image.py
-.buildozer \ No newline at end of file
+.buildozer
+hardir \ No newline at end of file
diff --git a/README.md b/README.md
index 8c7662dc..d3656463 100644
--- a/README.md
+++ b/README.md
@@ -89,7 +89,7 @@ As per the survey, here is a list of improvements to come
```sh
docker pull hlohaus789/g4f
-docker run -p 8080:8080 -p 1337:1337 -p 7900:7900 --shm-size="2g" hlohaus789/g4f:latest
+docker run -p 8080:8080 -p 1337:1337 -p 7900:7900 --shm-size="2g" -v ${PWD}/hardir:/app/hardir hlohaus789/g4f:latest
```
3. Open the included client on: [http://localhost:8080/chat/](http://localhost:8080/chat/)
or set the API base in your client to: [http://localhost:1337/v1](http://localhost:1337/v1)
@@ -218,9 +218,12 @@ See: [/docs/interference](/docs/interference.md)
### Configuration
-##### Cookies / Access Token
+#### Cookies
-For generating images with Bing and for the OpenAI Chat you need cookies or a token from your browser session. From Bing you need the "_U" cookie and from OpenAI you need the "access_token". You can pass the cookies / the access token in the create function or you use the `set_cookies` setter before you run G4F:
+You need cookies for BingCreateImages and the Gemini Provider.
+From Bing you need the "_U" cookie and from Gemini you need the "__Secure-1PSID" cookie.
+Sometimes you doesn't need the "__Secure-1PSID" cookie, but some other auth cookies.
+You can pass the cookies in the create function or you use the `set_cookies` setter before you run G4F:
```python
from g4f.cookies import set_cookies
@@ -228,20 +231,32 @@ from g4f.cookies import set_cookies
set_cookies(".bing.com", {
"_U": "cookie value"
})
-set_cookies("chat.openai.com", {
- "access_token": "token value"
-})
set_cookies(".google.com", {
"__Secure-1PSID": "cookie value"
})
-
...
```
-Alternatively, G4F reads the cookies with `browser_cookie3` from your browser
-or it starts a browser instance with selenium `webdriver` for logging in.
+#### .HAR File for OpenaiChat Provider
+
+##### Generating a .HAR File
+
+To utilize the OpenaiChat provider, a .har file is required from https://chat.openai.com/. Follow the steps below to create a valid .har file:
+
+1. Navigate to https://chat.openai.com/ using your preferred web browser and log in with your credentials.
+2. Access the Developer Tools in your browser. This can typically be done by right-clicking the page and selecting "Inspect," or by pressing F12 or Ctrl+Shift+I (Cmd+Option+I on a Mac).
+3. With the Developer Tools open, switch to the "Network" tab.
+4. Reload the website to capture the loading process within the Network tab.
+5. Initiate an action in the chat which can be capture in the .har file.
+6. Right-click any of the network activities listed and select "Save all as HAR with content" to export the .har file.
+
+##### Storing the .HAR File
+
+- Place the exported .har file in the `./hardir` directory if you are using Docker. Alternatively, you can store it in any preferred location within your current working directory.
+
+Note: Ensure that your .har file is stored securely, as it may contain sensitive information.
-##### Using Proxy
+#### Using Proxy
If you want to hide or change your IP address for the providers, you can set a proxy globally via an environment variable:
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 8b2d5b7b..3e606ae6 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -81,7 +81,14 @@ WORKDIR $G4F_DIR
COPY requirements.txt $G4F_DIR
# Upgrade pip for the latest features and install the project's Python dependencies.
-RUN pip install --break-system-packages --upgrade pip && pip install --break-system-packages -r requirements.txt
+RUN pip install --break-system-packages --upgrade pip \
+ && pip install --break-system-packages -r requirements.txt
+
+# Install selenium driver and uninstall webdriver
+RUN pip install --break-system-packages \
+ undetected-chromedriver selenium-wire \
+ && pip uninstall -y --break-system-packages \
+ webdriver plyer
# Copy the entire package into the container.
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
diff --git a/g4f/Provider/needs_auth/OpenaiChat.py b/g4f/Provider/needs_auth/OpenaiChat.py
index b83025e4..72f9f224 100644
--- a/g4f/Provider/needs_auth/OpenaiChat.py
+++ b/g4f/Provider/needs_auth/OpenaiChat.py
@@ -403,7 +403,7 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin):
"conversation_id": conversation_id,
"parent_message_id": parent_id,
"model": model,
- "history_and_training_disabled": history_disabled and not auto_continue,
+ "history_and_training_disabled": history_disabled and not auto_continue and not return_conversation,
"websocket_request_id": websocket_request_id
}
if action != "continue":
diff --git a/g4f/Provider/openai/har_file.py b/g4f/Provider/openai/har_file.py
index 379697c2..68fe7420 100644
--- a/g4f/Provider/openai/har_file.py
+++ b/g4f/Provider/openai/har_file.py
@@ -41,9 +41,9 @@ def readHAR():
if not harPath:
raise RuntimeError("No .har file found")
for path in harPath:
- with open(path, 'r') as file:
+ with open(path, 'rb') as file:
try:
- harFile = json.load(file)
+ harFile = json.loads(file.read())
except json.JSONDecodeError:
# Error: not a HAR file!
continue
diff --git a/hardir/.gitkeep b/hardir/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/hardir/.gitkeep