File size: 3,221 Bytes
9d3162f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import unittest
import requests
class CaesarAPIUnit(unittest.TestCase):
    def createapitest(self):
        data = {"caesarapis":[{
  "api_name": "Caesar Translate",
  "auth": "none",
  "content_type": "application/json",
  "data": {"caesartranslate":"hello world","response":"true","language":"fr","triggerword":"translate"},
  "method": "POST ",
  "token": "none",
  "triggerwords": "translate",
  "url": "http://192.168.0.10:7860/caesarlangtranslate",
},
        {
  "api_name": "Caesar Send Text",
  "auth": "none",
  "content_type": "application/json",
  "data": {
    "text": "hello world",
  },
  "method": "POST ",
  "token": "none",
  "triggerwords": "send text",
  "url": "http://192.168.0.10:7860/caesartext",
}]}
        response = requests.post("http://192.168.0.10:7860/createcaesaraipi",json=data)
        print(response.json())
    def getapitest(self):
        response = requests.get("http://192.168.0.10:7860/getcaesaraipi")
        print(response.json())
    def triggerapitest(self):
        data = {"user_trigger":"translate"}
        response = requests.post("http://192.168.0.10:7860/triggerapi",json=data)
        print(response.json())
    def caesarvoicetest(self):
        data = {"text":"hello world"}
        response = requests.post("http://192.168.0.10:7860/caesarvoice",json=data)
        with open('textfile.wav', 'wb') as file:
            file.write(response.content)
        print(response)
    def caesarsummarize(self):
        with open("test.txt","r") as f:
            text = f.read()
        if len(text) < 4000:
            data = {"text":text}
            response = requests.post("http://192.168.0.10:7860/caesarsummarize",json=data)
            print(response.json())
        else:
            print("original text is too large")
    def caesarstockinfo(self):
        response = requests.post("http://192.168.0.10:7860/caesarstockinfo",json={"stock":"AAPL","start_date":"2023-02-05","end_date":"2023-02-07"})
        print(response.json())
    def caesarocr(self):
        import base64
        with open("artificial neural networks.png", "rb") as image_file:
            encoded_string = base64.b64encode(image_file.read()).decode('UTF-8')
        #print(encoded_string)
        response = requests.post("http://192.168.0.10:7860/caesarocr",json={"ocr_data":encoded_string})
        print(response.json())
    def faceauthorizeuser(self):
        url = 'https://palondomus-caesarai.hf.space/faceauthorizeuser'
        f = open("/home/amari/Desktop/CaesarAI/CaesarAIAPI/CaesarFaceRecognition/testimages/amari.jpg", 'rb')
        
        file = {'file': f}
        
        
        resp = requests.post(url=url, files=file,params={"user":"amari"}) 
        print(resp.json())
        f.read()
        f.close()
    def caesarfaceauth(self):
        url = 'https://palondomus-caesarai.hf.space/caesarfaceauth'
        f = open("/home/amari/Desktop/CaesarAI/CaesarAIAPI/CaesarFaceRecognition/testimages/amari.jpg", 'rb')
        
        file = {'file': f}
        
        
        resp = requests.post(url=url, files=file,params={"user":"amari"}) 
        print(resp.json())
        f.read()
        f.close()

    

      

if __name__ == "__main__":
    unittest.main()