oneliai 0.1.0__tar.gz

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.
oneliai-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.1
2
+ Name: oneliai
3
+ Version: 0.1.0
4
+ Summary: SDK for ONELI.AI Customer API
5
+ Author: oneli.ai
6
+ Requires-Python: >=3.6
7
+ Requires-Dist: requests
File without changes
@@ -0,0 +1,156 @@
1
+ import requests
2
+
3
+ # URL="https://apis.oneli.chat"
4
+ URL="http://localhost:8085"
5
+ class AIClient:
6
+ def __init__(self, client_id, client_secret, base_url=f'{URL}/v1/strategy'):
7
+ self.client_id = client_id
8
+ self.client_secret = client_secret
9
+ self.base_url = base_url
10
+ self.access_token = self._get_access_token()
11
+
12
+ def _get_access_token(self):
13
+ response = requests.post(
14
+ f'{self.base_url}/auth/token',
15
+ json={
16
+ 'client_id': self.client_id,
17
+ 'client_secret': self.client_secret,
18
+ 'grant_type': 'client_credentials'
19
+ }
20
+ )
21
+ if response.status_code == 200:
22
+ return response.json().get('access_token')
23
+ else:
24
+ raise Exception('Failed to get access token')
25
+
26
+ def generate_response(self, template_id, variables):
27
+ response = requests.post(
28
+ f'{self.base_url}/dynamic-response',
29
+ json={
30
+ 'template_id': template_id,
31
+ 'variables': variables
32
+ },
33
+ headers={'Authorization': f'Bearer {self.access_token}'}
34
+ )
35
+ if response.status_code == 200:
36
+ return response.json().get('response')
37
+ else:
38
+ return response.json()
39
+ # raise Exception('Failed to generate response')
40
+
41
+ def query_data(self, arg, template_id):
42
+ response = requests.post(
43
+ f'{self.base_url}/query-data',
44
+ json={
45
+ 'arg': arg,
46
+ 'template_id': template_id
47
+ },
48
+ headers={'Authorization': f'Bearer {self.access_token}'}
49
+ )
50
+ if response.status_code == 200:
51
+ return response.json()
52
+ else:
53
+ res=response.json()
54
+ raise Exception(res['error'])
55
+
56
+
57
+ def query_intention(self, question):
58
+ response = requests.post(
59
+ f'{self.base_url}/query-intention',
60
+ json={
61
+ 'question': question
62
+
63
+ },
64
+ headers={'Authorization': f'Bearer {self.access_token}'}
65
+ )
66
+ if response.status_code == 200:
67
+ return response.json()
68
+ else:
69
+ raise Exception('Failed to start intention query')
70
+
71
+ def voc(self,productname,text):
72
+ response = requests.post(
73
+ f'{self.base_url}/voc',
74
+ json={
75
+ 'productname': productname,
76
+ 'text':text
77
+ },
78
+ headers={'Authorization': f'Bearer {self.access_token}'}
79
+ )
80
+ if response.status_code == 200:
81
+ return response.json()
82
+ else:
83
+ raise Exception('Failed to start voc ')
84
+
85
+
86
+ def spec(self,asin):
87
+ response = requests.post(
88
+ f'{self.base_url}/spec',
89
+ json={
90
+ 'asin': asin
91
+
92
+ },
93
+ headers={'Authorization': f'Bearer {self.access_token}'}
94
+ )
95
+ if response.status_code == 200:
96
+ return response.json()
97
+ else:
98
+ raise Exception('Failed to start voc ')
99
+
100
+ # def registEndpoint(self, name,endpointpath):
101
+ # response = requests.post(
102
+ # f'{self.base_url}/createEndpoints',
103
+ # json={
104
+ # "endpointpath": endpointpath,
105
+ # "method": "POST",
106
+ # "name":name
107
+ # },
108
+ # headers={'Authorization': f'Bearer {self.access_token}'}
109
+ # )
110
+ # if response.status_code == 200:
111
+ # return response.json()
112
+ # else:
113
+ # raise Exception('Failed to createEndpoints')
114
+
115
+
116
+
117
+ # def createRoles(self, role_name, description):
118
+ # response = requests.post(
119
+ # f'{self.base_url}/createRoles',
120
+ # json={
121
+ # "role_name": role_name,
122
+ # "description":description
123
+ # },
124
+ # headers={'Authorization': f'Bearer {self.access_token}'}
125
+ # )
126
+ # if response.status_code == 200:
127
+ # return response.json()
128
+ # else:
129
+ # raise Exception('Failed to createRoles')
130
+
131
+ # def roles_endpoint(self, role_id, endpoint_id):
132
+ # response = requests.post(
133
+ # f'{self.base_url}/roles/{role_id}/endpoints',
134
+ # json={
135
+ # "endpoint_id": endpoint_id
136
+ # },
137
+ # headers={'Authorization': f'Bearer {self.access_token}'}
138
+ # )
139
+ # if response.status_code == 200:
140
+ # return response.json()
141
+ # else:
142
+ # raise Exception('Failed to roles_endpoint')
143
+
144
+
145
+ # def user_roles(self, user_id, role_id):
146
+ # response = requests.post(
147
+ # f'{self.base_url}/users/{user_id}/roles',
148
+ # json={
149
+ # "role_id": role_id
150
+ # },
151
+ # headers={'Authorization': f'Bearer {self.access_token}'}
152
+ # )
153
+ # if response.status_code == 200:
154
+ # return response.json()
155
+ # else:
156
+ # raise Exception('Failed to user_roles')
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.1
2
+ Name: oneliai
3
+ Version: 0.1.0
4
+ Summary: SDK for ONELI.AI Customer API
5
+ Author: oneli.ai
6
+ Requires-Python: >=3.6
7
+ Requires-Dist: requests
@@ -0,0 +1,8 @@
1
+ setup.py
2
+ oneliai/__init__.py
3
+ oneliai/client.py
4
+ oneliai.egg-info/PKG-INFO
5
+ oneliai.egg-info/SOURCES.txt
6
+ oneliai.egg-info/dependency_links.txt
7
+ oneliai.egg-info/requires.txt
8
+ oneliai.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests
@@ -0,0 +1 @@
1
+ oneliai
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
oneliai-0.1.0/setup.py ADDED
@@ -0,0 +1,32 @@
1
+ # from setuptools import setup, find_packages
2
+
3
+ # setup(
4
+ # name='oneliai',
5
+ # version='0.1',
6
+ # packages=find_packages(),
7
+ # install_requires=[
8
+ # 'requests>=2.31.0',
9
+ # 'PyJWT>=2.8.0'
10
+ # ],
11
+ # author='Your Name',
12
+ # author_email='your.email@example.com',
13
+ # description='SDK for AI Customer API',
14
+ # url='https://github.com/your-repo/ai-customer-sdk'
15
+ # )
16
+
17
+
18
+ from setuptools import setup, find_packages
19
+
20
+ setup(
21
+ name='oneliai',
22
+ version="0.1.0",
23
+ author="oneli.ai",
24
+ description='SDK for ONELI.AI Customer API',
25
+ # long_description=open("README.md").read(),
26
+ # long_description_content_type="text/markdown",
27
+ packages=find_packages(),
28
+ install_requires=[
29
+ "requests",
30
+ ],
31
+ python_requires=">=3.6",
32
+ )