Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
drakyanerlanggarizkiwardhana authored Apr 25, 2023
1 parent f212a5b commit 11ebe76
Show file tree
Hide file tree
Showing 91 changed files with 5,314 additions and 1 deletion.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

136 changes: 135 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,135 @@
# GPT-4-Free
# GPT4free - use ChatGPT, for free!!

<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 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 ; ).

By the way, thank you so much for `2k` stars and all the support!!


## Table of Contents

- [To do list](#todo)
- [Current Sites](#current-sites)
- [Best Sites for gpt4](#best-sites)
- [How to install](#install)
- [Legal Notice](#legal-notice)
- [Copyright](#copyright)


- [Usage Examples](./README.md)
- [`quora (poe)`](./quora/README.md)
- [`phind`](./phind/README.md)
- [`t3nsor`](./t3nsor/README.md)
- [`ora`](./ora/README.md)
- [`writesonic`](./writesonic/README.md)
- [`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 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>

| Website | Model(s) |
| ---------------------------------------------------- | ------------------------------- |
| [ora.sh](https://ora.sh) | GPT-3.5 / 4 |
| [poe.com](https://poe.com) | GPT-4/3.5 |
| [writesonic.com](https://writesonic.com) | GPT-3.5 / Internet |
| [t3nsor.com](https://t3nsor.com) | GPT-3.5 |
| [you.com](https://you.com) | GPT-3.5 / Internet / good search|
| [phind.com](https://phind.com) | GPT-4 / Internet / good search |
| [sqlchat.ai](https://sqlchat.ai) | GPT-3.5 |
| [chat.openai.com/chat](https://chat.openai.com/chat) | GPT-3.5 |
| [bard.google.com](https://bard.google.com) | custom / search |
| [bing.com/chat](https://bing.com/chat) | GPT-4/3.5 |

## Best sites <a name="best-sites"></a>

#### gpt-4
- [`/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
- [`/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
install requirements with:
```sh
pip3 install -r requirements.txt
```

## To start gpt4free GUI
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
> https://chat.chatbot.sex/chat
> This site was developed by me and includes **gpt-4/3.5**, **internet access** and **gpt-jailbreak's** like DAN
> run locally here: https://github.com/xtekky/chatgpt-clone
## Legal Notice <a name="legal-notice"></a>

This repository uses third-party APIs and AI models and is *not* associated with or endorsed by the API providers or the original developers of the models. This project is intended **for educational purposes only**.

Please note the following:

1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is *not* claiming any right over them.

2. **Responsibility**: The author of this repository is *not* responsible for any consequences arising from the use or misuse of this repository or the content provided by the third-party APIs and any damage or losses caused by users' actions.

3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations.

## Copyright:
This program is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt)

Most code, with the exception of `quora/api.py` (by [ading2210](https://github.com/ading2210)), has been written by me, [xtekky](https://github.com/xtekky).

### Copyright Notice: <a name="copyright"></a>
```
xtekky/openai-gpt4: multiple reverse engineered language-model api's to decentralise the ai industry.
Copyright (C) 2023 xtekky
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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
16 changes: 16 additions & 0 deletions gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

.idea/

*/__pycache__/

*.log

cookie.json
9 changes: 9 additions & 0 deletions gui/README.md
Original file line number Diff line number Diff line change
@@ -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">
48 changes: 48 additions & 0 deletions gui/streamlit_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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
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",
initial_sidebar_state="expanded",
page_icon="🧠",
menu_items={
'Get Help': 'https://github.com/xtekky/gpt4free/blob/main/README.md',
'Report a bug': "https://github.com/xtekky/gpt4free/issues",
'About': "### gptfree GUI"
}
)

st.header('GPT4free GUI')

question_text_area = st.text_area('🤖 Ask Any Question :', placeholder='Explain quantum computing in 50 words')
if st.button('🧠 Think'):
answer = phind_get_answer(question_text_area)
st.caption("Answer :")
st.markdown(answer)


hide_streamlit_style = """
<style>
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
49 changes: 49 additions & 0 deletions ora/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
### Example: `ora` (use like openai pypi package) <a name="example-ora"></a>

### load model (new)

more gpt4 models in `/testing/ora_gpt4.py`

find the userid by visiting https://ora.sh/api/auth/session ( must be logged in on the site )
and session_token in the cookies, it should be: __Secure-next-auth.session-token

```python
# if using CompletionModel.load set these
ora.user_id = '...'
ora.session_token = '...'

# normal gpt-4: b8b12eaa-5d47-44d3-92a6-4d706f2bcacf
model = ora.CompletionModel.load(chatbot_id, 'gpt-4') # or gpt-3.5
```

#### create model / chatbot:
```python
# import ora
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)

while True:
# pass in conversationId to continue conversation

prompt = input('>>> ')
response = ora.Completion.create(
model = model,
prompt = prompt,
includeHistory = True, # remember history
conversationId = init.id)

print(response.completion.choices[0].text)
```
62 changes: 62 additions & 0 deletions ora/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from ora.model import CompletionModel
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

class Completion:
def create(
model : CompletionModel,
prompt: str,
includeHistory: bool = True,
conversationId: str or None = None) -> OraResponse:
extra = {
'conversationId': conversationId} if conversationId else {}

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",
"authorization" : f"Bearer AY0{randint(1111, 9999)}",
"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 = json_data).json()

if response.get('error'):
raise Exception('''set ora.user_id and ora.session_token\napi response: %s''' % response['error'])

return OraResponse({
'id' : response['conversationId'],
'object' : 'text_completion',
'created': int(time()),
'model' : model.slug,
'choices': [{
'text' : response['response'],
'index' : 0,
'logprobs' : None,
'finish_reason' : 'stop'
}],
'usage': {
'prompt_tokens' : len(prompt),
'completion_tokens' : len(response['response']),
'total_tokens' : len(prompt) + len(response['response'])
}
})
Loading

0 comments on commit 11ebe76

Please sign in to comment.