ws-bom-robot-app 0.0.43__py3-none-any.whl → 0.0.45__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.
@@ -88,7 +88,7 @@ class AgentDescriptor:
88
88
 
89
89
  def __init__(self, llm: LlmInterface, prompt: str, mode: str, rules: LlmRules = None):
90
90
  self.__prompt = prompt
91
- self.__llm = llm,
91
+ self.__llm = llm
92
92
  self.rules= rules
93
93
  self.strategy = self.get_strategy(mode) # Selects the strategy from the dictionary
94
94
 
@@ -64,7 +64,7 @@ class AgentHandler(AsyncCallbackHandler):
64
64
  if token:
65
65
  token = _parse_token(self.llm,token)
66
66
  if token:
67
- self.stream_buffer += token.replace('\n','') # append new data to pending buffer
67
+ self.stream_buffer += token # append new data to pending buffer
68
68
  if not self.in_json_block:
69
69
  # search for the start of a json block.
70
70
  start_match = self.json_start_regex.search(self.stream_buffer)
@@ -90,7 +90,7 @@ class AgentHandler(AsyncCallbackHandler):
90
90
  self.stream_buffer = self.stream_buffer[-3:]
91
91
  else:
92
92
  # in json block: look for an end fence.
93
- end_match = self.json_end_regex.search(self.stream_buffer,endpos=3)
93
+ end_match = self.json_end_regex.search(self.stream_buffer)
94
94
  if end_match:
95
95
  end_index = end_match.start()
96
96
  self.json_buffer += self.stream_buffer[:end_index]
@@ -1,4 +1,4 @@
1
- from typing import Annotated, Any
1
+ from typing import Annotated, Any, Mapping
2
2
  from fastapi import APIRouter, HTTPException, Request, Header
3
3
  from fastapi.responses import StreamingResponse
4
4
  from ws_bom_robot_app.llm.agent_description import AgentDescriptor
@@ -9,7 +9,7 @@ from ws_bom_robot_app.llm.vector_store.generator import kb, rules, kb_stream_fil
9
9
  from ws_bom_robot_app.llm.tools.tool_manager import ToolManager
10
10
  from ws_bom_robot_app.llm.vector_store.integration.manager import IntegrationManager
11
11
  from ws_bom_robot_app.task_manager import task_manager, TaskHeader
12
-
12
+ from uuid import uuid4
13
13
  router = APIRouter(prefix="/api/llm", tags=["llm"])
14
14
 
15
15
  @router.get("/")
@@ -20,13 +20,15 @@ async def root():
20
20
  async def _invoke(rq: InvokeRequest):
21
21
  return await invoke(rq)
22
22
 
23
+ def _stream_headers(rq: StreamRequest) -> Mapping[str, str]:
24
+ return {"X-thread-id": rq.thread_id or str(uuid4())}
23
25
  @router.post("/stream")
24
26
  async def _stream(rq: StreamRequest, ctx: Request) -> StreamingResponse:
25
- return StreamingResponse(stream(rq, ctx), media_type="application/json")
27
+ return StreamingResponse(stream(rq, ctx), media_type="application/json", headers=_stream_headers(rq))
26
28
 
27
29
  @router.post("/stream/raw")
28
30
  async def _stream_raw(rq: StreamRequest, ctx: Request) -> StreamingResponse:
29
- return StreamingResponse(stream(rq, ctx, formatted=False), media_type="application/json")
31
+ return StreamingResponse(stream(rq, ctx, formatted=False), media_type="application/json", headers=_stream_headers(rq))
30
32
 
31
33
  @router.post("/kb")
32
34
  async def _kb(rq: KbRequest) -> VectorDbResponse:
@@ -71,10 +71,11 @@ class DeepSeek(LlmInterface):
71
71
  )
72
72
 
73
73
  def get_models(self):
74
- return [
75
- {"id":"deepseek-chat"},
76
- {"id":"deepseek-reasoner"}
77
- ]
74
+ import openai
75
+ openai.api_key = self.config.api_key or os.getenv("DEEPSEEK_API_KEY")
76
+ openai.base_url = "https://api.deepseek.com"
77
+ response = openai.models.list()
78
+ return response.data
78
79
 
79
80
  class Google(LlmInterface):
