diff --git a/docker/Dockerfile-slim b/docker/Dockerfile-slim index 266de95d..f66b75e0 100644 --- a/docker/Dockerfile-slim +++ b/docker/Dockerfile-slim @@ -21,9 +21,8 @@ RUN apt-get update && apt-get upgrade -y \ && apt-get clean \ && rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN mkdir -p $G4F_DIR && touch /var/log/cron.log -RUN chown "${G4F_USER_ID}:${G4F_USER_ID}" $G4F_DIR /var/log/cron.log \ - && chmod gu+rw /var/run && chmod gu+s /usr/sbin/cron +RUN mkdir -p $G4F_DIR +RUN chown "${G4F_USER_ID}:${G4F_USER_ID}" $G4F_DIR USER $G4F_USER_ID WORKDIR $G4F_DIR @@ -32,10 +31,12 @@ ENV HOME /home/$G4F_USER ENV PATH "${HOME}/.local/bin:${PATH}" RUN git clone https://github.com/xtekky/gpt4free.git $G4F_DIR \ - && printf "*/15 * * * * python -m etc.tool.update\n" > cronfile && crontab cronfile \ - && pip install --no-cache-dir -r requirements-slim.txt + && printf "*/15 * * * * ./docker/start.sh\n" > cronfile \ + && printf "*/15 * * * * python -m etc.tool.update\n" >> cronfile && crontab cronfile \ + && pip install --no-cache-dir -r requirements-min.txt RUN git clone https://github.com/hlohaus/deepseek4free.git \ && cd deepseek4free && git checkout 21Feb \ && pip install --no-cache-dir . && cd .. && rm -rf deepseek4free -CMD cron && tail -f /var/log/cron.log & python -m g4f --port 8080 --debug --reload \ No newline at end of file +USER root +CMD cron && su -c docker/start.sh $G4F_USER \ No newline at end of file diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 00000000..810c75b0 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +python -m g4f --port 8080 --debug --reload \ No newline at end of file diff --git a/g4f/Provider/PollinationsAI.py b/g4f/Provider/PollinationsAI.py index ceacf1dc..bc1fe5f9 100644 --- a/g4f/Provider/PollinationsAI.py +++ b/g4f/Provider/PollinationsAI.py @@ -531,9 +531,20 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin): if reasoning: yield Reasoning(status="") if kwargs.get("action") == "next": + safe_messages = [] + for message in messages: + if message.get("role") == "user": + if isinstance(message.get("content"), str): + safe_messages.append({"role": "user", "content": message.get("content")}) + elif isinstance(message.get("content"), list): + next_value = message.get("content").pop() + if isinstance(next_value, dict): + next_value = next_value.get("text") + if next_value: + safe_messages.append({"role": "user", "content": next_value}) data = { "model": "openai", - "messages": [m for m in messages if m.get("role") == "user"] + FOLLOWUPS_DEVELOPER_MESSAGE, + "messages": safe_messages + FOLLOWUPS_DEVELOPER_MESSAGE, "tool_choice": "required", "tools": FOLLOWUPS_TOOLS } diff --git a/g4f/providers/base_provider.py b/g4f/providers/base_provider.py index 7e6b8a0a..15c1d808 100644 --- a/g4f/providers/base_provider.py +++ b/g4f/providers/base_provider.py @@ -376,7 +376,7 @@ class ProviderModelMixin: model = cls.default_model if model in cls.model_aliases: model = cls.model_aliases[model] - else: + if model not in cls.model_aliases.values(): if model not in cls.get_models(**kwargs) and cls.models: raise ModelNotFoundError(f"Model not found: {model} in: {cls.__name__} Valid models: {cls.models}") cls.last_model = model