worqhat 1.0__py3-none-any.whl → 3.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- worqhat/__init__.py +90 -10
- worqhat/_base_client.py +1992 -0
- worqhat/_client.py +467 -0
- worqhat/_compat.py +219 -0
- worqhat/_constants.py +14 -0
- worqhat/_exceptions.py +108 -0
- worqhat/_files.py +123 -0
- worqhat/_models.py +829 -0
- worqhat/_qs.py +150 -0
- worqhat/_resource.py +43 -0
- worqhat/_response.py +830 -0
- worqhat/_streaming.py +333 -0
- worqhat/_types.py +219 -0
- worqhat/_utils/__init__.py +57 -0
- worqhat/_utils/_logs.py +25 -0
- worqhat/_utils/_proxy.py +65 -0
- worqhat/_utils/_reflection.py +42 -0
- worqhat/_utils/_resources_proxy.py +24 -0
- worqhat/_utils/_streams.py +12 -0
- worqhat/_utils/_sync.py +86 -0
- worqhat/_utils/_transform.py +447 -0
- worqhat/_utils/_typing.py +151 -0
- worqhat/_utils/_utils.py +422 -0
- worqhat/_version.py +4 -0
- worqhat/lib/.keep +4 -0
- worqhat/resources/__init__.py +33 -0
- worqhat/resources/flows.py +223 -0
- worqhat/resources/health.py +143 -0
- worqhat/types/__init__.py +8 -0
- worqhat/types/flow_retrieve_metrics_params.py +25 -0
- worqhat/types/flow_retrieve_metrics_response.py +55 -0
- worqhat/types/health_check_response.py +33 -0
- worqhat/types/retrieve_server_info_response.py +15 -0
- worqhat-3.1.0.dist-info/METADATA +398 -0
- worqhat-3.1.0.dist-info/RECORD +38 -0
- {worqhat-1.0.dist-info → worqhat-3.1.0.dist-info}/WHEEL +1 -2
- {worqhat-1.0.dist-info → worqhat-3.1.0.dist-info/licenses}/LICENSE +201 -201
- worqhat/ai_models/__init__.py +0 -9
- worqhat/ai_models/ai_search.py +0 -41
- worqhat/ai_models/content_mod.py +0 -44
- worqhat/ai_models/image_analysis.py +0 -94
- worqhat/ai_models/image_gen.py +0 -281
- worqhat/ai_models/model_train.py +0 -45
- worqhat/ai_models/text_extract.py +0 -83
- worqhat/ai_models/text_gen.py +0 -177
- worqhat/database_management/Edit.py +0 -140
- worqhat/database_management/Read.py +0 -152
- worqhat/database_management/__init__.py +0 -5
- worqhat/database_management/collection.py +0 -25
- worqhat/test/test_ai_search.py +0 -38
- worqhat/test/test_content_mod.py +0 -39
- worqhat/test/test_image_analysis.py +0 -52
- worqhat/test/test_image_gen.py +0 -0
- worqhat/test/test_model_train.py +0 -52
- worqhat/test/test_text_extract.py +0 -65
- worqhat/test/test_text_gen.py +0 -66
- worqhat-1.0.dist-info/METADATA +0 -127
- worqhat-1.0.dist-info/RECORD +0 -26
- worqhat-1.0.dist-info/top_level.txt +0 -1
- /worqhat/{test/__init__.py → py.typed} +0 -0
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def add_data_to_collection(collection='', doc_id='', data='',api_key=None ):
|
|
6
|
-
if collection=='':
|
|
7
|
-
return ("Please enter a Collection name")
|
|
8
|
-
if not api_key:
|
|
9
|
-
api_key = os.getenv("API_KEY")
|
|
10
|
-
if not api_key:
|
|
11
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
12
|
-
url = "https://api.worqhat.com/api/collections/data/add"
|
|
13
|
-
headers = {
|
|
14
|
-
"Authorization": "Bearer " + api_key,
|
|
15
|
-
"Content-Type": "application/json"
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
payload = {
|
|
19
|
-
"collection": collection,
|
|
20
|
-
"docId": doc_id,
|
|
21
|
-
"data": data
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
response = requests.post("POST",url, json=payload, headers=headers)
|
|
25
|
-
|
|
26
|
-
return response.text
|
|
27
|
-
|
|
28
|
-
def update_data_in_collection( collection='', doc_id='', data='',api_key=None):
|
|
29
|
-
if collection=='':
|
|
30
|
-
return ("Please enter a Collection name")
|
|
31
|
-
if not api_key:
|
|
32
|
-
api_key = os.getenv("API_KEY")
|
|
33
|
-
if not api_key:
|
|
34
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
35
|
-
url = "https://api.worqhat.com/api/collections/data/update"
|
|
36
|
-
headers = {
|
|
37
|
-
"Authorization": "Bearer " + api_key,
|
|
38
|
-
"Content-Type": "application/json"
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
payload = {
|
|
42
|
-
"collection": collection,
|
|
43
|
-
"docId": doc_id,
|
|
44
|
-
"data": data
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
response = requests.post(url, json=payload, headers=headers)
|
|
48
|
-
|
|
49
|
-
return response.text
|
|
50
|
-
|
|
51
|
-
def increment_field_in_collection(collection='', doc_id='', field='', increment_value='',api_key=None):
|
|
52
|
-
if collection=='':
|
|
53
|
-
return ("Please enter a Collection name")
|
|
54
|
-
if not api_key:
|
|
55
|
-
api_key = os.getenv("API_KEY")
|
|
56
|
-
if not api_key:
|
|
57
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
58
|
-
url = "https://api.worqhat.com/api/collections/data/increment"
|
|
59
|
-
headers = {
|
|
60
|
-
"Authorization": "Bearer " + api_key,
|
|
61
|
-
"Content-Type": "application/json"
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
payload = {
|
|
65
|
-
"collection": collection,
|
|
66
|
-
"docId": doc_id,
|
|
67
|
-
"field": field,
|
|
68
|
-
"increment": increment_value
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
response = requests.post(url, json=payload, headers=headers)
|
|
72
|
-
|
|
73
|
-
return response.text
|
|
74
|
-
|
|
75
|
-
def update_array_in_collection(collection='', doc_id='', field='', value='',api_key=None ):
|
|
76
|
-
if collection=='':
|
|
77
|
-
return ("Please enter a Collection name")
|
|
78
|
-
if not api_key:
|
|
79
|
-
api_key = os.getenv("API_KEY")
|
|
80
|
-
if not api_key:
|
|
81
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
82
|
-
url = "https://api.worqhat.com/api/collections/data/array/update/add"
|
|
83
|
-
payload = {
|
|
84
|
-
"collection": collection,
|
|
85
|
-
"docId": doc_id,
|
|
86
|
-
"field": field,
|
|
87
|
-
"arrayUnion": value
|
|
88
|
-
}
|
|
89
|
-
headers = {
|
|
90
|
-
"Authorization": "Bearer " + api_key,
|
|
91
|
-
"Content-Type": "application/json"
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
response = requests.post(url, json=payload, headers=headers)
|
|
95
|
-
|
|
96
|
-
return response.text
|
|
97
|
-
|
|
98
|
-
def remove_array_element_from_collection(collection='', doc_id='', field='', value='',api_key=None):
|
|
99
|
-
if collection=='':
|
|
100
|
-
return ("Please enter a Collection name")
|
|
101
|
-
if not api_key:
|
|
102
|
-
api_key = os.getenv("API_KEY")
|
|
103
|
-
if not api_key:
|
|
104
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
105
|
-
url = "https://api.worqhat.com/api/collections/data/array/update/remove"
|
|
106
|
-
payload = {
|
|
107
|
-
"collection": collection,
|
|
108
|
-
"docId": doc_id,
|
|
109
|
-
"field": field,
|
|
110
|
-
"arrayRemove": value
|
|
111
|
-
}
|
|
112
|
-
headers = {
|
|
113
|
-
"Authorization": "Bearer " + api_key,
|
|
114
|
-
"Content-Type": "application/json"
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
response = requests.post(url, json=payload, headers=headers)
|
|
118
|
-
|
|
119
|
-
return response.text
|
|
120
|
-
|
|
121
|
-
def delete_doc_from_collection(collection='', doc_id='',api_key=None):
|
|
122
|
-
if collection=='':
|
|
123
|
-
return ("Please enter a Collection name")
|
|
124
|
-
if not api_key:
|
|
125
|
-
api_key = os.getenv("API_KEY")
|
|
126
|
-
if not api_key:
|
|
127
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
128
|
-
url = "https://api.worqhat.com/api/collections/data/delete"
|
|
129
|
-
payload = {
|
|
130
|
-
"collection": collection,
|
|
131
|
-
"docId": doc_id
|
|
132
|
-
}
|
|
133
|
-
headers = {
|
|
134
|
-
"Authorization": "Bearer " + api_key,
|
|
135
|
-
"Content-Type": "application/json"
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
response = requests.post(url, json=payload, headers=headers)
|
|
139
|
-
|
|
140
|
-
return response.text
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
def fetch_all_collections(api_key=None):
|
|
5
|
-
if not api_key:
|
|
6
|
-
api_key = os.getenv("API_KEY")
|
|
7
|
-
if not api_key:
|
|
8
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
9
|
-
url = "https://api.worqhat.com/api/collections/fetch-all"
|
|
10
|
-
headers = {
|
|
11
|
-
"Authorization": "Bearer " + api_key
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
response = requests.post("POST",url, headers=headers)
|
|
15
|
-
|
|
16
|
-
return response.text
|
|
17
|
-
|
|
18
|
-
def fetch_all_docs_from_collection(collection='', output_type="json",api_key=None,):
|
|
19
|
-
if collection=='':
|
|
20
|
-
return ("Please enter a Collection name")
|
|
21
|
-
if not api_key:
|
|
22
|
-
api_key = os.getenv("API_KEY")
|
|
23
|
-
if not api_key:
|
|
24
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
25
|
-
url = "https://api.worqhat.com/api/collections/data/fetch/all"
|
|
26
|
-
payload = {
|
|
27
|
-
"collection": collection,
|
|
28
|
-
"outputType": output_type
|
|
29
|
-
}
|
|
30
|
-
headers = {
|
|
31
|
-
"Authorization": "Bearer " + api_key,
|
|
32
|
-
"Content-Type": "application/json"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
response = requests.post("POST",url, json=payload, headers=headers)
|
|
36
|
-
|
|
37
|
-
return response.text
|
|
38
|
-
|
|
39
|
-
def fetch_doc_from_collection( collection='', doc_id='',api_key=None):
|
|
40
|
-
if collection=='':
|
|
41
|
-
return ("Please enter a Collection name")
|
|
42
|
-
if not api_key:
|
|
43
|
-
api_key = os.getenv("API_KEY")
|
|
44
|
-
if not api_key:
|
|
45
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
46
|
-
url = "https://api.worqhat.com/api/collections/data/fetch/document"
|
|
47
|
-
payload = {
|
|
48
|
-
"collection": collection,
|
|
49
|
-
"documentId": doc_id
|
|
50
|
-
}
|
|
51
|
-
headers = {
|
|
52
|
-
"Authorization": "Bearer " + api_key,
|
|
53
|
-
"Content-Type": "application/json"
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
response = requests.post("POST",url, json=payload, headers=headers)
|
|
57
|
-
|
|
58
|
-
return response.text
|
|
59
|
-
|
|
60
|
-
def fetch_doc_count_by_field(collection='', field='',api_key=None):
|
|
61
|
-
if collection=='':
|
|
62
|
-
return ("Please enter a Collection name")
|
|
63
|
-
if not api_key:
|
|
64
|
-
api_key = os.getenv("API_KEY")
|
|
65
|
-
if not api_key:
|
|
66
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
67
|
-
url = "https://api.worqhat.com/api/collections/data/fetch/count"
|
|
68
|
-
payload = {
|
|
69
|
-
"collection": collection,
|
|
70
|
-
"key": field
|
|
71
|
-
}
|
|
72
|
-
headers = {
|
|
73
|
-
"Authorization": "Bearer " + api_key,
|
|
74
|
-
"Content-Type": "application/json"
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
response = requests.post("POST",url, json=payload, headers=headers)
|
|
78
|
-
|
|
79
|
-
return response.text
|
|
80
|
-
|
|
81
|
-
def fetch_unique_keys_ordered(collection='', field='', order_by='', order_type='',api_key=None):
|
|
82
|
-
if collection=='':
|
|
83
|
-
return ("Please enter a Collection name")
|
|
84
|
-
if not api_key:
|
|
85
|
-
api_key = os.getenv("API_KEY")
|
|
86
|
-
if not api_key:
|
|
87
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
88
|
-
url = "https://api.worqhat.com/api/collections/data/fetch/unique"
|
|
89
|
-
payload = {
|
|
90
|
-
"collection": collection,
|
|
91
|
-
"key": field,
|
|
92
|
-
"orderBy": order_by,
|
|
93
|
-
"orderType": order_type
|
|
94
|
-
}
|
|
95
|
-
headers = {
|
|
96
|
-
"Authorization": "Bearer " + api_key,
|
|
97
|
-
"Content-Type": "application/json"
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
response = requests.post("POST",url, json=payload, headers=headers)
|
|
101
|
-
|
|
102
|
-
return response.text
|
|
103
|
-
|
|
104
|
-
def fetch_docs_by_query(collection='', queries='', compounding="and", order_by=None, order_type="asc", limit=None, start_after=None, output_type="json",api_key=None ):
|
|
105
|
-
if collection=='':
|
|
106
|
-
return ("Please enter a Collection name")
|
|
107
|
-
if not api_key:
|
|
108
|
-
api_key = os.getenv("API_KEY")
|
|
109
|
-
if not api_key:
|
|
110
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
111
|
-
url = "https://api.worqhat.com/api/collections/data/fetch/query"
|
|
112
|
-
payload = {
|
|
113
|
-
"collection": collection,
|
|
114
|
-
"queries": queries,
|
|
115
|
-
"compounding": compounding,
|
|
116
|
-
"orderBy": order_by,
|
|
117
|
-
"orderType": order_type,
|
|
118
|
-
"limit": limit,
|
|
119
|
-
"startAfter": start_after,
|
|
120
|
-
"outputType": output_type
|
|
121
|
-
}
|
|
122
|
-
headers = {
|
|
123
|
-
"Authorization": "Bearer " + api_key,
|
|
124
|
-
"Content-Type": "application/json"
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
response = requests.post("POST",url, json=payload, headers=headers)
|
|
128
|
-
|
|
129
|
-
return response.text
|
|
130
|
-
|
|
131
|
-
def fetch_docs_by_natural_query(collection='', query='', output_type="json",api_key=None ):
|
|
132
|
-
if collection=='':
|
|
133
|
-
return ("Please enter a Collection name")
|
|
134
|
-
if not api_key:
|
|
135
|
-
api_key = os.getenv("API_KEY")
|
|
136
|
-
if not api_key:
|
|
137
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
138
|
-
url = "https://api.worqhat.com/api/collections/data/fetch/natural-query"
|
|
139
|
-
payload = {
|
|
140
|
-
"collection": collection,
|
|
141
|
-
"query": query,
|
|
142
|
-
"outputType": output_type
|
|
143
|
-
}
|
|
144
|
-
headers = {
|
|
145
|
-
"Authorization": "Bearer " + api_key,
|
|
146
|
-
"Content-Type": "application/json"
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
response = requests.post("POST",url, json=payload, headers=headers)
|
|
150
|
-
|
|
151
|
-
return response.text
|
|
152
|
-
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
def create_collection(collection='', collection_schema='', collection_sort_by='',api_key=None ):
|
|
5
|
-
if collection=='':
|
|
6
|
-
return ("Please enter a Collection name")
|
|
7
|
-
if not api_key:
|
|
8
|
-
api_key = os.getenv("API_KEY")
|
|
9
|
-
if not api_key:
|
|
10
|
-
raise ValueError("API key is missing. Provide it as an argument or in the .env file.")
|
|
11
|
-
url = "https://api.worqhat.com/api/collections/create"
|
|
12
|
-
headers = {
|
|
13
|
-
"Authorization": "Bearer " + api_key,
|
|
14
|
-
"Content-Type": "application/json"
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
payload = {
|
|
18
|
-
"collection": collection,
|
|
19
|
-
"collectionSchema": collection_schema,
|
|
20
|
-
"collectionSortBy": collection_sort_by
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
response = requests.post("POST",url, json=payload, headers=headers)
|
|
24
|
-
|
|
25
|
-
return response.text
|
worqhat/test/test_ai_search.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from unittest.mock import MagicMock
|
|
3
|
-
from ..src.ai_models.ai_search import search_ai_v2, search_ai_v3
|
|
4
|
-
|
|
5
|
-
class TestAISearch(unittest.TestCase):
|
|
6
|
-
|
|
7
|
-
def setUp(self):
|
|
8
|
-
# Mock API key for testing
|
|
9
|
-
self.api_key = "mock_api_key"
|
|
10
|
-
|
|
11
|
-
def test_search_ai_v2(self):
|
|
12
|
-
# Mock response
|
|
13
|
-
mock_response = MagicMock()
|
|
14
|
-
mock_response.text = '{"result": "Test result for AI v2"}'
|
|
15
|
-
requests_mock = MagicMock()
|
|
16
|
-
requests_mock.request.return_value = mock_response
|
|
17
|
-
|
|
18
|
-
with unittest.mock.patch('ai_search.requests', requests_mock):
|
|
19
|
-
result = search_ai_v2(api_key=self.api_key, question="Test question")
|
|
20
|
-
|
|
21
|
-
self.assertEqual(result, '{"result": "Test result for AI v2"}')
|
|
22
|
-
requests_mock.request.assert_called_once()
|
|
23
|
-
|
|
24
|
-
def test_search_ai_v3(self):
|
|
25
|
-
# Mock response
|
|
26
|
-
mock_response = MagicMock()
|
|
27
|
-
mock_response.text = '{"result": "Test result for AI v3"}'
|
|
28
|
-
requests_mock = MagicMock()
|
|
29
|
-
requests_mock.request.return_value = mock_response
|
|
30
|
-
|
|
31
|
-
with unittest.mock.patch('ai_search.requests', requests_mock):
|
|
32
|
-
result = search_ai_v3(api_key=self.api_key, question="Test question")
|
|
33
|
-
|
|
34
|
-
self.assertEqual(result, '{"result": "Test result for AI v3"}')
|
|
35
|
-
requests_mock.request.assert_called_once()
|
|
36
|
-
|
|
37
|
-
if __name__ == '__main__':
|
|
38
|
-
unittest.main()
|
worqhat/test/test_content_mod.py
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from unittest.mock import MagicMock
|
|
3
|
-
import requests
|
|
4
|
-
from ..src.ai_models.content_mod import content_moderation,image_moderation
|
|
5
|
-
|
|
6
|
-
class TestModeration(unittest.TestCase):
|
|
7
|
-
|
|
8
|
-
def setUp(self):
|
|
9
|
-
# Mock API key for testing
|
|
10
|
-
self.api_key = "mock_api_key"
|
|
11
|
-
|
|
12
|
-
def test_content_moderation(self):
|
|
13
|
-
# Mock response
|
|
14
|
-
mock_response = MagicMock()
|
|
15
|
-
mock_response.text = '{"result": "Test content moderation result"}'
|
|
16
|
-
requests_mock = MagicMock()
|
|
17
|
-
requests_mock.request.return_value = mock_response
|
|
18
|
-
|
|
19
|
-
with unittest.mock.patch('moderation.requests', requests_mock):
|
|
20
|
-
result = content_moderation(api_key=self.api_key, text_content="Test text content")
|
|
21
|
-
|
|
22
|
-
self.assertEqual(result, '{"result": "Test content moderation result"}')
|
|
23
|
-
requests_mock.request.assert_called_once()
|
|
24
|
-
|
|
25
|
-
def test_image_moderation(self):
|
|
26
|
-
# Mock response
|
|
27
|
-
mock_response = MagicMock()
|
|
28
|
-
mock_response.text = '{"result": "Test image moderation result"}'
|
|
29
|
-
requests_mock = MagicMock()
|
|
30
|
-
requests_mock.request.return_value = mock_response
|
|
31
|
-
|
|
32
|
-
with unittest.mock.patch('moderation.requests', requests_mock):
|
|
33
|
-
result = image_moderation(api_key=self.api_key, image_file=MagicMock(name="mock_image_file"))
|
|
34
|
-
|
|
35
|
-
self.assertEqual(result, '{"result": "Test image moderation result"}')
|
|
36
|
-
requests_mock.request.assert_called_once()
|
|
37
|
-
|
|
38
|
-
if __name__ == '__main__':
|
|
39
|
-
unittest.main()
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from unittest.mock import MagicMock
|
|
3
|
-
import requests
|
|
4
|
-
from ..src.ai_models.image_analysis import image_analysis, face_detection, facial_comparison
|
|
5
|
-
|
|
6
|
-
class TestImageFunctions(unittest.TestCase):
|
|
7
|
-
|
|
8
|
-
def setUp(self):
|
|
9
|
-
# Mock API key for testing
|
|
10
|
-
self.api_key = "mock_api_key"
|
|
11
|
-
|
|
12
|
-
def test_image_analysis(self):
|
|
13
|
-
# Mock response
|
|
14
|
-
mock_response = MagicMock()
|
|
15
|
-
mock_response.text = '{"result": "Test image analysis result"}'
|
|
16
|
-
requests_mock = MagicMock()
|
|
17
|
-
requests_mock.request.return_value = mock_response
|
|
18
|
-
|
|
19
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
20
|
-
result = image_analysis(api_key=self.api_key, images=[MagicMock(name="mock_image")], question="Test question")
|
|
21
|
-
|
|
22
|
-
self.assertEqual(result, '{"result": "Test image analysis result"}')
|
|
23
|
-
requests_mock.request.assert_called_once()
|
|
24
|
-
|
|
25
|
-
def test_face_detection(self):
|
|
26
|
-
# Mock response
|
|
27
|
-
mock_response = MagicMock()
|
|
28
|
-
mock_response.text = '{"result": "Test face detection result"}'
|
|
29
|
-
requests_mock = MagicMock()
|
|
30
|
-
requests_mock.request.return_value = mock_response
|
|
31
|
-
|
|
32
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
33
|
-
result = face_detection(api_key=self.api_key, image_file=MagicMock(name="mock_image_file"))
|
|
34
|
-
|
|
35
|
-
self.assertEqual(result, '{"result": "Test face detection result"}')
|
|
36
|
-
requests_mock.request.assert_called_once()
|
|
37
|
-
|
|
38
|
-
def test_facial_comparison(self):
|
|
39
|
-
# Mock response
|
|
40
|
-
mock_response = MagicMock()
|
|
41
|
-
mock_response.text = '{"result": "Test facial comparison result"}'
|
|
42
|
-
requests_mock = MagicMock()
|
|
43
|
-
requests_mock.request.return_value = mock_response
|
|
44
|
-
|
|
45
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
46
|
-
result = facial_comparison(api_key=self.api_key, source_image_file=MagicMock(name="mock_source_image_file"), target_image_file=MagicMock(name="mock_target_image_file"))
|
|
47
|
-
|
|
48
|
-
self.assertEqual(result, '{"result": "Test facial comparison result"}')
|
|
49
|
-
requests_mock.request.assert_called_once()
|
|
50
|
-
|
|
51
|
-
if __name__ == '__main__':
|
|
52
|
-
unittest.main()
|
worqhat/test/test_image_gen.py
DELETED
|
File without changes
|
worqhat/test/test_model_train.py
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from unittest.mock import MagicMock
|
|
3
|
-
import requests
|
|
4
|
-
from ..src.ai_models.model_train import list_datasets, delete_dataset, train_dataset
|
|
5
|
-
|
|
6
|
-
class TestDatasetFunctions(unittest.TestCase):
|
|
7
|
-
|
|
8
|
-
def setUp(self):
|
|
9
|
-
# Mock API key for testing
|
|
10
|
-
self.api_key = "mock_api_key"
|
|
11
|
-
|
|
12
|
-
def test_list_datasets(self):
|
|
13
|
-
# Mock response
|
|
14
|
-
mock_response = MagicMock()
|
|
15
|
-
mock_response.text = '{"datasets": ["Dataset1", "Dataset2"]}'
|
|
16
|
-
requests_mock = MagicMock()
|
|
17
|
-
requests_mock.request.return_value = mock_response
|
|
18
|
-
|
|
19
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
20
|
-
result = list_datasets(api_key=self.api_key)
|
|
21
|
-
|
|
22
|
-
self.assertEqual(result, '{"datasets": ["Dataset1", "Dataset2"]}')
|
|
23
|
-
requests_mock.request.assert_called_once()
|
|
24
|
-
|
|
25
|
-
def test_delete_dataset(self):
|
|
26
|
-
# Mock response
|
|
27
|
-
mock_response = MagicMock()
|
|
28
|
-
mock_response.text = '{"message": "Dataset deleted successfully"}'
|
|
29
|
-
requests_mock = MagicMock()
|
|
30
|
-
requests_mock.request.return_value = mock_response
|
|
31
|
-
|
|
32
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
33
|
-
result = delete_dataset(api_key=self.api_key, dataset_id="123456789")
|
|
34
|
-
|
|
35
|
-
self.assertEqual(result, '{"message": "Dataset deleted successfully"}')
|
|
36
|
-
requests_mock.request.assert_called_once()
|
|
37
|
-
|
|
38
|
-
def test_train_dataset(self):
|
|
39
|
-
# Mock response
|
|
40
|
-
mock_response = MagicMock()
|
|
41
|
-
mock_response.text = '{"message": "Dataset trained successfully"}'
|
|
42
|
-
requests_mock = MagicMock()
|
|
43
|
-
requests_mock.request.return_value = mock_response
|
|
44
|
-
|
|
45
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
46
|
-
result = train_dataset(api_key=self.api_key, dataset_id="123456789", dataset_name="Sample Dataset", dataset_type="self", json_data="{'data':'This is sample Data'}", training_file="sample_training_data.txt")
|
|
47
|
-
|
|
48
|
-
self.assertEqual(result, '{"message": "Dataset trained successfully"}')
|
|
49
|
-
requests_mock.request.assert_called_once()
|
|
50
|
-
|
|
51
|
-
if __name__ == '__main__':
|
|
52
|
-
unittest.main()
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from unittest.mock import MagicMock
|
|
3
|
-
import requests
|
|
4
|
-
from ..src.ai_models.text_extract import pdf_extract, web_extract, image_text_detection, speech_to_text
|
|
5
|
-
|
|
6
|
-
class TestFunctions(unittest.TestCase):
|
|
7
|
-
|
|
8
|
-
def setUp(self):
|
|
9
|
-
# Mock API key for testing
|
|
10
|
-
self.api_key = "mock_api_key"
|
|
11
|
-
|
|
12
|
-
def test_pdf_extract(self):
|
|
13
|
-
# Mock response
|
|
14
|
-
mock_response = MagicMock()
|
|
15
|
-
mock_response.text = '{"result": "Test pdf extraction result"}'
|
|
16
|
-
requests_mock = MagicMock()
|
|
17
|
-
requests_mock.request.return_value = mock_response
|
|
18
|
-
|
|
19
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
20
|
-
result = pdf_extract(api_key=self.api_key, pdf_file=MagicMock(name="mock_pdf_file"))
|
|
21
|
-
|
|
22
|
-
self.assertEqual(result, '{"result": "Test pdf extraction result"}')
|
|
23
|
-
requests_mock.request.assert_called_once()
|
|
24
|
-
|
|
25
|
-
def test_web_extract(self):
|
|
26
|
-
# Mock response
|
|
27
|
-
mock_response = MagicMock()
|
|
28
|
-
mock_response.text = '{"result": "Test web extraction result"}'
|
|
29
|
-
requests_mock = MagicMock()
|
|
30
|
-
requests_mock.request.return_value = mock_response
|
|
31
|
-
|
|
32
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
33
|
-
result = web_extract(api_key=self.api_key, url_search="www.example.com")
|
|
34
|
-
|
|
35
|
-
self.assertEqual(result, '{"result": "Test web extraction result"}')
|
|
36
|
-
requests_mock.request.assert_called_once()
|
|
37
|
-
|
|
38
|
-
def test_image_text_detection(self):
|
|
39
|
-
# Mock response
|
|
40
|
-
mock_response = MagicMock()
|
|
41
|
-
mock_response.text = '{"result": "Test image text detection result"}'
|
|
42
|
-
requests_mock = MagicMock()
|
|
43
|
-
requests_mock.request.return_value = mock_response
|
|
44
|
-
|
|
45
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
46
|
-
result = image_text_detection(api_key=self.api_key, image_file=MagicMock(name="mock_image_file"))
|
|
47
|
-
|
|
48
|
-
self.assertEqual(result, '{"result": "Test image text detection result"}')
|
|
49
|
-
requests_mock.request.assert_called_once()
|
|
50
|
-
|
|
51
|
-
def test_speech_to_text(self):
|
|
52
|
-
# Mock response
|
|
53
|
-
mock_response = MagicMock()
|
|
54
|
-
mock_response.text = '{"result": "Test speech to text result"}'
|
|
55
|
-
requests_mock = MagicMock()
|
|
56
|
-
requests_mock.request.return_value = mock_response
|
|
57
|
-
|
|
58
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
59
|
-
result = speech_to_text(api_key=self.api_key, audio_file=MagicMock(name="mock_audio_file"))
|
|
60
|
-
|
|
61
|
-
self.assertEqual(result, '{"result": "Test speech to text result"}')
|
|
62
|
-
requests_mock.request.assert_called_once()
|
|
63
|
-
|
|
64
|
-
if __name__ == '__main__':
|
|
65
|
-
unittest.main()
|
worqhat/test/test_text_gen.py
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from unittest.mock import MagicMock
|
|
3
|
-
import requests
|
|
4
|
-
from ..src.ai_models.text_gen import (get_ai_responsev2, get_ai_responsev3,
|
|
5
|
-
get_large_ai_response_v2, get_alpha_ai_response)
|
|
6
|
-
|
|
7
|
-
class TestAIResponses(unittest.TestCase):
|
|
8
|
-
|
|
9
|
-
def setUp(self):
|
|
10
|
-
# Mock API key for testing
|
|
11
|
-
self.api_key = "mock_api_key"
|
|
12
|
-
|
|
13
|
-
def test_get_ai_responsev2(self):
|
|
14
|
-
# Mock response
|
|
15
|
-
mock_response = MagicMock()
|
|
16
|
-
mock_response.text = '{"response": "Test AI response v2"}'
|
|
17
|
-
requests_mock = MagicMock()
|
|
18
|
-
requests_mock.request.return_value = mock_response
|
|
19
|
-
|
|
20
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
21
|
-
result = get_ai_responsev2(api_key=self.api_key, question="What is the capital of India?")
|
|
22
|
-
|
|
23
|
-
self.assertEqual(result, '{"response": "Test AI response v2"}')
|
|
24
|
-
requests_mock.request.assert_called_once()
|
|
25
|
-
|
|
26
|
-
def test_get_ai_responsev3(self):
|
|
27
|
-
# Mock response
|
|
28
|
-
mock_response = MagicMock()
|
|
29
|
-
mock_response.text = '{"response": "Test AI response v3"}'
|
|
30
|
-
requests_mock = MagicMock()
|
|
31
|
-
requests_mock.request.return_value = mock_response
|
|
32
|
-
|
|
33
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
34
|
-
result = get_ai_responsev3(api_key=self.api_key, question="What is the capital of India?")
|
|
35
|
-
|
|
36
|
-
self.assertEqual(result, '{"response": "Test AI response v3"}')
|
|
37
|
-
requests_mock.request.assert_called_once()
|
|
38
|
-
|
|
39
|
-
def test_get_large_ai_response_v2(self):
|
|
40
|
-
# Mock response
|
|
41
|
-
mock_response = MagicMock()
|
|
42
|
-
mock_response.text = '{"response": "Test Large AI response v2"}'
|
|
43
|
-
requests_mock = MagicMock()
|
|
44
|
-
requests_mock.request.return_value = mock_response
|
|
45
|
-
|
|
46
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
47
|
-
result = get_large_ai_response_v2(api_key=self.api_key, question="What is the capital of Delhi?", dataset_id="123456789")
|
|
48
|
-
|
|
49
|
-
self.assertEqual(result, '{"response": "Test Large AI response v2"}')
|
|
50
|
-
requests_mock.request.assert_called_once()
|
|
51
|
-
|
|
52
|
-
def test_get_alpha_ai_response(self):
|
|
53
|
-
# Mock response
|
|
54
|
-
mock_response = MagicMock()
|
|
55
|
-
mock_response.text = '{"response": "Test Alpha AI response"}'
|
|
56
|
-
requests_mock = MagicMock()
|
|
57
|
-
requests_mock.request.return_value = mock_response
|
|
58
|
-
|
|
59
|
-
with unittest.mock.patch('your_module.requests', requests_mock):
|
|
60
|
-
result = get_alpha_ai_response(api_key=self.api_key, question="What is the capital of Delhi?")
|
|
61
|
-
|
|
62
|
-
self.assertEqual(result, '{"response": "Test Alpha AI response"}')
|
|
63
|
-
requests_mock.request.assert_called_once()
|
|
64
|
-
|
|
65
|
-
if __name__ == '__main__':
|
|
66
|
-
unittest.main()
|