diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-08-17 14:50:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-17 14:50:35 +0200 |
commit | e8066c1df55c429a72e0770ee0e30a0ffc03f019 (patch) | |
tree | c8bc44917ea03909cf586140f984ff0814bc30ea /g4f/.v1/testing | |
parent | ~ | small fixes & new pypi version | v-0.0.1.9 (diff) | |
parent | refactor: refactor provider (diff) | |
download | gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.gz gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.bz2 gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.lz gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.xz gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.zst gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/.v1/testing/aiassistest.py | 13 | ||||
-rw-r--r-- | g4f/.v1/testing/aicolors_test.py | 6 | ||||
-rw-r--r-- | g4f/.v1/testing/deepai_test.py | 18 | ||||
-rw-r--r-- | g4f/.v1/testing/forefront_test.py | 9 | ||||
-rw-r--r-- | g4f/.v1/testing/gptworldai_test.py | 18 | ||||
-rw-r--r-- | g4f/.v1/testing/hpgptai_test.py | 41 | ||||
-rw-r--r-- | g4f/.v1/testing/italygpt2_test.py | 4 | ||||
-rw-r--r-- | g4f/.v1/testing/openaihosted_test.py | 14 | ||||
-rw-r--r-- | g4f/.v1/testing/poe_account_create_test.py | 109 | ||||
-rw-r--r-- | g4f/.v1/testing/poe_test.py | 13 | ||||
-rw-r--r-- | g4f/.v1/testing/quora_test_2.py | 12 | ||||
-rw-r--r-- | g4f/.v1/testing/sqlchat_test.py | 4 | ||||
-rw-r--r-- | g4f/.v1/testing/t3nsor_test.py | 4 | ||||
-rw-r--r-- | g4f/.v1/testing/test_main.py | 27 | ||||
-rw-r--r-- | g4f/.v1/testing/theb_test.py | 5 | ||||
-rw-r--r-- | g4f/.v1/testing/useless_test.py | 25 | ||||
-rw-r--r-- | g4f/.v1/testing/usesless_test.py | 13 | ||||
-rw-r--r-- | g4f/.v1/testing/writesonic_test.py | 35 | ||||
-rw-r--r-- | g4f/.v1/testing/you_test.py | 27 |
19 files changed, 0 insertions, 397 deletions
diff --git a/g4f/.v1/testing/aiassistest.py b/g4f/.v1/testing/aiassistest.py deleted file mode 100644 index 57a34f15..00000000 --- a/g4f/.v1/testing/aiassistest.py +++ /dev/null @@ -1,13 +0,0 @@ -import aiassist - -question1 = "Who won the world series in 2020?" -req = aiassist.Completion.create(prompt=question1) -answer = req["text"] -message_id = req["parentMessageId"] - -question2 = "Where was it played?" -req2 = aiassist.Completion.create(prompt=question2, parentMessageId=message_id) -answer2 = req2["text"] - -print(answer) -print(answer2) diff --git a/g4f/.v1/testing/aicolors_test.py b/g4f/.v1/testing/aicolors_test.py deleted file mode 100644 index 853f7e45..00000000 --- a/g4f/.v1/testing/aicolors_test.py +++ /dev/null @@ -1,6 +0,0 @@ -from gpt4free import aicolors - -prompt = "Light green color" -req = aicolors.Completion.create(prompt=prompt) - -print(req) diff --git a/g4f/.v1/testing/deepai_test.py b/g4f/.v1/testing/deepai_test.py deleted file mode 100644 index 474f663e..00000000 --- a/g4f/.v1/testing/deepai_test.py +++ /dev/null @@ -1,18 +0,0 @@ -from gpt4free import deepai - -#single completion -for chunk in deepai.Completion.create("Write a list of possible vacation destinations:"): - print(chunk, end="", flush=True) -print() - -#chat completion -print("==============") -messages = [ #taken from the openai docs - {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "Who won the world series in 2020?"}, - {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."}, - {"role": "user", "content": "Where was it played?"} -] -for chunk in deepai.ChatCompletion.create(messages): - print(chunk, end="", flush=True) -print()
\ No newline at end of file diff --git a/g4f/.v1/testing/forefront_test.py b/g4f/.v1/testing/forefront_test.py deleted file mode 100644 index b7b5c57c..00000000 --- a/g4f/.v1/testing/forefront_test.py +++ /dev/null @@ -1,9 +0,0 @@ -from gpt4free import forefront - -# create an account -token = forefront.Account.create(logging=True) -print(token) - -# get a response -for response in forefront.StreamingCompletion.create(token=token, prompt='hello world', model='gpt-4'): - print(response.text, end='') diff --git a/g4f/.v1/testing/gptworldai_test.py b/g4f/.v1/testing/gptworldai_test.py deleted file mode 100644 index 3dfb32ce..00000000 --- a/g4f/.v1/testing/gptworldai_test.py +++ /dev/null @@ -1,18 +0,0 @@ -import gptworldAi - -# single completion -for chunk in gptworldAi.Completion.create("你是谁", "127.0.0.1:7890"): - print(chunk, end="", flush=True) -print() - -# chat completion -message = [] -while True: - prompt = input("请输入问题:") - message.append({"role": "user", "content": prompt}) - text = "" - for chunk in gptworldAi.ChatCompletion.create(message, '127.0.0.1:7890'): - text = text + chunk - print(chunk, end="", flush=True) - print() - message.append({"role": "assistant", "content": text}) diff --git a/g4f/.v1/testing/hpgptai_test.py b/g4f/.v1/testing/hpgptai_test.py deleted file mode 100644 index cdd146dd..00000000 --- a/g4f/.v1/testing/hpgptai_test.py +++ /dev/null @@ -1,41 +0,0 @@ -import hpgptai - -#single completion -res = hpgptai.Completion.create("你是谁","127.0.0.1:7890") -print(res["reply"]) - - -#chat completion -messages = [ - { - "content": "你是谁", - "html": "你是谁", - "id": hpgptai.ChatCompletion.randomStr(), - "role": "user", - "who": "User: ", - }, - { - "content": "我是一位AI助手,专门为您提供各种服务和支持。我可以回答您的问题,帮助您解决问题,提供相关信息,并执行一些任务。请随时告诉我您需要什么帮助。", - "html": "我是一位AI助手,专门为您提供各种服务和支持。我可以回答您的问题,帮助您解决问题,提供相关信息,并执行一些任务。请随时告诉我您需要什么帮助。", - "id": hpgptai.ChatCompletion.randomStr(), - "role": "assistant", - "who": "AI: ", - }, - { - "content": "我上一句问的是什么?", - "html": "我上一句问的是什么?", - "id": hpgptai.ChatCompletion.randomStr(), - "role": "user", - "who": "User: ", - }, -] -res = hpgptai.ChatCompletion.create(messages,proxy="127.0.0.1:7890") -print(res["reply"]) - - - - - - - - diff --git a/g4f/.v1/testing/italygpt2_test.py b/g4f/.v1/testing/italygpt2_test.py deleted file mode 100644 index 0494c8a2..00000000 --- a/g4f/.v1/testing/italygpt2_test.py +++ /dev/null @@ -1,4 +0,0 @@ -from gpt4free import italygpt2 -account_data=italygpt2.Account.create() -for chunk in italygpt2.Completion.create(account_data=account_data,prompt="Who are you?"): - print(chunk, end="", flush=True)
\ No newline at end of file diff --git a/g4f/.v1/testing/openaihosted_test.py b/g4f/.v1/testing/openaihosted_test.py deleted file mode 100644 index d5a79e52..00000000 --- a/g4f/.v1/testing/openaihosted_test.py +++ /dev/null @@ -1,14 +0,0 @@ -import openaihosted - -messages = [{"role": "system", "content": "You are a helpful assistant."}] -while True: - question = input("Question: ") - if question == "!stop": - break - - messages.append({"role": "user", "content": question}) - request = openaihosted.Completion.create(messages=messages) - - response = request["responses"] - messages.append({"role": "assistant", "content": response}) - print(f"Answer: {response}") diff --git a/g4f/.v1/testing/poe_account_create_test.py b/g4f/.v1/testing/poe_account_create_test.py deleted file mode 100644 index 41ae5a33..00000000 --- a/g4f/.v1/testing/poe_account_create_test.py +++ /dev/null @@ -1,109 +0,0 @@ -from hashlib import md5 -from json import dumps -from re import findall -from typing import Optional - -from tls_client import Session as TLS -from twocaptcha import TwoCaptcha - -from gpt4free.quora import extract_formkey -from gpt4free.quora.mail import Emailnator - -solver = TwoCaptcha('') - - -class Account: - @staticmethod - def create(proxy: Optional[str] = None, logging: bool = False, enable_bot_creation: bool = False): - client = TLS(client_identifier='chrome110') - client.proxies = {'http': f'http://{proxy}', 'https': f'http://{proxy}'} if proxy else None - - mail_client = Emailnator() - mail_address = mail_client.get_mail() - - if logging: - print('email', mail_address) - - client.headers = { - 'authority': 'poe.com', - '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', - 'content-type': 'application/json', - 'origin': 'https://poe.com', - 'poe-formkey': 'null', - 'poe-tag-id': 'null', - 'poe-tchannel': 'null', - 'referer': 'https://poe.com/login', - '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', - } - - client.headers["poe-formkey"] = extract_formkey(client.get('https://poe.com/login').text) - client.headers["poe-tchannel"] = client.get('https://poe.com/api/settings').json()['tchannelData']['channel'] - - # token = reCaptchaV3('https://www.recaptcha.net/recaptcha/enterprise/anchor?ar=1&k=6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG&co=aHR0cHM6Ly9wb2UuY29tOjQ0Mw..&hl=en&v=4PnKmGB9wRHh1i04o7YUICeI&size=invisible&cb=bi6ivxoskyal') - token = solver.recaptcha( - sitekey='6LflhEElAAAAAI_ewVwRWI9hsyV4mbZnYAslSvlG', - url='https://poe.com/login?redirect_url=%2F', - version='v3', - enterprise=1, - invisible=1, - action='login', - )['code'] - - payload = dumps( - separators=(',', ':'), - obj={ - 'queryName': 'MainSignupLoginSection_sendVerificationCodeMutation_Mutation', - 'variables': {'emailAddress': mail_address, 'phoneNumber': None, 'recaptchaToken': token}, - 'query': 'mutation MainSignupLoginSection_sendVerificationCodeMutation_Mutation(\n $emailAddress: String\n $phoneNumber: String\n $recaptchaToken: String\n) {\n sendVerificationCode(verificationReason: login, emailAddress: $emailAddress, phoneNumber: $phoneNumber, recaptchaToken: $recaptchaToken) {\n status\n errorMessage\n }\n}\n', - }, - ) - - base_string = payload + client.headers["poe-formkey"] + 'WpuLMiXEKKE98j56k' - client.headers["poe-tag-id"] = md5(base_string.encode()).hexdigest() - - print(dumps(client.headers, indent=4)) - - response = client.post('https://poe.com/api/gql_POST', data=payload) - - if 'automated_request_detected' in response.text: - print('please try using a proxy / wait for fix') - - if 'Bad Request' in response.text: - if logging: - print('bad request, retrying...', response.json()) - quit() - - if logging: - print('send_code', response.json()) - - mail_content = mail_client.get_message() - mail_token = findall(r';">(\d{6,7})</div>', mail_content)[0] - - if logging: - print('code', mail_token) - - payload = dumps( - separators=(',', ':'), - obj={ - "queryName": "SignupOrLoginWithCodeSection_signupWithVerificationCodeMutation_Mutation", - "variables": {"verificationCode": str(mail_token), "emailAddress": mail_address, "phoneNumber": None}, - "query": "mutation SignupOrLoginWithCodeSection_signupWithVerificationCodeMutation_Mutation(\n $verificationCode: String!\n $emailAddress: String\n $phoneNumber: String\n) {\n signupWithVerificationCode(verificationCode: $verificationCode, emailAddress: $emailAddress, phoneNumber: $phoneNumber) {\n status\n errorMessage\n }\n}\n", - }, - ) - - base_string = payload + client.headers["poe-formkey"] + 'WpuLMiXEKKE98j56k' - client.headers["poe-tag-id"] = md5(base_string.encode()).hexdigest() - - response = client.post('https://poe.com/api/gql_POST', data=payload) - if logging: - print('verify_code', response.json()) - - -Account.create(proxy='', logging=True) diff --git a/g4f/.v1/testing/poe_test.py b/g4f/.v1/testing/poe_test.py deleted file mode 100644 index 6edc030c..00000000 --- a/g4f/.v1/testing/poe_test.py +++ /dev/null @@ -1,13 +0,0 @@ -from time import sleep - -from gpt4free import quora - -token = quora.Account.create(proxy=None, logging=True) -print('token', token) - -sleep(2) - -for response in quora.StreamingCompletion.create(model='ChatGPT', prompt='hello world', token=token): - print(response.text, flush=True) - -quora.Account.delete(token) diff --git a/g4f/.v1/testing/quora_test_2.py b/g4f/.v1/testing/quora_test_2.py deleted file mode 100644 index 297ca7a1..00000000 --- a/g4f/.v1/testing/quora_test_2.py +++ /dev/null @@ -1,12 +0,0 @@ -from gpt4free import quora - -token = quora.Account.create(logging=True, enable_bot_creation=True) - -model = quora.Model.create( - token=token, model='ChatGPT', system_prompt='you are ChatGPT a large language model ...' # or claude-instant-v1.0 -) - -print(model.name) - -for response in quora.StreamingCompletion.create(custom_model=model.name, prompt='hello world', token=token): - print(response.text) diff --git a/g4f/.v1/testing/sqlchat_test.py b/g4f/.v1/testing/sqlchat_test.py deleted file mode 100644 index 1db71be2..00000000 --- a/g4f/.v1/testing/sqlchat_test.py +++ /dev/null @@ -1,4 +0,0 @@ -import sqlchat - -for response in sqlchat.StreamCompletion.create(prompt='write python code to reverse a string', messages=[]): - print(response.completion.choices[0].text, end='') diff --git a/g4f/.v1/testing/t3nsor_test.py b/g4f/.v1/testing/t3nsor_test.py deleted file mode 100644 index 6d36400d..00000000 --- a/g4f/.v1/testing/t3nsor_test.py +++ /dev/null @@ -1,4 +0,0 @@ -import t3nsor - -for response in t3nsor.StreamCompletion.create(prompt='write python code to reverse a string', messages=[]): - print(response.completion.choices[0].text) diff --git a/g4f/.v1/testing/test_main.py b/g4f/.v1/testing/test_main.py deleted file mode 100644 index 7c28f1d2..00000000 --- a/g4f/.v1/testing/test_main.py +++ /dev/null @@ -1,27 +0,0 @@ -import gpt4free -from gpt4free import Provider, quora, forefront - -# usage You -response = gpt4free.Completion.create(Provider.You, prompt='Write a poem on Lionel Messi') -print(response) - -# usage Poe -token = quora.Account.create(logging=False) -response = gpt4free.Completion.create(Provider.Poe, prompt='Write a poem on Lionel Messi', token=token, model='ChatGPT') -print(response) - -# usage forefront -token = forefront.Account.create(logging=False) -response = gpt4free.Completion.create( - Provider.ForeFront, prompt='Write a poem on Lionel Messi', model='gpt-4', token=token -) -print(response) -print(f'END') - -# usage theb -response = gpt4free.Completion.create(Provider.Theb, prompt='Write a poem on Lionel Messi') -print(response) - -# usage cocalc -response = gpt4free.Completion.create(Provider.CoCalc, prompt='Write a poem on Lionel Messi', cookie_input='') -print(response) diff --git a/g4f/.v1/testing/theb_test.py b/g4f/.v1/testing/theb_test.py deleted file mode 100644 index 5fa80908..00000000 --- a/g4f/.v1/testing/theb_test.py +++ /dev/null @@ -1,5 +0,0 @@ -from gpt4free import theb - -for token in theb.Completion.create('hello world'): - print(token, end='', flush=True) - print('asdsos') diff --git a/g4f/.v1/testing/useless_test.py b/g4f/.v1/testing/useless_test.py deleted file mode 100644 index 47c92386..00000000 --- a/g4f/.v1/testing/useless_test.py +++ /dev/null @@ -1,25 +0,0 @@ -from gpt4free import usesless - -message_id = "" -while True: - prompt = input("Question: ") - if prompt == "!stop": - break - - req = usesless.Completion.create(prompt=prompt, parentMessageId=message_id) - - print(f"Answer: {req['text']}") - message_id = req["id"] - -import gpt4free - -message_id = "" -while True: - prompt = input("Question: ") - if prompt == "!stop": - break - - req = gpt4free.Completion.create(provider=gpt4free.Provider.UseLess, prompt=prompt, parentMessageId=message_id) - - print(f"Answer: {req['text']}") - message_id = req["id"] diff --git a/g4f/.v1/testing/usesless_test.py b/g4f/.v1/testing/usesless_test.py deleted file mode 100644 index e2e35547..00000000 --- a/g4f/.v1/testing/usesless_test.py +++ /dev/null @@ -1,13 +0,0 @@ -import usesless - -question1 = "Who won the world series in 2020?" -req = usesless.Completion.create(prompt=question1) -answer = req["text"] -message_id = req["parentMessageId"] - -question2 = "Where was it played?" -req2 = usesless.Completion.create(prompt=question2, parentMessageId=message_id) -answer2 = req2["text"] - -print(answer) -print(answer2) diff --git a/g4f/.v1/testing/writesonic_test.py b/g4f/.v1/testing/writesonic_test.py deleted file mode 100644 index aff847f0..00000000 --- a/g4f/.v1/testing/writesonic_test.py +++ /dev/null @@ -1,35 +0,0 @@ -# import writesonic -import writesonic - -# create account (3-4s) -account = writesonic.Account.create(logging=True) - -# with loging: -# 2023-04-06 21:50:25 INFO __main__ -> register success : '{"id":"51aa0809-3053-44f7-922a...' (2s) -# 2023-04-06 21:50:25 INFO __main__ -> id : '51aa0809-3053-44f7-922a-2b85d8d07edf' -# 2023-04-06 21:50:25 INFO __main__ -> token : 'eyJhbGciOiJIUzI1NiIsInR5cCI6Ik...' -# 2023-04-06 21:50:28 INFO __main__ -> got key : '194158c4-d249-4be0-82c6-5049e869533c' (2s) - -# simple completion -response = writesonic.Completion.create(api_key=account.key, prompt='hello world') - -print(response.completion.choices[0].text) # Hello! How may I assist you today? - -# conversation - -response = writesonic.Completion.create( - api_key=account.key, - prompt='what is my name ?', - enable_memory=True, - history_data=[{'is_sent': True, 'message': 'my name is Tekky'}, {'is_sent': False, 'message': 'hello Tekky'}], -) - -print(response.completion.choices[0].text) # Your name is Tekky. - -# enable internet - -response = writesonic.Completion.create( - api_key=account.key, prompt='who won the quatar world cup ?', enable_google_results=True -) - -print(response.completion.choices[0].text) # Argentina won the 2022 FIFA World Cup tournament held in Qatar ... diff --git a/g4f/.v1/testing/you_test.py b/g4f/.v1/testing/you_test.py deleted file mode 100644 index 1e9f6205..00000000 --- a/g4f/.v1/testing/you_test.py +++ /dev/null @@ -1,27 +0,0 @@ -from gpt4free import you - -# simple request with links and details -response = you.Completion.create(prompt="hello world", detailed=True, include_links=True) - -print(response) - -# { -# "response": "...", -# "links": [...], -# "extra": {...}, -# "slots": {...} -# } -# } - -# chatbot - -chat = [] - -while True: - prompt = input("You: ") - - response = you.Completion.create(prompt=prompt, chat=chat) - - print("Bot:", response.text) - - chat.append({"question": prompt, "answer": response.text}) |