Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into huggingface-space
Browse files Browse the repository at this point in the history
  • Loading branch information
ramon-victor committed Jul 17, 2023
2 parents 0207daf + 096ad32 commit ad4f7f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This project features a WebUI utilizing the [G4F API](https://github.com/xtekky/
Experience the power of ChatGPT with a user-friendly interface, enhanced jailbreaks, and completely free.

## Known bugs 🚧
- GPT-4 model offline.
- Stream mode not working properly.

## News 📢
I have created a new version of FreeGPT WebUI using the [ChimeraGPT API](https://chimeragpt.adventblocks.cc/).
Expand All @@ -27,6 +27,14 @@ I have created a new version of FreeGPT WebUI using the [ChimeraGPT API](https:/
This free API allows you to use various AI chat models, including <strong>GPT-4, GPT-4-32k, Claude-2, Claude-2-100k, and more.</strong> <br>
Check out the project here: [FreeGPT WebUI - Chimera Version](https://github.com/ramonvc/freegpt-webui/tree/chimeragpt-version).

## Project Hosting and Demonstration 🌐🚀
The project is hosted on multiple platforms to be tested and modified.
|Plataform|Status|Repo|Demo|
|--|--|--|--|
|[replit](https://replit.com/)|![Active](https://img.shields.io/badge/Active-brightgreen)|[FreeGPT WebUI](https://replit.com/@ramonvc/freegpt-webui)|[Chat](https://freegpt-webui.ramonvc.repl.co/chat/)
|[hugging face](https://huggingface.co)|![Active](https://img.shields.io/badge/Active-brightgreen)|[FreeGPT WebUI](https://huggingface.co/spaces/monra/freegpt-webui/tree/main)|[Chat](https://huggingface.co/spaces/monra/freegpt-webui)
|[replit](https://replit.com/)|![Active](https://img.shields.io/badge/Active-brightgreen)|[FreeGPT WebUI - Chimera Version](https://replit.com/@ramonvc/freegpt-webui-chimera)|[Chat](https://freegpt-webui-chimera.ramonvc.repl.co/chat/)

## Note ℹ️
<p>
FreeGPT is a project that utilizes various free AI conversation API Providers. Each Provider is an API that provides responses generated by different AI models. The source code related to these services is available in <a href="https://github.com/ramonvc/freegpt-webui/tree/main/g4f">G4F folder</a>.
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ numpy>=1.22.2 # pinned to avoid a vulnerability
tornado>=6.3.2 # pinned to avoid a vulnerability
PyExecJS
browser_cookie3
googletrans==4.0.0rc1
32 changes: 2 additions & 30 deletions server/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import time
import g4f
from g4f import ChatCompletion
from googletrans import Translator
from flask import request, Response, stream_with_context
from datetime import datetime
from requests import get
from server.config import special_instructions

Expand All @@ -23,7 +21,7 @@ def __init__(self, bp, config: dict) -> None:
'methods': ['POST']
}
}

def _conversation(self):
"""
Handles the conversation route.
Expand Down Expand Up @@ -75,20 +73,8 @@ def build_messages(jailbreak):
internet_access = request.json['meta']['content']['internet_access']
prompt = request.json['meta']['content']['parts'][0]

# Generate system message
current_date = datetime.now().strftime("%Y-%m-%d")
system_message = (
f'You are ChatGPT also known as ChatGPT, a large language model trained by OpenAI. '
f'Strictly follow the users instructions. '
f'Knowledge cutoff: 2021-09-01 Current date: {current_date}. '
f'{set_response_language(prompt)}'
)

# Initialize the conversation with the system message
conversation = [{'role': 'system', 'content': system_message}]

# Add the existing conversation
conversation += _conversation
conversation = _conversation

# Add web results if enabled
conversation += fetch_search_results(
Expand Down Expand Up @@ -172,20 +158,6 @@ def response_jailbroken_failed(response):
return False if len(response) < 4 else not (response.startswith("GPT:") or response.startswith("ACT:"))


def set_response_language(prompt):
"""
Set the response language based on the prompt content.
:param prompt: Prompt dictionary
:return: String indicating the language to be used for the response
"""
translator = Translator()
max_chars = 256
content_sample = prompt['content'][:max_chars]
detected_language = translator.detect(content_sample).lang
return f"You will respond in the language: {detected_language}. "


def getJailbreak(jailbreak):
"""
Check if jailbreak instructions are provided.
Expand Down

0 comments on commit ad4f7f7

Please sign in to comment.