File size: 731 Bytes
d23d39f
 
 
d65b1bc
 
d23d39f
 
d5614a9
d23d39f
 
 
 
 
d65b1bc
d23d39f
d65b1bc
d23d39f
d65b1bc
d23d39f
 
 
 
aa314ad
d23d39f
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
import aiohttp
import json
import re


class Hugging:
    def __init__(self):
        self.url = "https://p01--hugging--legal-stuff--a96n-7tyr.code.run/generate"
        self.headers = {
            "Authorization": "Bearer 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",
            "accept": "application/json",
            "content-type": "application/json",
        }

    async def chat(self, prompt: str):

        payload = {"prompt": prompt}

        async with aiohttp.ClientSession() as session:
            async with session.post(
                self.url, headers=self.headers, data=json.dumps(payload)
            ) as response:
                result = await response.json()
                return result