diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | openai_rev/forefront/__init__.py | 1 | ||||
-rw-r--r-- | openai_rev/openai_rev.py | 8 | ||||
-rw-r--r-- | openai_rev/theb/README.md (renamed from theb/README.md) | 3 | ||||
-rw-r--r-- | openai_rev/theb/__init__.py (renamed from theb/__init__.py) | 20 | ||||
-rw-r--r-- | openai_rev/theb/theb_test.py | 4 | ||||
-rw-r--r-- | testing/accounts.txt | 3 | ||||
-rw-r--r-- | testing/test_main.py | 11 | ||||
-rw-r--r-- | theb/theb_test.py | 4 |
9 files changed, 35 insertions, 21 deletions
@@ -38,7 +38,7 @@ Please note the following: | **Copyright** | Copyright information | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#copyright) | - | | **Star History** | Star History | [![Link to Section](https://img.shields.io/badge/Link-Go%20to%20Section-blue)](#star-history) | - | | **Usage Examples** | | | | -| `theb` | Example usage for theb (gpt-3.5) | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](./theb/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) | +| `theb` | Example usage for theb (gpt-3.5) | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](openai_rev/theb/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) | | `forefront` | Example usage for forefront (gpt-4) | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](./forefront/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) | || | `quora (poe)` | Example usage for quora | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](./quora/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) | | `you` | Example usage for you | [![Link to File](https://img.shields.io/badge/Link-Go%20to%20File-blue)](./you/README.md) | ![Active](https://img.shields.io/badge/Active-brightgreen) | diff --git a/openai_rev/forefront/__init__.py b/openai_rev/forefront/__init__.py index 10202615..6fece65a 100644 --- a/openai_rev/forefront/__init__.py +++ b/openai_rev/forefront/__init__.py @@ -169,7 +169,6 @@ class Completion: ) -> ForeFrontResponse: text = '' final_response = None - res = list(StreamingCompletion.create(token=token, prompt=prompt)) for response in StreamingCompletion.create( token=token, chat_id=chat_id, diff --git a/openai_rev/openai_rev.py b/openai_rev/openai_rev.py index 7d483c01..6b88298b 100644 --- a/openai_rev/openai_rev.py +++ b/openai_rev/openai_rev.py @@ -2,6 +2,7 @@ from enum import Enum from openai_rev import forefront from openai_rev import quora +from openai_rev import theb from openai_rev import you @@ -9,6 +10,7 @@ class Provider(Enum): You = 'you' Poe = 'poe' ForeFront = 'fore_front' + Theb = 'theb' class Completion: @@ -20,6 +22,8 @@ class Completion: return Completion.__you_service(prompt, **kwargs) elif provider == Provider.ForeFront: return Completion.__fore_front_service(prompt, **kwargs) + elif provider == Provider.Theb: + return Completion.__theb_service(prompt, **kwargs) @classmethod def __you_service(cls, prompt: str, **kwargs) -> str: @@ -32,3 +36,7 @@ class Completion: @classmethod def __fore_front_service(cls, prompt: str, **kwargs) -> str: return forefront.Completion.create(prompt=prompt, **kwargs).text + + @classmethod + def __theb_service(cls, prompt: str, **kwargs): + return ''.join(theb.Completion.create(prompt=prompt)) diff --git a/theb/README.md b/openai_rev/theb/README.md index 982c34a1..bd37ba3f 100644 --- a/theb/README.md +++ b/openai_rev/theb/README.md @@ -1,9 +1,8 @@ ### Example: `theb` (use like openai pypi package) <a name="example-theb"></a> - ```python # import library -import theb +from openai_rev import theb # simple streaming completion for token in theb.Completion.create('hello world'): diff --git a/theb/__init__.py b/openai_rev/theb/__init__.py index 726e025e..fa79fdd9 100644 --- a/theb/__init__.py +++ b/openai_rev/theb/__init__.py @@ -1,9 +1,11 @@ -from re import findall from json import loads from queue import Queue, Empty +from re import findall from threading import Thread + from curl_cffi import requests + class Completion: # experimental part1 = '{"role":"assistant","id":"chatcmpl' @@ -14,7 +16,8 @@ class Completion: message_queue = Queue() stream_completed = False - def request(prompt: str): + @classmethod + def request(cls, prompt: str): headers = { 'authority': 'chatbot.theb.ai', 'content-type': 'application/json', @@ -22,12 +25,11 @@ class Completion: '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', } - requests.post('https://chatbot.theb.ai/api/chat-process', headers=headers, - content_callback = Completion.handle_stream_response, - json = { - 'prompt': prompt, - 'options': {} - } + requests.post( + 'https://chatbot.theb.ai/api/chat-process', + headers=headers, + content_callback=Completion.handle_stream_response, + json={'prompt': prompt, 'options': {}}, ) Completion.stream_completed = True @@ -36,7 +38,7 @@ class Completion: def create(prompt: str): Thread(target=Completion.request, args=[prompt]).start() - while Completion.stream_completed != True or not Completion.message_queue.empty(): + while not Completion.stream_completed or not Completion.message_queue.empty(): try: message = Completion.message_queue.get(timeout=0.01) for message in findall(Completion.regex, message): diff --git a/openai_rev/theb/theb_test.py b/openai_rev/theb/theb_test.py new file mode 100644 index 00000000..805ef094 --- /dev/null +++ b/openai_rev/theb/theb_test.py @@ -0,0 +1,4 @@ +from openai_rev import theb + +for token in theb.Completion.create('hello world'): + print(token, end='', flush=True) diff --git a/testing/accounts.txt b/testing/accounts.txt index 82a8957d..9d58df06 100644 --- a/testing/accounts.txt +++ b/testing/accounts.txt @@ -15,3 +15,6 @@ trbfmqhnokevio@bugfoo.com:eyJhbGciOiJSUzI1NiIsImtpZCI6Imluc18yTzZ3UTFYd3dxVFdXUW gprzdsftrckwbj@bugfoo.com:eyJhbGciOiJSUzI1NiIsImtpZCI6Imluc18yTzZ3UTFYd3dxVFdXUWUyQ1VYZHZ2bnNaY2UiLCJ0eXAiOiJKV1QifQ.eyJhenAiOiJodHRwczovL2FjY291bnRzLmZvcmVmcm9udC5haSIsImV4cCI6MTY4MjYyNzM3NiwiaWF0IjoxNjgyNjI3MzE2LCJpc3MiOiJodHRwczovL2NsZXJrLmZvcmVmcm9udC5haSIsIm5iZiI6MTY4MjYyNzMwNiwic2lkIjoic2Vzc18yUDFiMTkxUUdYZ3YxZ2VDTHR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5zC6n_XyMxsFmxoHSIt0vi74atqbFtlzp4Ct7YuDm_PFA6Dy0VoWx2FtkyjFow4ZcqHUubn2Nw3r8BlwpUReA +vcwbipuximmpzo@bugfoo.com:eyJhbGciOiJSUzI1NiIsImtpZCI6Imluc18yTzZ3UTFYd3dxVFdXUWUyQ1VYZHZ2bnNaY2UiLCJ0eXAiOiJKV1QifQ.eyJhenAiOiJodHRwczovL2FjY291bnRzLmZvcmVmcm9udC5haSIsImV4cCI6MTY4MjYzMDg2MywiaWF0IjoxNjgyNjMwODAzLCJpc3MiOiJodHRwczovL2NsZXJrLmZvcmVmcm9udC5haSIsIm5iZiI6MTY4MjYzMDc5Mywic2lkIjoic2Vzc18yUDFpNUhDM0JHUTRlRXY2VnFkcUdCQnNMUzgiLCJzdWIiOiJ1c2VyXzJQMWk1R2U5VFRzQjFCMDVXTFRIcXBjNzA2ZSJ9.vZt1afDAZ1UANpZwW30p4GWEezpQ2pCtQ6oD7bKxl68-_tsyOHlTd_Tqo1EChkqHKfaKdiSN2opjl3EpPqOq1DEwn7Oc0xFGod489juO-KSpbT5zyJtuUQn8t56UnOvC3ofCJvveE51aaPNt2it7-8vyhqDgkrEfw03PGFCv8PFK1zhqpjERuhBA_Cw8lFCtsc-uDcgMMSrenYmGnlPt8cD49k7OGNzE-GAXjVoxaVUFNQSloP76C-Nh919ycDId6x8U6P9DkOojLRUhEaGRNPI5SopO7IAOWt3S7jgpczzRW70pC_tn3EEcxFPm67tb2c41PdXk2vxrOwRo38cXPA diff --git a/testing/test_main.py b/testing/test_main.py index 956c004b..612ec695 100644 --- a/testing/test_main.py +++ b/testing/test_main.py @@ -3,15 +3,13 @@ from openai_rev import openai_rev, Provider, quora, forefront # usage You response = openai_rev.Completion.create(Provider.You, prompt='Write a poem on Lionel Messi') print(response) -print(f'END') + # usage Poe -# token = quora.Account.create(logging=False) -token = 'GKzCahZYGKhp76LfE197xw==' +token = quora.Account.create(logging=False) response = openai_rev.Completion.create( Provider.Poe, prompt='Write a poem on Lionel Messi', token=token, model='ChatGPT' ) print(response) -print(f'END') # usage forefront token = forefront.Account.create(logging=False) @@ -19,3 +17,8 @@ response = openai_rev.Completion.create( Provider.ForeFront, prompt='Write a poem on Lionel Messi', model='gpt-4', token=token ) print(response) +print(f'END') + +# usage theb +response = openai_rev.Completion.create(Provider.Theb, prompt='Write a poem on Lionel Messi') +print(response) diff --git a/theb/theb_test.py b/theb/theb_test.py deleted file mode 100644 index 177c970a..00000000 --- a/theb/theb_test.py +++ /dev/null @@ -1,4 +0,0 @@ -import theb - -for token in theb.Completion.create('hello world'): - print(token, end='', flush=True)
\ No newline at end of file |