ASUllmAPI 2.0.0__tar.gz → 2.0.2__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.
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI/model_config.py +1 -1
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI/web_socket.py +16 -18
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI.egg-info/PKG-INFO +3 -1
- asullmapi-2.0.2/ASUllmAPI.egg-info/requires.txt +4 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/PKG-INFO +3 -1
- {asullmapi-2.0.0 → asullmapi-2.0.2}/pyproject.toml +4 -2
- asullmapi-2.0.0/ASUllmAPI.egg-info/requires.txt +0 -2
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI/__init__.py +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI/api.py +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI/multithreading.py +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI/utils.py +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI.egg-info/SOURCES.txt +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI.egg-info/dependency_links.txt +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/ASUllmAPI.egg-info/top_level.txt +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/LICENSE +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/README.md +0 -0
- {asullmapi-2.0.0 → asullmapi-2.0.2}/setup.cfg +0 -0
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
3
|
from typing import Dict
|
|
4
|
+
import ssl
|
|
5
|
+
import warnings
|
|
4
6
|
|
|
5
7
|
import websockets
|
|
8
|
+
import certifi
|
|
6
9
|
|
|
7
10
|
from .model_config import ModelConfig
|
|
8
11
|
from .utils import load_json_buffer, begin_task_execution
|
|
9
12
|
|
|
13
|
+
SSL_CONTEXT = ssl.create_default_context(cafile=certifi.where())
|
|
14
|
+
|
|
10
15
|
|
|
11
16
|
async def interact_with_websocket(uri: str, query_payload: Dict[str, str], qid: int):
|
|
12
17
|
end_of_stream = "<EOS>"
|
|
13
18
|
payload = {qid: {"response": ""}}
|
|
14
19
|
|
|
15
|
-
async with websockets.connect(uri) as websocket:
|
|
20
|
+
async with websockets.connect(uri, ssl=SSL_CONTEXT) as websocket:
|
|
16
21
|
# Send the user-provided message to the WebSocket server
|
|
17
22
|
await websocket.send(json.dumps(query_payload))
|
|
18
23
|
|
|
@@ -24,30 +29,23 @@ async def interact_with_websocket(uri: str, query_payload: Dict[str, str], qid:
|
|
|
24
29
|
|
|
25
30
|
if isinstance(parsed_response, dict):
|
|
26
31
|
# Case: json/text response and user is denied entry
|
|
27
|
-
if 'message' in parsed_response.keys():
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
break
|
|
32
|
-
else:
|
|
33
|
-
raise RuntimeWarning(f"Unknown ASU LLM endpoint edge case detected: `message` as key in "
|
|
34
|
-
f"parsed response: {parsed_response}.")
|
|
35
|
-
|
|
32
|
+
if 'message' in parsed_response.keys() or 'error' in parsed_response.keys():
|
|
33
|
+
# Embed entire Forbidden message payload and leave response blank.
|
|
34
|
+
payload[qid].update(parsed_response)
|
|
35
|
+
break
|
|
36
36
|
# Case: json response and user is not denied entry
|
|
37
37
|
elif 'response' in parsed_response.keys():
|
|
38
38
|
payload[qid]["response"] += (parsed_response["response"].replace(end_of_stream, ""))
|
|
39
39
|
if 'metadata' in parsed_response.keys() or end_of_stream in parsed_response['response']:
|
|
40
40
|
payload[qid]["metadata"] = parsed_response["metadata"]
|
|
41
41
|
break
|
|
42
|
-
# Edge case: user gets a message to contact the administrator after an error
|
|
43
|
-
elif 'error' in parsed_response.keys():
|
|
44
|
-
payload[qid]["error"] = parsed_response["error"]
|
|
45
42
|
# Unknown edge case: json getting returned that is not a `message`, `response`, `error`
|
|
46
43
|
# (not observed yet)
|
|
47
44
|
else:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
warnings.warn(f"Unknown ASU LLM endpoint edge case detected: JSON parsed but data does not "
|
|
46
|
+
f"contain a message or response field.", RuntimeWarning)
|
|
47
|
+
payload[qid].update(parsed_response)
|
|
48
|
+
break
|
|
51
49
|
# Intended case: user asked for a response type of `text` and was not denied entry.
|
|
52
50
|
else:
|
|
53
51
|
payload[qid]["response"] += response.replace(end_of_stream, "")
|
|
@@ -57,8 +55,8 @@ async def interact_with_websocket(uri: str, query_payload: Dict[str, str], qid:
|
|
|
57
55
|
except websockets.ConnectionClosed:
|
|
58
56
|
print(f"Question {qid} connection closed by the server")
|
|
59
57
|
break
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
print(f"......Question {qid} response sent by the WebSocket server.")
|
|
59
|
+
return payload
|
|
62
60
|
|
|
63
61
|
|
|
64
62
|
async def limited_task(semaphore: asyncio.Semaphore, task):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ASUllmAPI
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: A simple python package to facilitate connection to ASU LLM API
|
|
5
5
|
Author-email: Stella Wenxing Liu <stellawenxingliu@gmail.com>, Varun Shourie <svarun195@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/ASU/aiml-ssmdv-student-support-ml-data-visualization
|
|
@@ -13,6 +13,8 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: requests
|
|
15
15
|
Requires-Dist: tqdm
|
|
16
|
+
Requires-Dist: websockets
|
|
17
|
+
Requires-Dist: certifi
|
|
16
18
|
|
|
17
19
|
# ASU LLM API
|
|
18
20
|
This package allows individuals at Arizona State University to access ASU GPT through API. You will need API access token, API endpoints in order to use this package.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ASUllmAPI
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: A simple python package to facilitate connection to ASU LLM API
|
|
5
5
|
Author-email: Stella Wenxing Liu <stellawenxingliu@gmail.com>, Varun Shourie <svarun195@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/ASU/aiml-ssmdv-student-support-ml-data-visualization
|
|
@@ -13,6 +13,8 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: requests
|
|
15
15
|
Requires-Dist: tqdm
|
|
16
|
+
Requires-Dist: websockets
|
|
17
|
+
Requires-Dist: certifi
|
|
16
18
|
|
|
17
19
|
# ASU LLM API
|
|
18
20
|
This package allows individuals at Arizona State University to access ASU GPT through API. You will need API access token, API endpoints in order to use this package.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ASUllmAPI"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.2"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name="Stella Wenxing Liu", email="stellawenxingliu@gmail.com" },
|
|
6
6
|
{ name="Varun Shourie", email="svarun195@gmail.com" }
|
|
@@ -15,7 +15,9 @@ classifiers = [
|
|
|
15
15
|
]
|
|
16
16
|
dependencies = [
|
|
17
17
|
"requests",
|
|
18
|
-
"tqdm"
|
|
18
|
+
"tqdm",
|
|
19
|
+
"websockets",
|
|
20
|
+
"certifi"
|
|
19
21
|
]
|
|
20
22
|
|
|
21
23
|
[project.urls]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|