Skip to content

Commit

Permalink
Merge branch 'xtekky:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kqlio67 authored Nov 26, 2024
2 parents f150db2 + b99717d commit e13186b
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 21 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/publish-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,26 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}

- name: Build and push armv7 image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile-armv7
platforms: linux/arm/v7
push: true
tags: |
hlohaus789/g4f:latest-armv7
hlohaus789/g4f:${{ github.ref_name }}-armv7
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
G4F_VERSION=${{ github.ref_name }}
- name: Build and push small images
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile-slim
platforms: linux/amd64,linux/arm64,linux/arm/v7
platforms: linux/amd64,linux/arm64
push: true
tags: |
hlohaus789/g4f:latest-slim
Expand Down
67 changes: 67 additions & 0 deletions docker/Dockerfile-armv7
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM python:slim-bookworm

ARG G4F_VERSION
ARG G4F_USER=g4f
ARG G4F_USER_ID=1000
ARG PYDANTIC_VERSION=1.8.1

ENV G4F_VERSION $G4F_VERSION
ENV G4F_USER $G4F_USER
ENV G4F_USER_ID $G4F_USER_ID
ENV G4F_DIR /app

RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y git \
&& apt-get install --quiet --yes --no-install-recommends \
build-essential \
# Add user and user group
&& groupadd -g $G4F_USER_ID $G4F_USER \
&& useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
&& mkdir -p /var/log/supervisor \
&& chown "${G4F_USER_ID}:${G4F_USER_ID}" /var/log/supervisor \
&& echo "${G4F_USER}:${G4F_USER}" | chpasswd \
&& python -m pip install --upgrade pip

USER $G4F_USER_ID
WORKDIR $G4F_DIR

ENV HOME /home/$G4F_USER
ENV PATH "${HOME}/.local/bin:${PATH}"

# Create app dir and copy the project's requirements file into it
RUN mkdir -p $G4F_DIR
COPY requirements-min.txt $G4F_DIR
COPY requirements-slim.txt $G4F_DIR

# Upgrade pip for the latest features and install the project's Python dependencies.
RUN pip install --no-cache-dir -r requirements-min.txt \
&& pip install --no-cache-dir --no-binary setuptools \
Cython==0.29.22 \
setuptools \
# Install PyDantic
&& pip install \
-vvv \
--no-cache-dir \
--no-binary :all: \
--global-option=build_ext \
--global-option=-j8 \
pydantic==${PYDANTIC_VERSION}
RUN cat requirements-slim.txt | xargs -n 1 pip install --no-cache-dir || true

# Remove build packages
RUN pip uninstall --yes \
Cython \
setuptools

USER root

