sunholo 0.64.3__py3-none-any.whl → 0.64.4__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.
@@ -165,13 +165,18 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
165
165
  return jsonify(bot_output)
166
166
 
167
167
  @app.route('/openai/v1/chat/completions', methods=['POST'])
168
- def openai_compatible_endpoint():
168
+ @app.route('/openai/v1/chat/completions/<vector_name>', methods=['POST'])
169
+ def openai_compatible_endpoint(vector_name=None):
169
170
  data = request.get_json()
170
- model = data.pop('model', None)
171
+ log.info(f'openai_compatible_endpoint got data: {data}')
172
+
173
+ vector_name = vector_name or data.pop('model', None)
171
174
  messages = data.pop('messages', None)
172
175
  chat_history = data.pop('chat_history', None)
173
176
  stream = data.pop('stream', False)
174
177
 
178
+ log.info(f'openai_compatible_endpoint got data: {data} for vector: {vector_name}')
179
+
175
180
  if not messages:
176
181
  return jsonify({"error": "No messages provided"}), 400
177
182
 
@@ -192,34 +197,36 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
192
197
 
193
198
  def generate_response_content():
194
199
  for chunk in start_streaming_chat(question=user_message,
195
- vector_name=model,
200
+ vector_name=vector_name,
196
201
  qna_func=observed_stream_interpreter,
197
202
  chat_history=all_input["chat_history"],
198
203
  wait_time=all_input.get("stream_wait_time", 1),
199
204
  timeout=all_input.get("stream_timeout", 60),
200
205
  **all_input["kwargs"]
201
206
  ):
202
- if isinstance(chunk, dict) and 'content' in chunk:
207
+ if isinstance(chunk, dict) and 'answer' in chunk:
203
208
  openai_chunk = {
204
209
  "id": response_id,
205
210
  "object": "chat.completion.chunk",
206
- "created": int(datetime.time()),
207
- "model": model,
211
+ "created": str(datetime.time()),
212
+ "model": vector_name,
208
213
  "system_fingerprint": sunholo_version(),
209
214
  "choices": [{
210
215
  "index": 0,
211
- "delta": {"content": chunk['content']},
216
+ "delta": {"content": chunk['answer']},
212
217
  "logprobs": None,
213
218
  "finish_reason": None
214
219
  }]
215
220
  }
216
221
  yield json.dumps(openai_chunk) + "\n"
222
+ else:
223
+ log.info(f"Unknown chunk: {chunk}")
217
224
 
218
225
  final_chunk = {
219
226
  "id": response_id,
220
227
  "object": "chat.completion.chunk",
221
- "created": int(datetime.time()),
222
- "model": model,
228
+ "created": str(datetime.time()),
229
+ "model": vector_name,
223
230
  "system_fingerprint": sunholo_version(),
224
231
  "choices": [{
225
232
  "index": 0,
@@ -236,7 +243,7 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
236
243
  try:
237
244
  bot_output = observed_stream_interpreter(
238
245
  question=user_message,
239
- vector_name=model,
246
+ vector_name=vector_name,
240
247
  chat_history=all_input["chat_history"],
241
248
  **all_input["kwargs"]
242
249
  )
@@ -245,8 +252,8 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
245
252
  openai_response = {
246
253
  "id": response_id,
247
254
  "object": "chat.completion",
248
- "created": int(datetime.time()),
249
- "model": model,
255
+ "created": str(datetime.time()),
256
+ "model": vector_name,
250
257
  "system_fingerprint": sunholo_version(),
251
258
  "choices": [{
252
259
  "index": 0,
@@ -264,6 +271,7 @@ def register_qna_routes(app, stream_interpreter, vac_interpreter):
264
271
  }
265
272
  }
266
273
 
274
+ log.info(f"OpenAI response: {openai_response}")
267
275
  return jsonify(openai_response)
268
276
 
269
277
  except Exception as err:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.64.3
3
+ Version: 0.64.4
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.64.3.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.64.4.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -12,7 +12,7 @@ sunholo/agents/fastapi/base.py,sha256=clk76cHbUAvU0OYJrRfCWX_5f0ACbhDsIzYBhI3wyo
12
12
  sunholo/agents/fastapi/qna_routes.py,sha256=DgK4Btu5XriOC1JaRQ4G_nWEjJfnQ0J5pyLanF6eF1g,3857
13
13
  sunholo/agents/flask/__init__.py,sha256=uqfHNw2Ru3EJ4dJEcbp86h_lkquBQPMxZbjhV_xe3rs,72
14
14
  sunholo/agents/flask/base.py,sha256=FgSaCODyoTtlstJtsqlLPScdgRUtv9_plxftdzHdVFo,809
15
- sunholo/agents/flask/qna_routes.py,sha256=NAicUK_vfMK1ovR2wGLdplGnwV4w8_cfwFNOTjiMzNg,14074
15
+ sunholo/agents/flask/qna_routes.py,sha256=yskVD7bP_MAvWipZcdsdNyvh1WVlYr9VqbokfV09pYM,14513
16
16
  sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,31
17
17
  sunholo/archive/archive.py,sha256=C-UhG5x-XtZ8VheQp92IYJqgD0V3NFQjniqlit94t18,1197
18
18
  sunholo/auth/__init__.py,sha256=4owDjSaWYkbTlPK47UHTOC0gCWbZsqn4ZIEw5NWZTlg,28
@@ -102,9 +102,9 @@ sunholo/vertex/__init__.py,sha256=JvHcGFuv6R_nAhY2AdoqqhMpJ5ugeWPZ_svGhWrObBk,13
102
102
  sunholo/vertex/init.py,sha256=JDMUaBRdednzbKF-5p33qqLit2LMsvgvWW-NRz0AqO0,1801
103
103
  sunholo/vertex/memory_tools.py,sha256=8F1iTWnqEK9mX4W5RzCVKIjydIcNp6OFxjn_dtQ3GXo,5379
104
104
  sunholo/vertex/safety.py,sha256=3meAX0HyGZYrH7rXPUAHxtI_3w_zoy_RX7Shtkoa660,1275
105
- sunholo-0.64.3.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
106
- sunholo-0.64.3.dist-info/METADATA,sha256=BmLFSkbWpUHnOLvrqJsgQZuotjYptCsYyPiLtR5bg9M,5971
107
- sunholo-0.64.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
108
- sunholo-0.64.3.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
109
- sunholo-0.64.3.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
110
- sunholo-0.64.3.dist-info/RECORD,,
105
+ sunholo-0.64.4.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
106
+ sunholo-0.64.4.dist-info/METADATA,sha256=-vzVQ820NsKlAjLeentAjVDxSWvjKIH5y4Up5Wi1vtU,5971
107
+ sunholo-0.64.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
108
+ sunholo-0.64.4.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
109
+ sunholo-0.64.4.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
110
+ sunholo-0.64.4.dist-info/RECORD,,