sunholo 0.55.13__py3-none-any.whl → 0.55.15__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.
@@ -25,7 +25,7 @@ def extract_chat_history(chat_history=None):
25
25
  # Output: [("Hello, AI!", "Hello, Human! How can I help you today?")]
26
26
  ```
27
27
  """
28
- if chat_history is None:
28
+ if not chat_history:
29
29
  log.info("No chat history found")
30
30
  return []
31
31
 
@@ -52,15 +52,17 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
52
52
  return jsonify(command_response)
53
53
 
54
54
  log.info(f'Streaming data with: {all_input}')
55
+ if span:
56
+ generation = span.generation(
57
+ name="start_streaming_chat",
58
+ metadata=vac_config,
59
+ input = all_input,
60
+ completion_start_time=datetime.datetime.now(),
61
+ model=vac_config.get("model") or vac_config.get("llm")
62
+ )
63
+
55
64
  def generate_response_content():
56
- if span:
57
- generation = span.generation(
58
- name="start_streaming_chat",
59
- metadata=vac_config,
60
- input = all_input,
61
- completion_start_time=datetime.datetime.now(),
62
- model=vac_config.get("model") or vac_config.get("llm")
63
- )
65
+
64
66
  chunks = ""
65
67
  for chunk in start_streaming_chat(question=all_input["user_input"],
66
68
  vector_name=vector_name,
@@ -69,7 +71,7 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
69
71
  wait_time=all_input["stream_wait_time"],
70
72
  timeout=all_input["stream_timeout"],
71
73
  #kwargs
72
- message_author=all_input["message_author"]
74
+ **all_input["kwargs"]
73
75
  ):
74
76
  if isinstance(chunk, dict) and 'answer' in chunk:
75
77
  # When we encounter the dictionary, we yield it as a JSON string
@@ -92,14 +94,15 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
92
94
 
93
95
  yield chunk
94
96
 
95
- if trace:
96
- generation.end(output=chunks)
97
- span.end(output=chunks)
98
- trace.update(output=chunks)
99
-
100
97
  # Here, the generator function will handle streaming the content to the client.
101
98
  response = Response(generate_response_content(), content_type='text/plain; charset=utf-8')
102
99
  response.headers['Transfer-Encoding'] = 'chunked'
100
+
101
+ log.debug(f"streaming response: {response}")
102
+ if trace:
103
+ generation.end(output=response)
104
+ span.end(output=response)
105
+ trace.update(output=response)
103
106
 
104
107
  if langfuse:
105
108
  langfuse.flush()
@@ -131,7 +134,7 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
131
134
  question=all_input["user_input"],
132
135
  vector_name=vector_name,
133
136
  chat_history=all_input["chat_history"],
134
- message_author=all_input["message_author"]
137
+ **all_input["kwargs"]
135
138
  )
136
139
  if generation:
137
140
  generation.end(output=bot_output)
@@ -198,18 +201,18 @@ def prep_vac(request, vector_name):
198
201
  if trace:
199
202
  trace.update(input=data, metadata=vac_config)
200
203
 
201
- user_input = data['user_input'].strip()
202
- message_author = data.get('message_author', None)
203
- stream_wait_time = data.get('stream_wait_time', 7)
204
- stream_timeout = data.get('stream_timeout', 120)
204
+ user_input = data.pop('user_input').strip()
205
+ stream_wait_time = data.pop('stream_wait_time', 7)
206
+ stream_timeout = data.pop('stream_timeout', 120)
207
+ chat_history = data.pop('chat_history', None)
208
+ paired_messages = extract_chat_history(chat_history)
205
209
 
206
- paired_messages = extract_chat_history(data.get('chat_history', None))
207
210
  all_input = {'user_input': user_input,
208
211
  'vector_name': vector_name,
209
212
  'chat_history': paired_messages,
210
- 'message_author': message_author,
211
213
  'stream_wait_time': stream_wait_time,
212
- 'stream_timeout':stream_timeout}
214
+ 'stream_timeout':stream_timeout,
215
+ 'kwargs': data}
213
216
 
214
217
  if trace:
215
218
  span = trace.span(
@@ -130,6 +130,7 @@ class BufferStreamingStdOutCallbackHandler(StreamingStdOutCallbackHandler):
130
130
  patterns are detected.
131
131
  """
132
132
  log.debug(f"on_llm_new_token: {token}")
133
+
133
134
  self.buffer += token
134
135
 
135
136
  if '```' in token:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.55.13
3
+ Version: 0.55.15
4
4
  Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
5
5
  Home-page: https://github.com/sunholo-data/sunholo-py
6
- Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.55.13.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.55.15.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -1,7 +1,7 @@
1
1
  sunholo/__init__.py,sha256=hEN0kOEikUGBot_YIMra1nnPNmcwmO_kwvPOmLW8-_8,692
2
2
  sunholo/logging.py,sha256=z0aI0u1Bk_be3c6EDCGf0hn4JZKymYqIySbfCKOqpkQ,10881
3
3
  sunholo/agents/__init__.py,sha256=CnlbVohPt-Doth9PyROSlN3P8xMV9j9yS19YE-wCS90,341
