1
+ from json import dumps
2
+ from time import time
1
3
from flask import request
2
-
4
+ from hashlib import sha256
3
5
from datetime import datetime
4
6
from requests import get
5
7
from requests import post
6
8
7
- from server .config import models
8
9
from server .config import special_instructions
9
10
10
11
@@ -15,11 +16,10 @@ def __init__(self, app) -> None:
15
16
'/backend-api/v2/conversation' : {
16
17
'function' : self ._conversation ,
17
18
'methods' : ['POST' ]
18
- },
19
+ }
19
20
}
20
21
21
22
def _conversation (self ):
22
-
23
23
try :
24
24
jailbreak = request .json ['jailbreak' ]
25
25
internet_access = request .json ['meta' ]['content' ]['internet_access' ]
@@ -53,29 +53,20 @@ def _conversation(self):
53
53
extra + special_instructions [jailbreak ] + \
54
54
_conversation + [prompt ]
55
55
56
+ timestamp = int (time () * 1000 )
56
57
headers = {
57
- 'authority' : 'www.sqlchat.ai' ,
58
- 'accept' : '*/*' ,
59
- 'accept-language' : 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3' ,
60
- 'content-type' : 'text/plain;charset=UTF-8' ,
61
- 'origin' : 'https://www.sqlchat.ai' ,
62
- 'referer' : 'https://www.sqlchat.ai/' ,
63
- 'sec-fetch-dest' : 'empty' ,
64
- 'sec-fetch-mode' : 'cors' ,
65
- 'sec-fetch-site' : 'same-origin' ,
58
+ 'authority' : 'chatforai.com' ,
59
+ 'origin' : 'https://chatforai.com' ,
60
+ 'referer' : 'https://chatforai.com/' ,
66
61
'user-agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36' ,
67
62
}
68
63
69
- data = {
70
- 'messages' : conversation ,
71
- 'openAIApiConfig' : {
72
- 'key' : '' ,
73
- 'endpoint' : ''
74
- }
75
- }
76
-
77
- gpt_resp = post ('https://www.sqlchat.ai/api/chat' ,
78
- headers = headers , json = data , stream = True )
64
+ gpt_resp = post ('https://chatforai.com/api/generate' , headers = headers , stream = True ,
65
+ data = dumps (separators = (',' , ':' ), obj = {
66
+ 'messages' : conversation ,
67
+ 'time' : timestamp ,
68
+ 'pass' : None ,
69
+ 'sign' : sha256 (f'{ timestamp } :{ conversation [- 1 ]["content" ]} :k6zeE77ge7XF' .encode ()).hexdigest (), 'key' : '' }))
79
70
80
71
def stream ():
81
72
answer = ''
0 commit comments