返回提交历史
Modified
t3nsor/__init__.py
+20
-4
Renamed
t3nsor/t3nsor_test.py
+1
-1
XFEstudio/gpt4free
t3nsor.tech api unpatch
351fbbb1
代码差异
2 个文件
+21
-5
@@ -1,6 +1,24 @@
1
1
from requests import post
2
2
from time import time
3
3
4
headers = {
5
'authority': 'www.t3nsor.tech',
6
'accept': '*/*',
7
'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',
8
'cache-control': 'no-cache',
9
'content-type': 'application/json',
10
'origin': 'https://www.t3nsor.tech',
11
'pragma': 'no-cache',
12
'referer': 'https://www.t3nsor.tech/',
13
'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
14
'sec-ch-ua-mobile': '?0',
15
'sec-ch-ua-platform': '"macOS"',
16
'sec-fetch-dest': 'empty',
17
'sec-fetch-mode': 'cors',
18
'sec-fetch-site': 'same-origin',
19
'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',
20
}
21
4
22
class T3nsorResponse:
5
23
6
24
class Completion:
@@ -53,9 +71,7 @@ class Completion:
53
71
prompt: str = 'hello world',
54
72
messages: list = []) -> T3nsorResponse:
55
73
56
raise Exception('The t3nsor.tech API is currently down.')
57
58
response = post('https://www.t3nsor.tech/api/chat', json = Completion.model | {
74
response = post('https://www.t3nsor.tech/api/chat', headers = headers, json = Completion.model | {
59
75
'messages' : messages,
60
76
'key' : '',
61
77
'prompt' : prompt
@@ -91,7 +107,7 @@ class StreamCompletion:
91
107
prompt: str = 'hello world',
92
108
messages: list = []) -> T3nsorResponse:
93
109
94
response = post('https://www.t3nsor.tech/api/chat', stream = True, json = Completion.model | {
110
response = post('https://www.t3nsor.tech/api/chat', headers = headers, stream = True, json = Completion.model | {
95
111
'messages' : messages,
96
112
'key' : '',
97
113
'prompt' : prompt
@@ -4,4 +4,4 @@ for response in t3nsor.StreamCompletion.create(
4
4
prompt = 'write python code to reverse a string',
5
5
messages = []):
6
6
7
print(response.completion.choices[0].text)
7
print(response.completion.choices[0].text)