XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

update(docker-compose.yml): Removed docker-compose.yml

ccd74eda
valerii@valeriis-air.(none) <valery.chirkov99@gmail.com>
提交于

代码差异

2 个文件 +42 -53
Deleted docker-compose.yml +0 -14
@@ -1,14 +0,0 @@
1 version: '3.8'
2
3 services:
4 gpt4:
5 build:
6 context: .
7 dockerfile: Dockerfile
8 image: gpt4free:latest
9 container_name: gpt4
10 ports:
11 - 8501:8501
12 restart: unless-stopped
13 read_only: true
14
Modified gpt4free/forefront/__init__.py +42 -39
@@ -1,47 +1,59 @@
1 from json import loads
2 from re import findall
3 from time import time, sleep
1 import re
2 import time
4 3 from typing import Generator, Optional
5 4 from uuid import uuid4
6 5
7 from fake_useragent import UserAgent
8 from requests import post
9 from pymailtm import MailTm, Message
10 from tls_client import Session
6 import fake_useragent
7 import pymailtm
8 import requests
11 9
12 10 from .typing import ForeFrontResponse
13 11
14 12
13 def speed_logging(func):
14 def wrapper(*args, **kwargs):
15 start = time.time()
16 res = func(*args, **kwargs)
17 print(time() - start)
18 return res
19 return wrapper
20
21
15 22 class Account:
23 @speed_logging
16 24 @staticmethod
17 def create(proxy: Optional[str] = None, logging: bool = False):
18 proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
25 def create_forefront_account(proxy: Optional[str] = None) -> Optional[str]:
26 """Create a ForeFront account.
27
28 Args:
29 proxy: The proxy to use for the request.
19 30
20 start = time()
31 Returns:
32 The ForeFront token if successful, else None.
33 """
34 proxies = {'http': f'http://{proxy}', 'https': f'http://{proxy}'} if proxy else None
21 35
22 mail_client = MailTm().get_account()
36 mail_client = pymailtm.MailTm().get_account()
23 37 mail_address = mail_client.address
24 38
25 client = Session(client_identifier='chrome110')
26 client.proxies = proxies
27 client.headers = {
39 session = requests.Session()
40 session.proxies = proxies
41 session.headers = {
28 42 'origin': 'https://accounts.forefront.ai',
29 'user-agent': UserAgent().random,
43 'user-agent': fake_useragent.UserAgent().random,
30 44 }
31 45
32 response = client.post(
46 response = session.post(
33 47 'https://clerk.forefront.ai/v1/client/sign_ups?_clerk_js_version=4.38.4',
34 48 data={'email_address': mail_address},
35 49 )
36 50
37 51 try:
38 52 trace_token = response.json()['response']['id']
39 if logging:
40 print(trace_token)
41 53 except KeyError:
42 return 'Failed to create account!'
54 return None
43 55
44 response = client.post(
56 response = session.post(
45 57 f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.38.4',
46 58 data={
47 59 'strategy': 'email_link',
@@ -49,38 +61,26 @@ class Account:
49 61 },
50 62 )
51 63
52 if logging:
53 print(response.text)
54
55 64 if 'sign_up_attempt' not in response.text:
56 return 'Failed to create account!'
65 return None
57 66
58 67 while True:
59 sleep(1)
60 new_message: Message = mail_client.wait_for_message()
61 if logging:
62 print(new_message.data['id'])
63
64 verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message.text)[0]
68 time.sleep(1)
69 new_message = mail_client.wait_for_message()
65 70
71 verification_url = re.findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message.text)
66 72 if verification_url:
67 73 break
68 74
69 if logging:
70 print(verification_url)
75 response = session.get(verification_url[0])
71 76
72 response = client.get(verification_url)
73
74 response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
77 response = session.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
75 78
76 79 token = response.json()['response']['sessions'][0]['last_active_token']['jwt']
77 80
78 81 with open('accounts.txt', 'a') as f:
79 82 f.write(f'{mail_address}:{token}\n')
80 83
81 if logging:
82 print(time() - start)
83
84 84 return token
85 85
86 86
@@ -100,7 +100,7 @@ class StreamingCompletion:
100 100 if not chat_id:
101 101 chat_id = str(uuid4())
102 102
103 proxies = { 'http': 'http://' + proxy, 'https': 'http://' + proxy } if proxy else None
103 proxies = { 'http': f'http://{proxy}', 'https': f'http://{proxy}' } if proxy else None
104 104
105 105 headers = {
106 106 'authority': 'chat-server.tenant-forefront-default.knative.chi.coreweave.com',
@@ -191,3 +191,6 @@ class Completion:
191 191 raise Exception('Unable to get the response, Please try again')
192 192
193 193 return final_response
194
195
196