summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Docker/Dockerfile11
-rw-r--r--README.md56
-rw-r--r--gui/README.md9
-rw-r--r--gui/streamlit_app.py (renamed from streamlit_app.py)25
-rw-r--r--ora/__init__.py19
-rw-r--r--ora/_jwt.py75
-rw-r--r--ora/model.py12
-rw-r--r--phind/README.md2
-rw-r--r--phind/__init__.py2
-rw-r--r--testing/ora_test.py15
-rw-r--r--testing/phind_test.py (renamed from phind/phind_test.py)8
11 files changed, 184 insertions, 50 deletions
diff --git a/Docker/Dockerfile b/Docker/Dockerfile
new file mode 100644
index 00000000..89ca0e5d
--- /dev/null
+++ b/Docker/Dockerfile
@@ -0,0 +1,11 @@
+FROM python:3.10
+
+RUN apt-get update && apt-get install -y git
+
+RUN git clone https://github.com/xtekky/gpt4free.git
+WORKDIR /gpt4free
+RUN pip install --no-cache-dir -r requirements.txt
+
+EXPOSE 8501
+
+CMD ["streamlit", "run", "streamlit_app.py"]
diff --git a/README.md b/README.md
index 45eb0621..f86c47eb 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
<img width="1383" alt="image" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
-Have you ever come across some amazing projects that you couldnt use **just because you didn't have an OpenAI API key?**
+Have you ever come across some amazing projects that you couldn't use **just because you didn't have an OpenAI API key?**
-**We've got you covered!** This repository offers **reverse-engineered** third-party APIs for `GPT-4/3.5`, sourced from various websites. You can simply **download** this repository and use the available modules, which are designed to be used **just like OpenAI's official package**. **Unleash ChatGPT's potential for your projects, now!** You are welcome ; ).
+**We've got you covered!** This repository offers **reverse-engineered** third-party APIs for `GPT-4/3.5`, sourced from various websites. You can simply **download** this repository, and use the available modules, which are designed to be used **just like OpenAI's official package**. **Unleash ChatGPT's potential for your projects, now!** You are welcome ; ).
By the way, thank you so much for `2k` stars and all the support!!
@@ -28,14 +28,17 @@ By the way, thank you so much for `2k` stars and all the support!!
- [`you`](./you/README.md)
- [`sqlchat`](./sqlchat/README.md)
+- [replit Example (feel free to fork this repl)](#replit)
+
+
## Todo <a name="todo"></a>
-- [ ] add a GUI for the repo
-- [ ] make a general package like `openai_rev`, instead of different folders
-- [ ] live api status to know which are down and which can be used
-- [ ] integrate more api's in `./unfinished` aswell as other ones in the lists
-- [ ] make an api to use as proxy for other projects
-- [ ] make a pypi package
+- [ ] Add a GUI for the repo
+- [ ] Make a general package named `openai_rev`, instead of different folders
+- [ ] Live api status to know which are down and which can be used
+- [ ] Integrate more API's in `./unfinished` as well as other ones in the lists
+- [ ] Make an API to use as proxy for other projects
+- [ ] Make a pypi package
## Current Sites <a name="current-sites"></a>
@@ -55,29 +58,36 @@ By the way, thank you so much for `2k` stars and all the support!!
## Best sites <a name="best-sites"></a>
#### gpt-4
-- [`/ora`](./ora/README.md)
-- here is proof / test: [`ora_gpt4_proof.py`](./testing/ora_gpt4_proof.py)
-- why ?, no streaming compared to poe.com but u can send more than 1 message
-- update: you need to use session token now and there is a limit, accounts are only google so no creator for now
+- [`/phind`](./ora/README.md)
+- pro: only stable gpt-4 with streaming ( no limit )
+- contra: weird backend prompting
+- why not `ora` anymore ? gpt-4 requires login + limited
#### gpt-3.5
-- [`/sqlchat`](./sqlchat/README.md)
-- why ? (streaming + you can give conversation history)
-
-#### search
-- [`/phind`](./phind/README.md)
-- why ? its not sure if they use gpt, but rather claude but they have an amazing search and good reasoning model
+- [`/ora`](./ora/README.md)
+- only stable api at the moment ( for gpt-3.5, gpt-4 is dead)
## Install <a name="install"></a>
-- download or clone this GitHub repo
-
+download or clone this GitHub repo
install requirements with:
```sh
pip3 install -r requirements.txt
```
+
## To start gpt4free GUI
-To start gpt4free GUI run the following command :
-`streamlit run streamlit_app.py`
+move `streamlit_app.py` from `./gui` to the base folder
+then run:
+`streamlit run streamlit_app.py` or `python3 -m streamlit run streamlit_app.py`
+
+## Docker
+Build
+```
+docker build -t gpt4free:latest -f Docker/Dockerfile .
+```
+Run
+```
+docker run -p 8501:8501 gpt4free:latest
+```
## ChatGPT clone
> currently implementing new features and trying to scale it, please be patient it may be unstable
@@ -121,3 +131,5 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
```
+## replit
+You can fork this repl to host your own ChatGPT-clone WebUI. https://replit.com/@gpt4free/gpt4free-webui
diff --git a/gui/README.md b/gui/README.md
new file mode 100644
index 00000000..379cf155
--- /dev/null
+++ b/gui/README.md
@@ -0,0 +1,9 @@
+# gpt4free gui
+
+preview:
+
+<img width="1125" alt="image" src="https://user-images.githubusercontent.com/98614666/234232398-09e9d3c5-08e6-4b8a-b4f2-0666e9790c7d.png">
+
+run:
+
+<img width="724" alt="image" src="https://user-images.githubusercontent.com/98614666/234232449-0d5cd092-a29d-4759-8197-e00ba712cb1a.png">
diff --git a/streamlit_app.py b/gui/streamlit_app.py
index 97bdf694..ff1cb6d4 100644
--- a/streamlit_app.py
+++ b/gui/streamlit_app.py
@@ -1,19 +1,24 @@
import streamlit as st
import phind
+phind.cf_clearance = ''
+phind.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'
+
def phind_get_answer(question:str)->str:
# set cf_clearance cookie
- phind.cf_clearance = 'heguhSRBB9d0sjLvGbQECS8b80m2BQ31xEmk9ChshKI-1682268995-0-160'
- phind.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'
- result = phind.Completion.create(
- model = 'gpt-4',
- prompt = question,
- results = phind.Search.create(question, actualSearch = True),
- creative = False,
- detailed = False,
- codeContext = '')
- return result.completion.choices[0].text
+ try:
+
+ result = phind.Completion.create(
+ model = 'gpt-4',
+ prompt = question,
+ results = phind.Search.create(question, actualSearch = True),
+ creative = False,
+ detailed = False,
+ codeContext = '')
+ return result.completion.choices[0].text
+ except Exception as e:
+ return 'An error occured, please make sure you are using a cf_clearance token and correct useragent | %s' % e
st.set_page_config(
page_title="gpt4freeGUI",
diff --git a/ora/__init__.py b/ora/__init__.py
index 36e14cd5..db8252cd 100644
--- a/ora/__init__.py
+++ b/ora/__init__.py
@@ -3,6 +3,7 @@ from ora.typing import OraResponse
from requests import post
from time import time
from random import randint
+from ora._jwt import do_jwt
user_id = None
session_token = None
@@ -19,6 +20,15 @@ class Completion:
cookies = {
"cookie" : f"__Secure-next-auth.session-token={session_token}"} if session_token else {}
+ json_data = extra | {
+ 'chatbotId': model.id,
+ 'input' : prompt,
+ 'userId' : user_id if user_id else model.createdBy,
+ 'model' : model.modelName,
+ 'provider' : 'OPEN_AI',
+ 'includeHistory': includeHistory}
+
+
response = post('https://ora.sh/api/conversation',
headers = cookies | {
"host" : "ora.sh",
@@ -26,14 +36,9 @@ 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",
"origin" : "https://ora.sh",
"referer" : "https://ora.sh/chat/",
+ "x-signed-token": do_jwt(json_data)
},
- json = extra | {
- 'chatbotId': model.id,
- 'input' : prompt,
- 'userId' : user_id if user_id else model.createdBy,
- 'model' : model.modelName,
- 'provider' : 'OPEN_AI',
- 'includeHistory': includeHistory}).json()
+ json = json_data).json()
if response.get('error'):
raise Exception('''set ora.user_id and ora.session_token\napi response: %s''' % response['error'])
diff --git a/ora/_jwt.py b/ora/_jwt.py
new file mode 100644
index 00000000..cc8b2349
--- /dev/null
+++ b/ora/_jwt.py
@@ -0,0 +1,75 @@
+import jwt
+from datetime import datetime, timedelta
+# from cryptography.hazmat.primitives import serialization
+# from cryptography.hazmat.primitives.serialization import load_pem_private_key
+# from cryptography.hazmat.backends import default_backend
+
+
+def do_jwt(json_data: dict):
+
+ private_key = b'''-----BEGIN RSA PRIVATE KEY-----
+MIIJKAIBAAKCAgEAxv9TLZP2TnsR512LqzT52N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256',
+ 'typ': 'JWT',
+ 'kid': '0d1bb0d7-45e4-445c-889e-57419470a570'
+ }
+
+ payload = {
+ **json_data,
+ 'iat': int(datetime.now().timestamp()),
+ 'exp': int((datetime.now() + timedelta(minutes=10)).timestamp()),
+ 'iss': 'https://ora.sh'
+ }
+
+ return jwt.encode(payload, private_key, algorithm='RS256', headers=header) \ No newline at end of file
diff --git a/ora/model.py b/ora/model.py
index 7c967625..34720c2d 100644
--- a/ora/model.py
+++ b/ora/model.py
@@ -20,6 +20,12 @@ class CompletionModel:
CompletionModel.description = description
CompletionModel.slug = name
+ json_data = {
+ 'prompt' : system_prompt,
+ 'userId' : f'auto:{uuid4()}',
+ 'name' : name,
+ 'description': description}
+
headers = {
'Origin' : 'https://ora.sh',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15',
@@ -27,11 +33,7 @@ class CompletionModel:
'Host' : 'ora.sh',
}
- response = post('https://ora.sh/api/assistant', headers = headers, json = {
- 'prompt' : system_prompt,
- 'userId' : f'auto:{uuid4()}',
- 'name' : name,
- 'description': description})
+ response = post('https://ora.sh/api/assistant', headers = headers, json = json_data)
print(response.json())
diff --git a/phind/README.md b/phind/README.md
index f17f487f..806bdf49 100644
--- a/phind/README.md
+++ b/phind/README.md
@@ -3,7 +3,7 @@
```python
import phind
-# set cf_clearance cookie
+# set cf_clearance cookie (needed again)
phind.cf_clearance = 'xx.xx-1682166681-0-160'
phind.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' # same as the one from browser you got cf_clearance from
diff --git a/phind/__init__.py b/phind/__init__.py
index 629befa5..9b1650e0 100644
--- a/phind/__init__.py
+++ b/phind/__init__.py
@@ -8,7 +8,7 @@ from re import findall
from curl_cffi.requests import post
cf_clearance = ''
-user_agent = ''
+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 PhindResponse:
diff --git a/testing/ora_test.py b/testing/ora_test.py
new file mode 100644
index 00000000..5144be14
--- /dev/null
+++ b/testing/ora_test.py
@@ -0,0 +1,15 @@
+import ora
+
+
+# create model
+model = ora.CompletionModel.create(
+ system_prompt = 'You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible',
+ description = 'ChatGPT Openai Language Model',
+ name = 'gpt-3.5')
+
+# init conversation (will give you a conversationId)
+init = ora.Completion.create(
+ model = model,
+ prompt = 'hello world')
+
+print(init.completion.choices[0].text) \ No newline at end of file
diff --git a/phind/phind_test.py b/testing/phind_test.py
index 94354fd8..d72db090 100644
--- a/phind/phind_test.py
+++ b/testing/phind_test.py
@@ -1,8 +1,8 @@
import phind
-# set cf_clearance cookie
-phind.cf_clearance = 'heguhSRBB9d0sjLvGbQECS8b80m2BQ31xEmk9ChshKI-1682268995-0-160'
-phind.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'
+# set cf_clearance cookie ( not needed at the moment)
+phind.cf_clearance = ''
+phind.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'
prompt = 'hello world'
@@ -22,7 +22,7 @@ prompt = 'who won the quatar world cup'
# help needed: not getting newlines from the stream, please submit a PR if you know how to fix this
# stream completion
for result in phind.StreamingCompletion.create(
- model = 'gpt-3.5',
+ model = 'gpt-4',
prompt = prompt,
results = phind.Search.create(prompt, actualSearch = True), # create search (set actualSearch to False to disable internet)
creative = False,