t.me/xtekky
commited on
Commit
·
cfce83b
1
Parent(s):
f236f07
testing
Browse files- sqlchat/README.md +0 -42
- sqlchat/__init__.py +0 -117
- t3nsor/README.md +2 -0
- unfinished/gptbz/__init__.py +2 -3
- unfinished/ora_test.py +0 -29
- unfinished/test.py +12 -0
sqlchat/README.md
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
### Example: `sqlchat` (use like openai pypi package) <a name="example-sqlchat"></a>
|
2 |
-
|
3 |
-
```python
|
4 |
-
# Import sqlchat
|
5 |
-
import sqlchat
|
6 |
-
|
7 |
-
# sqlchat.Completion.create
|
8 |
-
# sqlchat.StreamCompletion.create
|
9 |
-
|
10 |
-
[...]
|
11 |
-
|
12 |
-
```
|
13 |
-
|
14 |
-
#### Example Chatbot
|
15 |
-
```python
|
16 |
-
messages = []
|
17 |
-
|
18 |
-
while True:
|
19 |
-
user = input('you: ')
|
20 |
-
|
21 |
-
sqlchat_cmpl = sqlchat.Completion.create(
|
22 |
-
prompt = user,
|
23 |
-
messages = messages
|
24 |
-
)
|
25 |
-
|
26 |
-
print('gpt:', sqlchat_cmpl.completion.choices[0].text)
|
27 |
-
|
28 |
-
messages.extend([
|
29 |
-
{'role': 'user', 'content': user },
|
30 |
-
{'role': 'assistant', 'content': sqlchat_cmpl.completion.choices[0].text}
|
31 |
-
])
|
32 |
-
```
|
33 |
-
|
34 |
-
#### Streaming Response:
|
35 |
-
|
36 |
-
```python
|
37 |
-
for response in sqlchat.StreamCompletion.create(
|
38 |
-
prompt = 'write python code to reverse a string',
|
39 |
-
messages = []):
|
40 |
-
|
41 |
-
print(response.completion.choices[0].text)
|
42 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sqlchat/__init__.py
DELETED
@@ -1,117 +0,0 @@
|
|
1 |
-
from requests import post
|
2 |
-
from time import time
|
3 |
-
|
4 |
-
headers = {
|
5 |
-
'authority' : 'www.sqlchat.ai',
|
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 |
-
'content-type' : 'text/plain;charset=UTF-8',
|
9 |
-
'origin' : 'https://www.sqlchat.ai',
|
10 |
-
'referer' : 'https://www.sqlchat.ai/',
|
11 |
-
'sec-fetch-dest' : 'empty',
|
12 |
-
'sec-fetch-mode' : 'cors',
|
13 |
-
'sec-fetch-site' : 'same-origin',
|
14 |
-
'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',
|
15 |
-
}
|
16 |
-
|
17 |
-
class SqlchatResponse:
|
18 |
-
class Completion:
|
19 |
-
class Choices:
|
20 |
-
def __init__(self, choice: dict) -> None:
|
21 |
-
self.text = choice['text']
|
22 |
-
self.content = self.text.encode()
|
23 |
-
self.index = choice['index']
|
24 |
-
self.logprobs = choice['logprobs']
|
25 |
-
self.finish_reason = choice['finish_reason']
|
26 |
-
|
27 |
-
def __repr__(self) -> str:
|
28 |
-
return f'''<__main__.APIResponse.Completion.Choices(\n text = {self.text.encode()},\n index = {self.index},\n logprobs = {self.logprobs},\n finish_reason = {self.finish_reason})object at 0x1337>'''
|
29 |
-
|
30 |
-
def __init__(self, choices: dict) -> None:
|
31 |
-
self.choices = [self.Choices(choice) for choice in choices]
|
32 |
-
|
33 |
-
class Usage:
|
34 |
-
def __init__(self, usage_dict: dict) -> None:
|
35 |
-
self.prompt_tokens = usage_dict['prompt_chars']
|
36 |
-
self.completion_tokens = usage_dict['completion_chars']
|
37 |
-
self.total_tokens = usage_dict['total_chars']
|
38 |
-
|
39 |
-
def __repr__(self):
|
40 |
-
return f'''<__main__.APIResponse.Usage(\n prompt_tokens = {self.prompt_tokens},\n completion_tokens = {self.completion_tokens},\n total_tokens = {self.total_tokens})object at 0x1337>'''
|
41 |
-
|
42 |
-
def __init__(self, response_dict: dict) -> None:
|
43 |
-
|
44 |
-
self.response_dict = response_dict
|
45 |
-
self.id = response_dict['id']
|
46 |
-
self.object = response_dict['object']
|
47 |
-
self.created = response_dict['created']
|
48 |
-
self.model = response_dict['model']
|
49 |
-
self.completion = self.Completion(response_dict['choices'])
|
50 |
-
self.usage = self.Usage(response_dict['usage'])
|
51 |
-
|
52 |
-
def json(self) -> dict:
|
53 |
-
return self.response_dict
|
54 |
-
|
55 |
-
class Completion:
|
56 |
-
def create(
|
57 |
-
prompt: str = 'hello world',
|
58 |
-
messages: list = []) -> SqlchatResponse:
|
59 |
-
|
60 |
-
response = post('https://www.sqlchat.ai/api/chat', headers=headers, stream=True,
|
61 |
-
json = {
|
62 |
-
'messages': messages,
|
63 |
-
'openAIApiConfig':{'key':'','endpoint':''}})
|
64 |
-
|
65 |
-
return SqlchatResponse({
|
66 |
-
'id' : f'cmpl-1337-{int(time())}',
|
67 |
-
'object' : 'text_completion',
|
68 |
-
'created': int(time()),
|
69 |
-
'model' : 'gpt-3.5-turbo',
|
70 |
-
'choices': [{
|
71 |
-
'text' : response.text,
|
72 |
-
'index' : 0,
|
73 |
-
'logprobs' : None,
|
74 |
-
'finish_reason' : 'stop'
|
75 |
-
}],
|
76 |
-
'usage': {
|
77 |
-
'prompt_chars' : len(prompt),
|
78 |
-
'completion_chars' : len(response.text),
|
79 |
-
'total_chars' : len(prompt) + len(response.text)
|
80 |
-
}
|
81 |
-
})
|
82 |
-
|
83 |
-
class StreamCompletion:
|
84 |
-
def create(
|
85 |
-
prompt : str = 'hello world',
|
86 |
-
messages: list = []) -> SqlchatResponse:
|
87 |
-
|
88 |
-
messages.append({
|
89 |
-
'role':'user',
|
90 |
-
'content':prompt
|
91 |
-
})
|
92 |
-
|
93 |
-
response = post('https://www.sqlchat.ai/api/chat', headers=headers, stream=True,
|
94 |
-
json = {
|
95 |
-
'messages': messages,
|
96 |
-
'openAIApiConfig':{'key':'','endpoint':''}})
|
97 |
-
|
98 |
-
for chunk in response.iter_content(chunk_size = 2046):
|
99 |
-
yield SqlchatResponse({
|
100 |
-
'id' : f'cmpl-1337-{int(time())}',
|
101 |
-
'object' : 'text_completion',
|
102 |
-
'created': int(time()),
|
103 |
-
'model' : 'gpt-3.5-turbo',
|
104 |
-
|
105 |
-
'choices': [{
|
106 |
-
'text' : chunk.decode(),
|
107 |
-
'index' : 0,
|
108 |
-
'logprobs' : None,
|
109 |
-
'finish_reason' : 'stop'
|
110 |
-
}],
|
111 |
-
|
112 |
-
'usage': {
|
113 |
-
'prompt_chars' : len(prompt),
|
114 |
-
'completion_chars' : len(chunk.decode()),
|
115 |
-
'total_chars' : len(prompt) + len(chunk.decode())
|
116 |
-
}
|
117 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t3nsor/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
### Example: `t3nsor` (use like openai pypi package) <a name="example-t3nsor"></a>
|
2 |
|
3 |
```python
|
|
|
1 |
+
### note: currently patched
|
2 |
+
|
3 |
### Example: `t3nsor` (use like openai pypi package) <a name="example-t3nsor"></a>
|
4 |
|
5 |
```python
|
unfinished/gptbz/__init__.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
-
import asyncio
|
2 |
import websockets
|
3 |
-
|
4 |
from json import dumps, loads
|
5 |
|
6 |
async def test():
|
@@ -20,6 +18,8 @@ async def test():
|
|
20 |
try:
|
21 |
response = await wss.recv()
|
22 |
json_response = loads(response)
|
|
|
|
|
23 |
ended = json_response.get('eof')
|
24 |
|
25 |
if not ended:
|
@@ -28,4 +28,3 @@ async def test():
|
|
28 |
except websockets.ConnectionClosed:
|
29 |
break
|
30 |
|
31 |
-
asyncio.run(test())
|
|
|
|
|
1 |
import websockets
|
|
|
2 |
from json import dumps, loads
|
3 |
|
4 |
async def test():
|
|
|
18 |
try:
|
19 |
response = await wss.recv()
|
20 |
json_response = loads(response)
|
21 |
+
print(json_response)
|
22 |
+
|
23 |
ended = json_response.get('eof')
|
24 |
|
25 |
if not ended:
|
|
|
28 |
except websockets.ConnectionClosed:
|
29 |
break
|
30 |
|
|
unfinished/ora_test.py
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
# inport ora
|
2 |
-
import ora
|
3 |
-
|
4 |
-
# create model
|
5 |
-
model = ora.CompletionModel.create(
|
6 |
-
system_prompt = 'You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible',
|
7 |
-
description = 'ChatGPT Openai Language Model',
|
8 |
-
name = 'gpt-3.5')
|
9 |
-
|
10 |
-
print(model.id)
|
11 |
-
|
12 |
-
# init conversation (will give you a conversationId)
|
13 |
-
init = ora.Completion.create(
|
14 |
-
model = model,
|
15 |
-
prompt = 'hello world')
|
16 |
-
|
17 |
-
print(init.completion.choices[0].text)
|
18 |
-
|
19 |
-
while True:
|
20 |
-
# pass in conversationId to continue conversation
|
21 |
-
|
22 |
-
prompt = input('>>> ')
|
23 |
-
response = ora.Completion.create(
|
24 |
-
model = model,
|
25 |
-
prompt = prompt,
|
26 |
-
includeHistory = True,
|
27 |
-
conversationId = init.id)
|
28 |
-
|
29 |
-
print(response.completion.choices[0].text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unfinished/test.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gptbz
|
2 |
+
import asyncio
|
3 |
+
|
4 |
+
|
5 |
+
# asyncio.run(gptbz.test())
|
6 |
+
|
7 |
+
import requests
|
8 |
+
|
9 |
+
image = '/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAoALQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExB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hCSWBBG4bhtAAyCcmiinF3k0RWgqdKMl1VvxZfM2s+VkWFh5nl5x9tfG/djGfK6bec468Y/irN1CeUCeHXbrTItPc3O6GN5PNltxHx0I+YKXLYB42455ooqpaIwo2lO1rE1rZjUYrcCO2Giw/Zp7BYzKrkKu4bh8oAB2EA56HIz0u3uxL+1kbygQpQFt2fmki4GOOuOvfHbNFFPpcTu6nKFpsTU75V8oNJKXIXduOI4hk54zjHTjGO+a0KKKaM59PQxLqNNBMuoQpDFYJEfPQLISp8zcWAXIxh5CcLnOMnHQaFNKkkvtOFoli0k9xqP32Zn24LIFyM7kwRg98c5yUVL3No6xTfV2/IrxyW0vh21kQ2phaexKn97s5aErj+LPTbnj7u7+KujoopxZNZW+9/oQXdpBfWk1rcxiSGVGjdSSMhgQeRyOCRxWOtvbXU0Ol6mIHksJbea0IMoJYISGy3U5ST+JuB83uUUMVJuz121JnaL/AITOBSYPOGnyEA7/ADdvmJnH8G3IHX5s4xxmtmiihdRVFZR9AoooqjI//9k='
|
10 |
+
|
11 |
+
response = requests.get('https://ocr.holey.cc/ncku?base64_str=%s' % image) #.split('base64,')[1])
|
12 |
+
print(response.content)
|