80
81
  def get_llm(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ws_bom_robot_app
3
- Version: 0.0.43
3
+ Version: 0.0.45
4
4
  Summary: A FastAPI application serving ws bom/robot/llm platform ai.
5
5
  Home-page: https://github.com/websolutespa/bom
6
6
  Author: Websolute Spa
@@ -6,10 +6,10 @@ ws_bom_robot_app/main.py,sha256=zO3B-v-v9ESASvw8IaQj9Y9hNvNmOxohFmA0R82EybQ,6518
6
6
  ws_bom_robot_app/task_manager.py,sha256=Zedzs2R3O-wNSQOqs4jorgFwPRi-ji_0TN4mGfk-VvE,15958
7
7
  ws_bom_robot_app/util.py,sha256=b49ItlZgh2Wzw-6K8k5Wa44eVgjQ0JmWQwJnEaQBVGw,3502
8
8
  ws_bom_robot_app/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- ws_bom_robot_app/llm/agent_description.py,sha256=DKPGchYXrkxt8pRpOabn5QE_qn8jSKl92pLpnVLHG5I,4657
10
- ws_bom_robot_app/llm/agent_handler.py,sha256=37SGUvjV_u6k-ufetulZlMGKksDc4ItoIdz-nwDLIBw,7604
9
+ ws_bom_robot_app/llm/agent_description.py,sha256=yK4aVU3RNk1oP4bEneV3QPAi-208JwWk4R6qHlzqYIg,4656
10
+ ws_bom_robot_app/llm/agent_handler.py,sha256=zRjUZ9D3GIAfmKl1473k2b8YHswZy5rTWdS5BCbZyaY,7578
11
11
  ws_bom_robot_app/llm/agent_lcel.py,sha256=iF03Q2fiJ60Zv-ia0eYwz46IPMTJaijb6xcn6cJIUZc,2260
12
- ws_bom_robot_app/llm/api.py,sha256=UaD1oJyAOe7ASoXxPNJcth3kDuWcjk1xqUNEjuPWbR4,3759
12
+ ws_bom_robot_app/llm/api.py,sha256=BIytnysVK_Iz2RmYmD314cduWAh55l_YcEUvPvb3-oI,3968
13
13
  ws_bom_robot_app/llm/defaut_prompt.py,sha256=LlCd_nSMkMmHESfiiiQYfnJyB6Pp-LSs4CEKdYW4vFk,1106
14
14
  ws_bom_robot_app/llm/main.py,sha256=tr7gPjSzO2w85ipSxWVcathNxJC3NKTdJKY89VhhKOM,4973
15
15
  ws_bom_robot_app/llm/settings.py,sha256=EkFGCppORenStH9W4e6_dYvQ-5p6xiEMpmUHBqNqG9M,117
@@ -18,7 +18,7 @@ ws_bom_robot_app/llm/models/api.py,sha256=mLbPG7jHh1EjgQG-xpBhEgiTIHpK35HZ51obgq
18
18
  ws_bom_robot_app/llm/models/base.py,sha256=1TqxuTK3rjJEALn7lvgoen_1ba3R2brAgGx6EDTtDZo,152
19
19
  ws_bom_robot_app/llm/models/kb.py,sha256=oVSw6_dmNxikAHrPqcfxDXz9M0ezLIYuxpgvzfs_Now,9514
20
20
  ws_bom_robot_app/llm/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- ws_bom_robot_app/llm/providers/llm_manager.py,sha256=vaSVbCKV5tbNg9cCVRa9KgeOoSqIbaSuG1DeIERl90M,8113
21
+ ws_bom_robot_app/llm/providers/llm_manager.py,sha256=VVRaRfnqx1g6eXhKhWmUGIOfR4hmKcUAAqFQtET5R5U,8226
22
22
  ws_bom_robot_app/llm/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  ws_bom_robot_app/llm/tools/tool_builder.py,sha256=OaA0jReNUpjfe7c8TVLM86acQ4w0cQaR3NE22hGKJb0,1165
24
24
  ws_bom_robot_app/llm/tools/tool_manager.py,sha256=RZcJVPyWT9D3HUxSO1d5kSfTQtJB2CG5hocuFa01AzY,5816
@@ -60,7 +60,7 @@ ws_bom_robot_app/llm/vector_store/loader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5
60
60
  ws_bom_robot_app/llm/vector_store/loader/base.py,sha256=L_ugekNuAq0N9O-24wtlHSNHkqSeD-KsJrfGt_FX9Oc,5340
61
61
  ws_bom_robot_app/llm/vector_store/loader/docling.py,sha256=yP0zgXLeFAlByaYuj-6cYariuknckrFds0dxdRcnVz8,3456
62
62
  ws_bom_robot_app/llm/vector_store/loader/json_loader.py,sha256=qo9ejRZyKv_k6jnGgXnu1W5uqsMMtgqK_uvPpZQ0p74,833
63
- ws_bom_robot_app-0.0.43.dist-info/METADATA,sha256=zt3XihJLZb1XS5Nx2vh8nDzZO_9HS0nc_gFo90bONtg,8348
64
- ws_bom_robot_app-0.0.43.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
65
- ws_bom_robot_app-0.0.43.dist-info/top_level.txt,sha256=Yl0akyHVbynsBX_N7wx3H3ZTkcMLjYyLJs5zBMDAKcM,17
66
- ws_bom_robot_app-0.0.43.dist-info/RECORD,,
63
+ ws_bom_robot_app-0.0.45.dist-info/METADATA,sha256=Iky-VB6cy4w2PQ8us_WeCfrSDwJWSwhfKDyblnaDu6Y,8348
64
+ ws_bom_robot_app-0.0.45.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
65
+ ws_bom_robot_app-0.0.45.dist-info/top_level.txt,sha256=Yl0akyHVbynsBX_N7wx3H3ZTkcMLjYyLJs5zBMDAKcM,17
66
+ ws_bom_robot_app-0.0.45.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.0.0)
2
+ Generator: setuptools (76.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5