1
0
Fork 0

Merge branch 'main' into feature/delete_poe_account

This commit is contained in:
t.me/xtekky 2023-05-01 18:25:14 +01:00 committed by GitHub
commit bcd8592710
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 36 deletions

View file

@ -32,11 +32,11 @@ Just API's from some language model sites.
<td><a href="https://github.com/xtekky/chatgpt-clone/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td> <td><a href="https://github.com/xtekky/chatgpt-clone/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/xtekky/chatgpt-clone?style=flat-square&labelColor=343b41"/></a></td>
</tr> </tr>
<tr> <tr>
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free"><b>ChatGpt Discord Bot</b></a></td> <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free"><b>ChatGpt Discord Bot</b></a></td>
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/mishalhossin/Coding-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td> <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/mishalhossin/Coding-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td> <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/mishalhossin/Coding-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td> <td><a href="https://github.com/mishalhossin/Discord-Chatbot-Gpt4Free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
<td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/mishalhossin/Coding-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td> <td><a href="https://github.com/mishalhossin/Coding-Chatbot-Gpt4Free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/mishalhossin/Discord-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -86,7 +86,6 @@ Just API's from some language model sites.
| [sqlchat.ai](https://sqlchat.ai) | GPT-3.5 | | [sqlchat.ai](https://sqlchat.ai) | GPT-3.5 |
| [bard.google.com](https://bard.google.com) | custom / search | | [bard.google.com](https://bard.google.com) | custom / search |
| [bing.com/chat](https://bing.com/chat) | GPT-4/3.5 | | [bing.com/chat](https://bing.com/chat) | GPT-4/3.5 |
| [chat.forefront.ai/](https://chat.forefront.ai/) | GPT-4/3.5 |
## Best sites <a name="best-sites"></a> ## Best sites <a name="best-sites"></a>
@ -119,7 +118,7 @@ then run:
Build Build
``` ```
docker build -t gpt4free:latest -f Docker/Dockerfile . docker build -t gpt4free:latest .
``` ```
Run Run
@ -127,17 +126,13 @@ Run
``` ```
docker run -p 8501:8501 gpt4free:latest docker run -p 8501:8501 gpt4free:latest
``` ```
Another way - docker-compose (no docker build/run needed)
```
docker-compose up -d
```
## Deploy using docker-compose ## Deploy using docker-compose
Run the following: Run the following:
``` ```
docker-compose up -d docker-compose up --build -d
``` ```
## ChatGPT clone ## ChatGPT clone

View file

@ -3,7 +3,13 @@ version: "3.9"
services: services:
gpt4free: gpt4free:
build: build:
context: . context: ./
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: dc_gpt4free
# environment:
# - http_proxy=http://127.0.0.1:1080 # modify this for your proxy
# - https_proxy=http://127.0.0.1:1080 # modify this for your proxy
image: img_gpt4free
ports: ports:
- "8501:8501" - 8501:8501
restart: always

View file

@ -1,12 +0,0 @@
version: '3.8'
services:
gpt4:
build:
context: .
dockerfile: Dockerfile
image: gpt4free:latest
container_name: gpt4
ports:
- 8501:8501
restart: unless-stopped

View file

@ -6,8 +6,11 @@ from gpt4free import forefront
token = forefront.Account.create(logging=False) token = forefront.Account.create(logging=False)
print(token) print(token)
# get a response # get a response
for response in forefront.StreamingCompletion.create(token=token, for response in forefront.StreamingCompletion.create(
prompt='hello world', model='gpt-4'): token=token,
print(response.completion.choices[0].text, end='') prompt='hello world',
model='gpt-4'
):
print(response.choices[0].text, end='')
print("") print("")
``` ```

View file

@ -5,7 +5,10 @@
from gpt4free import theb from gpt4free import theb
# simple streaming completion # simple streaming completion
for token in theb.Completion.create('hello world'):
print(token, end='', flush=True) while True:
print("") x = input()
for token in theb.Completion.create(x):
print(token, end='', flush=True)
print("")
``` ```

View file

@ -17,6 +17,7 @@ class Completion:
timer = None timer = None
message_queue = Queue() message_queue = Queue()
stream_completed = False stream_completed = False
last_msg_id = None
@staticmethod @staticmethod
def request(prompt: str, proxy: Optional[str] = None): def request(prompt: str, proxy: Optional[str] = None):
@ -29,25 +30,34 @@ class Completion:
proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None
options = {}
if Completion.last_msg_id:
options['parentMessageId'] = Completion.last_msg_id
requests.post( requests.post(
'https://chatbot.theb.ai/api/chat-process', 'https://chatbot.theb.ai/api/chat-process',
headers=headers, headers=headers,
proxies=proxies, proxies=proxies,
content_callback=Completion.handle_stream_response, content_callback=Completion.handle_stream_response,
json={'prompt': prompt, 'options': {}}, json={'prompt': prompt, 'options': options},
) )
Completion.stream_completed = True Completion.stream_completed = True
@staticmethod @staticmethod
def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, None]: def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, None]:
Completion.stream_completed = False
Thread(target=Completion.request, args=[prompt, proxy]).start() Thread(target=Completion.request, args=[prompt, proxy]).start()
while not Completion.stream_completed or not Completion.message_queue.empty(): while not Completion.stream_completed or not Completion.message_queue.empty():
try: try:
message = Completion.message_queue.get(timeout=0.01) message = Completion.message_queue.get(timeout=0.01)
for message in findall(Completion.regex, message): for message in findall(Completion.regex, message):
yield loads(Completion.part1 + message + Completion.part2)['delta'] message_json = loads(Completion.part1 + message + Completion.part2)
Completion.last_msg_id = message_json['id']
yield message_json['delta']
except Empty: except Empty:
pass pass