# Clean up build deps
RUN apt-get purge --auto-remove --yes \
build-essential \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/*

USER $G4F_USER_ID

# Copy the entire package into the container.
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
4 changes: 2 additions & 2 deletions docker/Dockerfile-slim
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ ENV PATH "${HOME}/.local/bin:${PATH}"

# Create app dir and copy the project's requirements file into it
RUN mkdir -p $G4F_DIR
COPY requirements-min.txt $G4F_DIR
COPY requirements-slim.txt $G4F_DIR

# Upgrade pip for the latest features and install the project's Python dependencies.
RUN cat requirements-slim.txt | xargs -n 1 pip install --no-cache-dir || true
RUN pip install --no-cache-dir -r requirements-slim.txt \
&& pip install --no-cache-dir duckduckgo-search>=5.0

# Copy the entire package into the container.
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
3 changes: 1 addition & 2 deletions docs/async_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,9 @@ The G4F AsyncClient supports a wide range of AI models and providers, allowing y
- OpenAI
- Google (for Gemini)
- Anthropic
- Bing
- Microsoft Copilot
- Custom providers



**To use a specific model or provider, specify it when creating the client or in the API call:**
```python
Expand Down
1 change: 0 additions & 1 deletion g4f/Provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from .AIUncensored import AIUncensored
from .Airforce import Airforce
from .AmigoChat import AmigoChat
from .Bing import Bing
from .Blackbox import Blackbox
from .ChatGpt import ChatGpt
from .ChatGptEs import ChatGptEs
Expand Down
24 changes: 12 additions & 12 deletions g4f/Provider/Bing.py → g4f/Provider/deprecated/Bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
from urllib import parse
from datetime import datetime, date

from ..typing import AsyncResult, Messages, ImageType, Cookies
from ..image import ImageRequest
from ..errors import ResponseError, ResponseStatusError, RateLimitError
from ..requests import DEFAULT_HEADERS
from ..requests.aiohttp import StreamSession
from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
from .helper import get_random_hex
from .bing.upload_image import upload_image
from .bing.conversation import Conversation, create_conversation, delete_conversation
from .needs_auth.BingCreateImages import BingCreateImages
from .. import debug
from ...typing import AsyncResult, Messages, ImageType, Cookies
from ...image import ImageRequest
from ...errors import ResponseError, ResponseStatusError, RateLimitError
from ...requests import DEFAULT_HEADERS
from ...requests.aiohttp import StreamSession
from ..base_provider import AsyncGeneratorProvider, ProviderModelMixin
from ..helper import get_random_hex
from ..bing.upload_image import upload_image
from ..bing.conversation import Conversation, create_conversation, delete_conversation
from ..needs_auth.BingCreateImages import BingCreateImages
from ... import debug

class Tones:
"""
Expand All @@ -35,7 +35,7 @@ class Bing(AsyncGeneratorProvider, ProviderModelMixin):
"""
label = "Microsoft Copilot in Bing"
url = "https://bing.com/chat"
working = True
working = False
supports_message_history = True
default_model = "Balanced"
default_vision_model = "gpt-4-vision"
Expand Down
1 change: 1 addition & 0 deletions g4f/Provider/deprecated/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
from .Hashnode import Hashnode
from .Ylokh import Ylokh
from .OpenAssistant import OpenAssistant
from .Bing import Bing
19 changes: 19 additions & 0 deletions g4f/gui/client/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ body {
border: 1px solid var(--blur-border);
}

.new_version {
position: absolute;
right: 0;
top: 0;
padding: 10px;
font-weight: 500;
background-color: rgba(0, 0, 0, 0.5);
color: var(--colour-3);
}

.white .new_version {
color: var(--colour-1);
}

.new_version a {
color: var(--colour-4);
text-decoration: underline dotted;
}

.conversations {
max-width: 300px;
padding: var(--section-gap);
Expand Down
10 changes: 8 additions & 2 deletions g4f/gui/client/static/js/chat.v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -1331,15 +1331,21 @@ async function load_version() {
document.title = 'g4f - ' + versions["version"];
let text = "version ~ "
if (versions["version"] != versions["latest_version"]) {
let release_url = 'https://github.com/xtekky/gpt4free/releases/tag/' + versions["latest_version"];
let release_url = 'https://github.com/xtekky/gpt4free/releases/latest';
let title = `New version: ${versions["latest_version"]}`;
text += `<a href="${release_url}" target="_blank" title="${title}">${versions["version"]}</a> 🆕`;
const new_version = document.createElement("div");
new_version.classList.add("new_version");
const link = `<a href="${release_url}" target="_blank" title="${title}">v${versions["latest_version"]}</a>`;
new_version.innerHTML = `g4f ${link}&nbsp;&nbsp;🆕`;
new_version.addEventListener("click", ()=>new_version.parentElement.removeChild(new_version));
document.body.appendChild(new_version);
} else {
text += versions["version"];
}
document.getElementById("version_text").innerHTML = text
}
setTimeout(load_version, 2000);
setTimeout(load_version, 100);

[imageInput, cameraInput].forEach((el) => {
el.addEventListener('click', async () => {
Expand Down
1 change: 0 additions & 1 deletion requirements-slim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pycryptodome
curl_cffi>=0.6.2
aiohttp
certifi
duckduckgo-search>=5.0
nest_asyncio
werkzeug
pillow
Expand Down

0 comments on commit e13186b

Please sign in to comment.