summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--docker/Dockerfile16
-rw-r--r--g4f/Provider/__init__.py1
-rw-r--r--g4f/Provider/needs_auth/HuggingChat.py9
4 files changed, 21 insertions, 6 deletions
diff --git a/README.md b/README.md
index a4075702..c068a5c4 100644
--- a/README.md
+++ b/README.md
@@ -155,6 +155,7 @@ cd gpt4free
4. Build the Docker image:
```bash
+docker pull selenium/node-chrome
docker-compose build
```
diff --git a/docker/Dockerfile b/docker/Dockerfile
index d160fcac..4fe9a45d 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -11,8 +11,12 @@ ENV G4F_USER ${G4F_USER:-g4f}
ARG G4F_USER_ID
ENV G4F_USER_ID ${G4F_USER_ID:-1000}
ARG G4F_NO_GUI
-ENV G4F_NO_GUI ${G4F_NO_GUI}
+ENV G4F_NO_GUI $G4F_NO_GUI
ENV HOME /home/$G4F_USER
+ENV SE_DOWNLOAD_DIR $HOME/Downloads
+ENV SEL_USER $G4F_USER
+ENV SEL_UID $G4F_USER_ID
+ENV SEL_GID $G4F_USER_ID
USER root
@@ -46,9 +50,15 @@ RUN if [ "$G4F_NO_GUI" ] ; then \
# Change background image
COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
-# Switch user
+# Add user
RUN groupadd -g $G4F_USER_ID $G4F_USER
RUN useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER
+
+# Fix permissions
+RUN mkdir "${SE_DOWNLOAD_DIR}"
+RUN chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor
+
+# Switch user
USER $G4F_USER_ID
# Set the working directory in the container.
@@ -61,7 +71,7 @@ COPY requirements.txt $G4F_DIR
RUN pip install --upgrade pip && pip install -r requirements.txt
# Copy the entire package into the container.
-ADD --chown=$G4F_USER g4f $G4F_DIR/
+ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/
# Expose ports
EXPOSE 8080 1337 \ No newline at end of file
diff --git a/g4f/Provider/__init__.py b/g4f/Provider/__init__.py
index efc94613..bfc02590 100644
--- a/g4f/Provider/__init__.py
+++ b/g4f/Provider/__init__.py
@@ -39,7 +39,6 @@ from .Koala import Koala
from .Liaobots import Liaobots
from .Llama2 import Llama2
from .MyShell import MyShell
-from .NoowAi import NoowAi
from .OnlineGpt import OnlineGpt
from .Opchatgpts import Opchatgpts
from .PerplexityAi import PerplexityAi
diff --git a/g4f/Provider/needs_auth/HuggingChat.py b/g4f/Provider/needs_auth/HuggingChat.py
index 530069c0..41c938b4 100644
--- a/g4f/Provider/needs_auth/HuggingChat.py
+++ b/g4f/Provider/needs_auth/HuggingChat.py
@@ -47,14 +47,19 @@ class HuggingChat(AsyncGeneratorProvider):
"web_search": web_search
}
async with session.post(f"{cls.url}/conversation/{conversation_id}", json=send, proxy=proxy) as response:
+ first_token = True
async for line in response.content:
line = json.loads(line[:-1])
if "type" not in line:
raise RuntimeError(f"Response: {line}")
elif line["type"] == "stream":
- yield line["token"]
+ token = line["token"]
+ if first_token:
+ token = token.lstrip()
+ first_token = False
+ yield token
elif line["type"] == "finalAnswer":
break
async with session.delete(f"{cls.url}/conversation/{conversation_id}", proxy=proxy) as response:
- response.raise_for_status() \ No newline at end of file
+ response.raise_for_status()