Skip to content

Commit

Permalink
t3nsor.tech api unpatch
Browse files Browse the repository at this point in the history
  • Loading branch information
xtekky committed Apr 13, 2023
1 parent d0f5814 commit 351fbbb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions t3nsor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
from requests import post
from time import time

headers = {
'authority': 'www.t3nsor.tech',
'accept': '*/*',
'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',
'cache-control': 'no-cache',
'content-type': 'application/json',
'origin': 'https://www.t3nsor.tech',
'pragma': 'no-cache',
'referer': 'https://www.t3nsor.tech/',
'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'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',
}

class T3nsorResponse:

class Completion:
Expand Down Expand Up @@ -53,9 +71,7 @@ def create(
prompt: str = 'hello world',
messages: list = []) -> T3nsorResponse:

raise Exception('The t3nsor.tech API is currently down.')

response = post('https://www.t3nsor.tech/api/chat', json = Completion.model | {
response = post('https://www.t3nsor.tech/api/chat', headers = headers, json = Completion.model | {
'messages' : messages,
'key' : '',
'prompt' : prompt
Expand Down Expand Up @@ -91,7 +107,7 @@ def create(
prompt: str = 'hello world',
messages: list = []) -> T3nsorResponse:

response = post('https://www.t3nsor.tech/api/chat', stream = True, json = Completion.model | {
response = post('https://www.t3nsor.tech/api/chat', headers = headers, stream = True, json = Completion.model | {
'messages' : messages,
'key' : '',
'prompt' : prompt
Expand Down
2 changes: 1 addition & 1 deletion testing/t3nsor_test.py → t3nsor/t3nsor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
prompt = 'write python code to reverse a string',
messages = []):

print(response.completion.choices[0].text)
print(response.completion.choices[0].text)

0 comments on commit 351fbbb

Please sign in to comment.