4
- sunholo/agents/chat_history.py,sha256=SajDa9OEJeXLyPvCH7O4NbjtNrZyqYaop16lDgapsfI,5199
4
+ sunholo/agents/chat_history.py,sha256=PbwYmw1TwzI8H-cwQIGgHZ6UIr2Qb-JWow0RG3ayLM8,5195
5
5
  sunholo/agents/dispatch_to_qa.py,sha256=kWrO-CJel5kJAyyCShShpACUuZpqDOP7DN8vo_7ciao,8056
6
6
  sunholo/agents/langserve.py,sha256=FdhQjorAY2bMn2rpuabNT6bU3uqSKWrl8DjpH3L_V7k,4375
7
7
  sunholo/agents/pubsub.py,sha256=5hbbhbBGyVWRpt2sAGC5FEheYH1mCCwVUhZEB1S7vGg,1337
@@ -13,7 +13,7 @@ sunholo/agents/fastapi/base.py,sha256=clk76cHbUAvU0OYJrRfCWX_5f0ACbhDsIzYBhI3wyo
13
13
  sunholo/agents/fastapi/qna_routes.py,sha256=Xl05L8DjUozGMK7kKPqz7Twr4W56BnLQu_uprsTv_q0,4075
14
14
  sunholo/agents/flask/__init__.py,sha256=uqfHNw2Ru3EJ4dJEcbp86h_lkquBQPMxZbjhV_xe3rs,72
15
15
  sunholo/agents/flask/base.py,sha256=RUGWBYWeV60FatYF5sMRrxD-INU97Vodsi6JaB6i93s,763
16
- sunholo/agents/flask/qna_routes.py,sha256=WgmVGl7S4TvQWoAXO0b06FkGf0O-iDQUbB7WyC9YaSY,8850
16
+ sunholo/agents/flask/qna_routes.py,sha256=A_L9w966Pb_MZSh17gcu5HxmzJdiclKaKTZ0ARaSRjg,8785
17
17
  sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,31
18
18
  sunholo/archive/archive.py,sha256=C-UhG5x-XtZ8VheQp92IYJqgD0V3NFQjniqlit94t18,1197
19
19
  sunholo/auth/__init__.py,sha256=4owDjSaWYkbTlPK47UHTOC0gCWbZsqn4ZIEw5NWZTlg,28
@@ -72,7 +72,7 @@ sunholo/qna/__init__.py,sha256=F8q1uR_HreoSX0IfmKY1qoSwIgXhO2Q8kuDSxh9_-EE,28
72
72
  sunholo/qna/parsers.py,sha256=Qn7lYsO2daWN0kDRGop5CkamIPq9wWFPEB1cP6Is7Ng,1585
73
73
  sunholo/qna/retry.py,sha256=hAcqCZchAG1610G6huPev4ymDdO2G5tT3mrK28dxlAs,2028
74
74
  sunholo/streaming/__init__.py,sha256=k8dBqhzyS1Oi6NfADtRtWfnPtU1FU2kQz-YxH9yrNeQ,197
75
- sunholo/streaming/content_buffer.py,sha256=xcljhbpPQa-6O9M-Du3HiZqxW3XbvG_C4qNohtrsQPg,6587
75
+ sunholo/streaming/content_buffer.py,sha256=hr2ySHOTK1zw_3u-JrKwoomsAAdda2VcOxjkvJLcUuM,6596
76
76
  sunholo/streaming/langserve.py,sha256=6isOvFwZBfmiQY5N41PYPyrdJj9IgJXXHLfTzPvewGw,6299
77
77
  sunholo/streaming/streaming.py,sha256=0Bgl_FYmd2GJuy_4khDx5y_nfPqDp7Yu8ZkQ9POVhGk,16446
78
78
  sunholo/summarise/__init__.py,sha256=MZk3dblUMODcPb1crq4v-Z508NrFIpkSWNf9FIO8BcU,38
@@ -81,8 +81,8 @@ sunholo/utils/__init__.py,sha256=MxuxoJ-oOie_skGnB4mOagVYjzvfmX9Gz9N5heI8azM,62
81
81
  sunholo/utils/config.py,sha256=KYuhwmhYS7qOpt2ZcpAWnlHPJ9rBDX1SgP8gnjkAW6E,7321
82
82
  sunholo/utils/gcp.py,sha256=B2G1YKjeD7X9dqO86Jrp2vPuFwZ223Xl5Tg09Ndw-oc,5760
83
83
  sunholo/utils/parsers.py,sha256=E-M7s3_rPviT5zCqQHzhb1DwYmz5a1J472ZVazx10M8,3400
84
- sunholo-0.55.13.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
85
- sunholo-0.55.13.dist-info/METADATA,sha256=GcdZKMXCKHhajZgrFwcFxSzXOVxMBsM2FzOfNI2Lj5w,6434
86
- sunholo-0.55.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
87
- sunholo-0.55.13.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
88
- sunholo-0.55.13.dist-info/RECORD,,
84
+ sunholo-0.55.15.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
85
+ sunholo-0.55.15.dist-info/METADATA,sha256=rCF_1oWdOx8Zvn9HZA3E5JZKZXBSvM05F1tX8Q1jheA,6434
86
+ sunholo-0.55.15.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
87
+ sunholo-0.55.15.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
88
+ sunholo-0.55.15.dist-info/RECORD,,