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

Commit

Permalink
Merge branch 'pre-release' into chimeragpt-version
Browse files Browse the repository at this point in the history
  • Loading branch information
ramon-victor committed Jul 17, 2023
2 parents 0385e17 + 8c1f2d9 commit 5f0973e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ retrying
numpy>=1.22.2 # pinned to avoid a vulnerability
tornado>=6.3.2 # pinned to avoid a vulnerability
PyExecJS
googletrans==4.0.0rc1
openai
browser_cookie3
32 changes: 2 additions & 30 deletions server/backend.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import re
import time
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 @@ -22,7 +20,7 @@ def __init__(self, bp, config: dict) -> None:
'methods': ['POST']
}
}

def _conversation(self):
"""
Handles the conversation route.
Expand Down Expand Up @@ -76,20 +74,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 @@ -173,20 +159,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 5f0973e

Please sign in to comment.