diff options
author | hp256 <971748116@qq.com> | 2023-05-23 10:10:13 +0200 |
---|---|---|
committer | hp256 <971748116@qq.com> | 2023-05-23 10:10:13 +0200 |
commit | 25dcf166a74151c5729be9c7901aedd7afd0b8f8 (patch) | |
tree | c9390296cf5ddaa3f512c9c0fafcdf6f1bdf81eb | |
parent | Merge branch 'xtekky:main' into main (diff) | |
download | gpt4free-25dcf166a74151c5729be9c7901aedd7afd0b8f8.tar gpt4free-25dcf166a74151c5729be9c7901aedd7afd0b8f8.tar.gz gpt4free-25dcf166a74151c5729be9c7901aedd7afd0b8f8.tar.bz2 gpt4free-25dcf166a74151c5729be9c7901aedd7afd0b8f8.tar.lz gpt4free-25dcf166a74151c5729be9c7901aedd7afd0b8f8.tar.xz gpt4free-25dcf166a74151c5729be9c7901aedd7afd0b8f8.tar.zst gpt4free-25dcf166a74151c5729be9c7901aedd7afd0b8f8.zip |
-rw-r--r-- | gpt4free/oraai/README.md | 20 | ||||
-rw-r--r-- | gpt4free/oraai/__init__.py | 102 |
2 files changed, 0 insertions, 122 deletions
diff --git a/gpt4free/oraai/README.md b/gpt4free/oraai/README.md deleted file mode 100644 index 6f538711..00000000 --- a/gpt4free/oraai/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# OraAI -Written by [hp_mzx](https://github.com/hpsj). - -## Examples: -### Completion: -```python -chunk = oraai.Completion.create("who are you") -print(chunk) -``` - -### Chat Completion: -Support context -```python -obj = oraai.Completion() -whilt True: - prompt = input("Please enter a question:") - chunk = obj.create(prompt) - print(chunk) -print() -```
\ No newline at end of file diff --git a/gpt4free/oraai/__init__.py b/gpt4free/oraai/__init__.py deleted file mode 100644 index 99a70098..00000000 --- a/gpt4free/oraai/__init__.py +++ /dev/null @@ -1,102 +0,0 @@ -import time -import json -import uuid -import random -import requests -from fake_useragent import UserAgent - - -class ChatCompletion: - def __init__(self,proxy=None,chatbotId="5111b690-edd3-403f-b02a-607332d059f9"): - self.userId = "auto:"+str(uuid.uuid4()) - self.chatbotId = chatbotId - self.proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None - self.conversationId = None - self.headers = { - "Content-Type": "application/json", - "Origin": "https://ora.ai", - "Referer": "https://ora.ai/", - 'user-agent': UserAgent().random, - } - - def create(self,prompt: str): - url = "https://ora.ai/api/conversation" - data = { - "chatbotId": self.chatbotId, - "config": False, - "includeHistory": True, - "input": prompt, - "provider": "OPEN_AI", - "userId": self.userId, - } - - if self.conversationId: - data["conversationId"] = self.conversationId - response = requests.post( - url, - data=json.dumps(data), - proxies=self.proxies, - headers=self.headers - ) - if response.status_code == 200: - response_json = response.json() - self.conversationId = response_json["conversationId"] - return response_json["response"] - - raise ValueError(response.text) - - - def generate_image(self,prompt:str): - url = "https://ora.ai/api/images/request" - data = { - "prompt":prompt, - "seed":random.randint(0, 4294967295) - } - response = requests.post( - url, - data=json.dumps(data), - proxies=self.proxies, - headers=self.headers - ) - if response.status_code == 200: - inferenceId = response.json()["id"] - else: - raise ValueError(response.text) - - data = { - "chatbotId":self.chatbotId, - "inferenceId":inferenceId, - "userId":self.userId, - "userInput":"/generate " + prompt - } - print(data) - if self.conversationId: - data["conversationId"] = self.conversationId - while True: - response = requests.post( - "https://ora.ai/api/images/check", - data=json.dumps(data), - proxies=self.proxies, - headers=self.headers - ) - if response.status_code == 200: - response_json = response.json() - if response_json.get("conversationId"): - self.conversationId = response_json["conversationId"] - return response_json["inference"]["images"][0]["uri"] - else: - time.sleep(0.5) - else: - raise ValueError(response.text) - - -class Completion: - @classmethod - def create(self, prompt, proxy): - return ChatCompletion(proxy).create(prompt) - - - - - - |