ws-bom-robot-app 0.0.101__tar.gz → 0.0.103__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.
Files changed (84) hide show
  1. {ws_bom_robot_app-0.0.101/ws_bom_robot_app.egg-info → ws_bom_robot_app-0.0.103}/PKG-INFO +1 -1
  2. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/setup.py +1 -1
  3. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/agent_context.py +1 -1
  4. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/agent_lcel.py +20 -24
  5. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/tools/tool_manager.py +12 -1
  6. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/cms.py +10 -1
  7. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103/ws_bom_robot_app.egg-info}/PKG-INFO +1 -1
  8. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/MANIFEST.in +0 -0
  9. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/README.md +0 -0
  10. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/pyproject.toml +0 -0
  11. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/requirements.txt +0 -0
  12. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/setup.cfg +0 -0
  13. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/__init__.py +0 -0
  14. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/auth.py +0 -0
  15. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/config.py +0 -0
  16. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/cron_manager.py +0 -0
  17. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/__init__.py +0 -0
  18. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/agent_description.py +0 -0
  19. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/agent_handler.py +0 -0
  20. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/api.py +0 -0
  21. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/defaut_prompt.py +0 -0
  22. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/evaluator.py +0 -0
  23. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/feedbacks/__init__.py +0 -0
  24. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/feedbacks/feedback_manager.py +0 -0
  25. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/main.py +0 -0
  26. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/models/__init__.py +0 -0
  27. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/models/api.py +0 -0
  28. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/models/base.py +0 -0
  29. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/models/feedback.py +0 -0
  30. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/models/kb.py +0 -0
  31. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/nebuly_handler.py +0 -0
  32. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/providers/__init__.py +0 -0
  33. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/providers/llm_manager.py +0 -0
  34. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/tools/__init__.py +0 -0
  35. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/tools/models/__init__.py +0 -0
  36. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/tools/models/main.py +0 -0
  37. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/tools/tool_builder.py +0 -0
  38. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/tools/utils.py +0 -0
  39. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/__init__.py +0 -0
  40. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/agent.py +0 -0
  41. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/chunker.py +0 -0
  42. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/cleanup.py +0 -0
  43. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/download.py +0 -0
  44. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/print.py +0 -0
  45. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/secrets.py +0 -0
  46. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/utils/webhooks.py +0 -0
  47. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/__init__.py +0 -0
  48. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/db/__init__.py +0 -0
  49. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/db/base.py +0 -0
  50. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/db/chroma.py +0 -0
  51. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/db/faiss.py +0 -0
  52. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/db/manager.py +0 -0
  53. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/db/qdrant.py +0 -0
  54. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/generator.py +0 -0
  55. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/__init__.py +0 -0
  56. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/api.py +0 -0
  57. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/azure.py +0 -0
  58. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/base.py +0 -0
  59. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/confluence.py +0 -0
  60. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/dropbox.py +0 -0
  61. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/gcs.py +0 -0
  62. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/github.py +0 -0
  63. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/googledrive.py +0 -0
  64. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/jira.py +0 -0
  65. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/manager.py +0 -0
  66. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/s3.py +0 -0
  67. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/sftp.py +0 -0
  68. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/sharepoint.py +0 -0
  69. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/shopify.py +0 -0
  70. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/sitemap.py +0 -0
  71. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/slack.py +0 -0
  72. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/integration/thron.py +0 -0
  73. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/loader/__init__.py +0 -0
  74. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/loader/base.py +0 -0
  75. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/loader/docling.py +0 -0
  76. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/llm/vector_store/loader/json_loader.py +0 -0
  77. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/main.py +0 -0
  78. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/subprocess_runner.py +0 -0
  79. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/task_manager.py +0 -0
  80. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app/util.py +0 -0
  81. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app.egg-info/SOURCES.txt +0 -0
  82. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app.egg-info/dependency_links.txt +0 -0
  83. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app.egg-info/requires.txt +0 -0
  84. {ws_bom_robot_app-0.0.101 → ws_bom_robot_app-0.0.103}/ws_bom_robot_app.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ws_bom_robot_app
