ASUllmAPI 2.0.5__tar.gz → 2.0.6__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.
@@ -7,13 +7,14 @@ __author__ = ['swliu', 'vshourie']
7
7
  class ModelConfig:
8
8
 
9
9
  def __init__(self, access_token: str = None, action: str = None, api_url: str = "", enable_history: bool = False,
10
- enable_search: bool = True, history: List[Dict[str, str]] = None, model_max_tokens: int = None,
10
+ enable_search: bool = True, history: List[Dict[str, str]] = None, model_max_tokens: int = None,
11
11
  model_temperature: float = None, model_top_k: int = None, model_top_p: int = None, name: str = "",
12
12
  project_id: str = None, provider: str = "", response_format_type: str = "",
13
- search_collection: str = "asu", search_db_type: str = "milvus", search_output_fields: List[str] = None,
14
- search_retrieval_type: str = "chunk", search_source_name: List[str] = None, search_tags: list = None,
15
- search_top_k: int = 3, semantic_caching: bool = False, session_id: str = None,
16
- system_prompt: str = None):
13
+ search_collection: str = "asu", search_db_type: str = "opensearch",
14
+ search_output_fields: List[str] = None, search_retrieval_type: str = "chunk",
15
+ search_source_name: List[str] = None, search_tags: list = None, search_top_k: int = 3,
16
+ search_prompt_mode: str = "unrestricted", search_prompt: str = None, semantic_caching: bool = False,
17
+ session_id: str = None, system_prompt: str = None):
17
18
  self.access_token = access_token
18
19
  self.action = action
19
20
  self.api_url = api_url
@@ -35,6 +36,8 @@ class ModelConfig:
35
36
  self.search_tags = search_tags
36
37
  self.search_top_k = search_top_k
37
38
  self.search_retrieval_type = search_retrieval_type
39
+ self.search_prompt_mode = search_prompt_mode
40
+ self.search_prompt = search_prompt
38
41
  self.semantic_caching = semantic_caching
39
42
  self.session_id = session_id
40
43
  self.system_prompt = system_prompt
@@ -113,6 +116,10 @@ class ModelConfig:
113
116
  search_params["top_k"] = self.search_top_k
114
117
  search_params["retrieval_type"] = self.search_retrieval_type
115
118
 
119
+ if self.search_prompt_mode is not None:
120
+ search_params["prompt_mode"] = self.search_prompt_mode
121
+ if self.search_prompt is not None:
122
+ search_params["search_prompt"] = self.search_prompt
116
123
  if self.search_source_name is not None:
117
124
  search_params["source_name"] = self.search_source_name
118
125
  if self.search_tags is not None:
@@ -99,29 +99,36 @@ async def interact_with_websocket(uri: str, queue: asyncio.Queue,
99
99
  # END - QUERY QUEUE LOOP
100
100
  except (asyncio.TimeoutError, websockets.ConnectionClosed, Exception) as exc:
101
101
  if isinstance(exc, asyncio.TimeoutError):
102
- logging.error(f"Error {error_ct} on {qid} stream timeout: resetting connection...")
102
+ logging.error(f"Error {error_ct} on Question ID {qid} stream timeout: resetting connection...")
103
103
  elif isinstance(exc, ResponseDataError):
104
- logging.error(f"Error {error_ct} on {qid}: invalid response from endpoint.\n"
104
+ logging.error(f"Error {error_ct} on Question ID {qid}: invalid response from endpoint.\n"
105
105
  f"{response_payloads[qid]}")
106
106
  elif isinstance(exc, websockets.ConnectionClosed):
107
- logging.error(f"Error {error_ct} on {qid}: WebSocket connection closed on "
107
+ logging.error(f"Error {error_ct} on Question ID {qid}: WebSocket connection closed on "
108
108
  f"query ID {qid}. Reopening...")
109
+ elif isinstance(exc, websockets.exceptions.InvalidStatusCode):
110
+ logging.error(f"Error {error_ct} on Question ID {qid}: Server rejected the connection. "
111
+ f"Check URI again.")
109
112
  else:
110
- logging.error(f"Error {error_ct} on {qid}: {traceback.format_exc()}")
111
-
112
- time.sleep(reconnect_timeout_secs)
113
- # If the query is already complete, we don't want to increment the error count
114
- if response_payloads[qid]["success"] == 0:
115
- error_ct += 1
116
- # Reset buffer stream so that you don't get messed by pre-existing data.
117
- response_payloads[qid]["response"] = ""
118
- else:
119
- logging.info(f"Query ID {qid} completed...")
120
- queue.task_done()
121
-
122
- # prevent any further retries if at error limit.
123
- if error_ct == error_threshold:
124
- error_ct = 0
113
+ logging.error(f"Error {error_ct} on Question ID {qid}: {traceback.format_exc()}")
114
+
115
+ try:
116
+ # If the query is already complete, we don't want to increment the error count
117
+ if response_payloads[qid]["success"] == 0:
118
+ error_ct += 1
119
+ # Reset buffer stream so that you don't get messed by pre-existing data.
120
+ response_payloads[qid]["response"] = ""
121
+ else:
122
+ logging.info(f"Query ID {qid} completed...")
123
+ queue.task_done()
124
+ except KeyError:
125
+ logging.error(f"Question ID {qid} does not exist in the queue. Exiting...")
126
+ return
127
+ finally:
128
+ # prevent any further retries if at error limit.
129
+ if error_ct == error_threshold:
130
+ error_ct = 0
131
+ time.sleep(reconnect_timeout_secs)
125
132
  # END - WEBSOCKET LOOP
126
133
  logging.info("WebSocket connection closed. Queue appears to be empty...")
127
134
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ASUllmAPI
3
- Version: 2.0.5
3
+ Version: 2.0.6
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ASUllmAPI
3
- Version: 2.0.5
3
+ Version: 2.0.6
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ASUllmAPI"
3
- version = "2.0.5"
3
+ version = "2.0.6"
4
4
  authors = [
5
5
  { name="Stella Wenxing Liu", email="stellawenxingliu@gmail.com" },
6
6
  { name="Varun Shourie", email="svarun195@gmail.com" }
File without changes
File without changes
File without changes
File without changes
File without changes