sonika-langchain-bot 0.0.14__tar.gz → 0.0.15__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.
- {sonika_langchain_bot-0.0.14/src/sonika_langchain_bot.egg-info → sonika_langchain_bot-0.0.15}/PKG-INFO +1 -1
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/setup.py +1 -1
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/langchain_bot_agent.py +22 -11
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15/src/sonika_langchain_bot.egg-info}/PKG-INFO +1 -1
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/LICENSE +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/README.md +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/setup.cfg +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/__init__.py +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/document_processor.py +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/langchain_clasificator.py +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/langchain_class.py +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/langchain_files.py +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/langchain_models.py +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/langchain_tools.py +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot.egg-info/SOURCES.txt +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot.egg-info/dependency_links.txt +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot.egg-info/requires.txt +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot.egg-info/top_level.txt +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/test/test.py +0 -0
- {sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/test/test_document_processor.py +0 -0
|
@@ -9,7 +9,6 @@ from langgraph.graph import StateGraph, END, add_messages
|
|
|
9
9
|
from langgraph.prebuilt import ToolNode
|
|
10
10
|
from langgraph.checkpoint.memory import MemorySaver
|
|
11
11
|
from langchain_mcp_adapters.client import MultiServerMCPClient
|
|
12
|
-
|
|
13
12
|
# Import your existing interfaces
|
|
14
13
|
from sonika_langchain_bot.langchain_class import FileProcessorInterface, IEmbeddings, ILanguageModel, Message, ResponseModel
|
|
15
14
|
|
|
@@ -151,15 +150,24 @@ class LangChainBot:
|
|
|
151
150
|
tools_description += f"## {tool.name}\n"
|
|
152
151
|
tools_description += f"**Description:** {tool.description}\n\n"
|
|
153
152
|
|
|
154
|
-
# Opción 1:
|
|
155
|
-
if hasattr(tool, 'args_schema') and tool.args_schema:
|
|
156
|
-
|
|
153
|
+
# Opción 1: args_schema es una clase Pydantic (HTTPTool)
|
|
154
|
+
if hasattr(tool, 'args_schema') and tool.args_schema and hasattr(tool.args_schema, '__fields__'):
|
|
155
|
+
tools_description += f"**Parameters:**\n"
|
|
156
|
+
for field_name, field_info in tool.args_schema.__fields__.items():
|
|
157
|
+
required = "**REQUIRED**" if field_info.is_required() else "*optional*"
|
|
158
|
+
tools_description += f"- `{field_name}` ({field_info.annotation.__name__}, {required}): {field_info.description}\n"
|
|
159
|
+
|
|
160
|
+
# Opción 2: args_schema es un dict (MCP Tools) ← NUEVO
|
|
161
|
+
elif hasattr(tool, 'args_schema') and isinstance(tool.args_schema, dict):
|
|
162
|
+
if 'properties' in tool.args_schema:
|
|
157
163
|
tools_description += f"**Parameters:**\n"
|
|
158
|
-
for
|
|
159
|
-
required = "**REQUIRED**" if
|
|
160
|
-
|
|
164
|
+
for param_name, param_info in tool.args_schema['properties'].items():
|
|
165
|
+
required = "**REQUIRED**" if param_name in tool.args_schema.get('required', []) else "*optional*"
|
|
166
|
+
param_desc = param_info.get('description', 'No description')
|
|
167
|
+
param_type = param_info.get('type', 'any')
|
|
168
|
+
tools_description += f"- `{param_name}` ({param_type}, {required}): {param_desc}\n"
|
|
161
169
|
|
|
162
|
-
# Opción
|
|
170
|
+
# Opción 3: Tool básico con _run (fallback)
|
|
163
171
|
elif hasattr(tool, '_run'):
|
|
164
172
|
tools_description += f"**Parameters:**\n"
|
|
165
173
|
import inspect
|
|
@@ -170,7 +178,7 @@ class LangChainBot:
|
|
|
170
178
|
required = "*optional*" if param.default != inspect.Parameter.empty else "**REQUIRED**"
|
|
171
179
|
default_info = f" (default: {param.default})" if param.default != inspect.Parameter.empty else ""
|
|
172
180
|
tools_description += f"- `{param_name}` ({param_type}, {required}){default_info}\n"
|
|
173
|
-
|
|
181
|
+
|
|
174
182
|
tools_description += "\n"
|
|
175
183
|
|
|
176
184
|
tools_description += ("## Usage Instructions\n"
|
|
@@ -179,7 +187,7 @@ class LangChainBot:
|
|
|
179
187
|
"- Do NOT call tools with empty arguments\n")
|
|
180
188
|
|
|
181
189
|
instructions += tools_description
|
|
182
|
-
|
|
190
|
+
|
|
183
191
|
return instructions
|
|
184
192
|
|
|
185
193
|
def _create_modern_workflow(self) -> StateGraph:
|
|
@@ -354,7 +362,10 @@ class LangChainBot:
|
|
|
354
362
|
}
|
|
355
363
|
|
|
356
364
|
# Execute the LangGraph workflow
|
|
357
|
-
result = self.graph.invoke(initial_state)
|
|
365
|
+
#result = self.graph.invoke(initial_state)
|
|
366
|
+
|
|
367
|
+
# Siempre usar ainvoke (funciona para ambos casos)
|
|
368
|
+
result = asyncio.run(self.graph.ainvoke(initial_state))
|
|
358
369
|
|
|
359
370
|
# Update internal conversation history
|
|
360
371
|
self.chat_history = result["messages"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sonika_langchain_bot-0.0.14 → sonika_langchain_bot-0.0.15}/src/sonika_langchain_bot/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|