3
- Version: 0.0.101
3
+ Version: 0.0.103
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
@@ -4,7 +4,7 @@ _requirements = [line.split('#')[0].strip() for line in open("requirements.txt")
4
4
 
5
5
  setup(
6
6
  name="ws_bom_robot_app",
7
- version="0.0.101",
7
+ version="0.0.103",
8
8
  description="A FastAPI application serving ws bom/robot/llm platform ai.",
9
9
  long_description=open("README.md", encoding='utf-8').read(),
10
10
  long_description_content_type="text/markdown",
@@ -7,7 +7,7 @@ class AgentContext(BaseModel):
7
7
  class _i18n(BaseModel):
8
8
  lg: Optional[str] = "en"
9
9
  country: Optional[str] = "US"
10
- timestamp: Optional[str] = Field(default_factory=lambda: datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
10
+ timestamp: Optional[str] = Field(default_factory=lambda: datetime.now().strftime("%Y-%m-%d %H:%M:%S %A"))
11
11
  timezone: Optional[str] = "UTC"
12
12
  model_config = ConfigDict(extra='allow')
13
13
  class _user(BaseModel):
@@ -22,13 +22,9 @@ class AgentLcel:
22
22
  self.embeddings = llm.get_embeddings()
23
23
  self.memory_key: str = "chat_history"
24
24
  self.__llm_with_tools = llm.get_llm().bind_tools(self.__tools) if len(self.__tools) > 0 else llm.get_llm()
25
-
26
- # Configura l'LLM in base alla modalità
27
25
  if self.json_schema:
28
- # JSON mode: usa with_structured_output per output strutturato mantenendo i tool
29
26
  self.__pydantic_schema = self.__create_pydantic_schema()
30
27
  else:
31
- # Agent mode standard
32
28
  self.__pydantic_schema = None
33
29
 
34
30
  self.executor = self.__create_agent()
@@ -68,13 +64,7 @@ class AgentLcel:
68
64
  return create_model('JsonSchema', **fields)
69
65
 
70
66
  def __get_output_parser(self):
71
- """Restituisce il parser appropriato in base alla modalità."""
72
- if self.json_schema and self.__pydantic_schema:
73
- # In modalità JSON, usa with_structured_output direttamente nell'agent
74
- # Il parser qui serve solo per compatibilità, la conversione avviene prima
75
- return self.__llm.get_parser()
76
- else:
77
- return self.__llm.get_parser()
67
+ return self.__llm.get_parser()
78
68
 
79
69
  async def __create_prompt(self, input: dict) -> ChatPromptTemplate:
80
70
  from langchain_core.messages import SystemMessage
@@ -82,9 +72,14 @@ class AgentLcel:
82
72
  rules_prompt = await get_rules(self.embeddings, self.rules, message.content) if self.rules else ""
83
73
  system = default_prompt + (tool_prompt(render_text_description(self.__tools)) if len(self.__tools)>0 else "") + self.sys_message + rules_prompt
84
74
 
85
- # Aggiungere istruzioni per output strutturato se è presente json_schema
75
+ # Aggiungi istruzioni per output JSON strutturato se necessario
86
76
  if self.json_schema and self.__pydantic_schema:
87
- system += f"\n\nYou must respond with a JSON object matching this schema: {self.__pydantic_schema.schema_json()}"
77
+ json_instructions = f"\n\nIMPORTANT: You must format your final response as a JSON object with the following structure:\n"
78
+ for field_name, field_info in self.__pydantic_schema.model_fields.items():
79
+ field_type = field_info.annotation.__name__ if hasattr(field_info.annotation, '__name__') else str(field_info.annotation)
80
+ json_instructions += f"- {field_name}: {field_type}\n"
81
+ json_instructions += "\nProvide ONLY the JSON object in your response, no additional text."
82
+ system += json_instructions
88
83
 
89
84
  messages = [
90
85
  SystemMessage(content=system),
@@ -98,14 +93,15 @@ class AgentLcel:
98
93
  )
99
94
  return prompt
100
95
 
101
- def __create_agent(self) -> AgentExecutor:
102
- agent: Any = (
103
- {
104
- "agent_scratchpad": lambda x: self.__llm.get_formatter(x["intermediate_steps"]),
105
- str(self.memory_key): lambda x: x[self.memory_key],
106
- }
107
- | RunnableLambda(self.__create_prompt)
108
- | self.__llm_with_tools
109
- | self.__get_output_parser()
110
- )
111
- return AgentExecutor(agent=agent,tools=self.__tools,verbose=False)
96
+ def __create_agent(self):
97
+ # Un solo AgentExecutor per entrambe le modalità
98
+ agent = (
99
+ {
100
+ "agent_scratchpad": lambda x: self.__llm.get_formatter(x["intermediate_steps"]),
101
+ self.memory_key: lambda x: x[self.memory_key],
102
+ }
103
+ | RunnableLambda(self.__create_prompt)
104
+ | self.__llm_with_tools
105
+ | self.__get_output_parser()
106
+ )
107
+ return AgentExecutor(agent=agent, tools=self.__tools, verbose=False)
@@ -1,5 +1,5 @@
1
1
  from asyncio import Queue
2
- import aiohttp
2
+ import aiohttp, re
3
3
  from typing import Optional, Type, Callable
4
4
  from ws_bom_robot_app.config import config
5
5
  from ws_bom_robot_app.llm.models.api import LlmApp,LlmAppTool
@@ -200,10 +200,21 @@ class ToolManager:
200
200
  else: # default
201
201
  try:
202
202
  from ws_bom_robot_app.llm.main import stream
203
+ import json
203
204
  chunks = []
204
205
  async for chunk in stream(rq=app.rq, ctx=None, formatted=False):
205
206
  chunks.append(chunk)
206
207
  rs = ''.join(chunks) if chunks else None
208
+
209
+ # if the app has output_structure, parse the JSON and return dict
210
+ if rs and app.rq.output_structure:
211
+ try:
212
+ cleaned_rs = re.sub(r'^```(?:json)?\s*\n?', '', rs.strip())
213
+ cleaned_rs = re.sub(r'\n?```\s*$', '', cleaned_rs)
214
+ return json.loads(cleaned_rs)
215
+ except json.JSONDecodeError:
216
+ print(f"[!] Failed to parse JSON output from proxy_app_chat: {rs}")
217
+ return rs
207
218
  return rs
208
219
  except Exception as e:
209
220
  print(f"[!] Error in proxy_app_chat: {e}")
@@ -37,6 +37,14 @@ async def get_apps() -> list[CmsApp]:
37
37
  if obj is None:
38
38
  break
39
39
  return obj
40
+ def __to_dict(obj):
41
+ """Converts DictObject to dict recursively"""
42
+ if isinstance(obj, DictObject):
43
+ return {k: __to_dict(v) for k, v in obj.__dict__.items()}
44
+ elif isinstance(obj, list):
45
+ return [__to_dict(item) for item in obj]
46
+ else:
47
+ return obj
40
48
  host = config.robot_cms_host
41
49
  if host:
42
50
  url = f"{host}/api/llmApp?depth=1&pagination=false&locale=it"
@@ -77,7 +85,8 @@ async def get_apps() -> list[CmsApp]:
77
85
  ) if __attr(_cms_app_dict.settings,'rules','vectorDbFile','filename') else None,
78
86
  #fine_tuned_model=__attr(_cms_app_dict.settings,'llmConfig','fineTunedModel'),
79
87
  lang_chain_tracing= __attr(_cms_app_dict.settings,'llmConfig','langChainTracing', default=False),
80
- lang_chain_project= __attr(_cms_app_dict.settings,'llmConfig','langChainProject', default='')
88
+ lang_chain_project= __attr(_cms_app_dict.settings,'llmConfig','langChainProject', default=''),
89
+ output_structure= __to_dict(__attr(_cms_app_dict.settings,'llmConfig','outputStructure')) if __attr(_cms_app_dict.settings,'llmConfig','outputStructure') else None
81
90
  ))
82
91
  except Exception as e:
83
92
  import traceback
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ws_bom_robot_app
3
- Version: 0.0.101
3
+ Version: 0.0.103
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