File size: 2,121 Bytes
2f158fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
094aba4
 
2f158fd
 
 
602cdee
2f158fd
 
094aba4
2f158fd
 
 
 
1f5c55e
9ae9fc9
ab83f61
 
 
 
9ae9fc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2020-2023 (c) Randy W @xtdevs, @xtsea
#
# from : https://github.com/TeamKillerX
# Channel : @RendyProjects
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import os

import requests
from dotenv import load_dotenv

load_dotenv()
HUGGING_TOKEN = os.environ["HUGGINGTOKEN_1"]
SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]


def ryuzaki_ai_text(text):
    API_URL = SOURCE_ALPHA_URL
    headers = {"Authorization": f"Bearer {HUGGING_TOKEN}"}
    response = requests.post(API_URL, headers=headers, json={"inputs": text})
    return response.json()

try:
    from aiohttp import ClientSession as aiohttp_client
except ImportError:
    aiohttp_client = None

async def async_searcher(
    url: str,
    post: bool = False,
    head: bool = False,
    headers: dict = None,
    evaluate=None,
    object: bool = False,
    re_json: bool = False,
    re_content: bool = False,
    *args,
    **kwargs,
):
    if aiohttp_client:
        async with aiohttp_client(headers=headers) as client:
            method = client.head if head else (client.post if post else client.get)
            data = await method(url, *args, **kwargs)
            if evaluate:
                return await evaluate(data)
            if re_json:
                return await data.json()
            if re_content:
                return await data.read()
            if head or object:
                return data
            return await data.text()
    else:
        return "Error"