AchyuthGamer commited on
Commit
665f833
1 Parent(s): 7a2562e

Delete g4f/Provider/Providers/Ails.py

Browse files
Files changed (1) hide show
  1. g4f/Provider/Providers/Ails.py +0 -87
g4f/Provider/Providers/Ails.py DELETED
@@ -1,87 +0,0 @@
1
- import os
2
- import time
3
- import json
4
- import uuid
5
- import hashlib
6
- import requests
7
-
8
- from ...typing import sha256, Dict, get_type_hints
9
- from datetime import datetime
10
-
11
- url: str = 'https://ai.ls'
12
- model: str = 'gpt-3.5-turbo'
13
- supports_stream = True
14
- needs_auth = False
15
- working = True
16
-
17
-
18
- class Utils:
19
- def hash(json_data: Dict[str, str]) -> sha256:
20
-
21
- base_string: str = '%s:%s:%s:%s' % (
22
- json_data['t'],
23
- json_data['m'],
24
- 'WI,2rU#_r:r~aF4aJ36[.Z(/8Rv93Rf',
25
- len(json_data['m'])
26
- )
27
-
28
- return hashlib.sha256(base_string.encode()).hexdigest()
29
-
30
- def format_timestamp(timestamp: int) -> str:
31
-
32
- e = timestamp
33
- n = e % 10
34
- r = n + 1 if n % 2 == 0 else n
35
- return str(e - n + r)
36
-
37
-
38
- def _create_completion(model: str, messages: list, temperature: float = 0.6, stream: bool = False, **kwargs):
39
-
40
- headers = {
41
- 'authority': 'api.caipacity.com',
42
- 'accept': '*/*',
43
- 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
44
- 'authorization': 'Bearer free',
45
- 'client-id': str(uuid.uuid4()),
46
- 'client-v': '0.1.249',
47
- 'content-type': 'application/json',
48
- 'origin': 'https://ai.ls',
49
- 'referer': 'https://ai.ls/',
50
- 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
51
- 'sec-ch-ua-mobile': '?0',
52
- 'sec-ch-ua-platform': '"Windows"',
53
- 'sec-fetch-dest': 'empty',
54
- 'sec-fetch-mode': 'cors',
55
- 'sec-fetch-site': 'cross-site',
56
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
57
- }
58
-
59
- timestamp = Utils.format_timestamp(int(time.time() * 1000))
60
-
61
- sig = {
62
- 'd': datetime.now().strftime('%Y-%m-%d'),
63
- 't': timestamp,
64
- 's': Utils.hash({
65
- 't': timestamp,
66
- 'm': messages[-1]['content']})}
67
-
68
- json_data = json.dumps(separators=(',', ':'), obj={
69
- 'model': 'gpt-3.5-turbo',
70
- 'temperature': 0.6,
71
- 'stream': True,
72
- 'messages': messages} | sig)
73
-
74
- response = requests.post('https://api.caipacity.com/v1/chat/completions',
75
- headers=headers, data=json_data, stream=True)
76
-
77
- for token in response.iter_lines():
78
- if b'content' in token:
79
- completion_chunk = json.loads(token.decode().replace('data: ', ''))
80
- token = completion_chunk['choices'][0]['delta'].get('content')
81
- if token != None:
82
- yield token
83
-
84
-
85
- params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
86
- '(%s)' % ', '.join(
87
- [f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])