eq-chatbot-core 4.2.0__tar.gz → 4.2.1__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 (70) hide show
  1. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/CHANGELOG.md +6 -0
  2. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/PKG-INFO +1 -1
  3. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/RELEASE_NOTES.md +6 -0
  4. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/anthropic_provider.py +3 -78
  5. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/anthropic_shared.py +84 -0
  6. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/langdock_provider.py +8 -3
  7. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/version.py +1 -1
  8. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/.gitignore +0 -0
  9. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/LICENSE +0 -0
  10. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/README.md +0 -0
  11. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/pyproject.toml +0 -0
  12. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/__init__.py +0 -0
  13. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/cli.py +0 -0
  14. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/data/__init__.py +0 -0
  15. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/data/config.toml.example +0 -0
  16. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/mcp/__init__.py +0 -0
  17. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/mcp/client.py +0 -0
  18. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/mcp/streamable_http.py +0 -0
  19. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/__init__.py +0 -0
  20. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/base.py +0 -0
  21. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/ionos_provider.py +0 -0
  22. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/litellm_provider.py +0 -0
  23. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/local_provider.py +0 -0
  24. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/mammouth_provider.py +0 -0
  25. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/melious_provider.py +0 -0
  26. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/openai_compatible.py +0 -0
  27. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/openai_provider.py +0 -0
  28. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/openrouter_provider.py +0 -0
  29. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/param_learning.py +0 -0
  30. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/privatemode_provider.py +0 -0
  31. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/stream_accumulator.py +0 -0
  32. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/providers/temperature_constraints.py +0 -0
  33. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/py.typed +0 -0
  34. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/rag/__init__.py +0 -0
  35. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/rag/chunker.py +0 -0
  36. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/rag/context_manager.py +0 -0
  37. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/rag/embedder.py +0 -0
  38. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/rag/retriever.py +0 -0
  39. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/__init__.py +0 -0
  40. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/abc.py +0 -0
  41. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/contracts.py +0 -0
  42. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/factory.py +0 -0
  43. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/mock.py +0 -0
  44. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/providers/__init__.py +0 -0
  45. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/providers/elevenlabs.py +0 -0
  46. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/providers/gemini_live.py +0 -0
  47. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/providers/openai.py +0 -0
  48. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/realtime/websocket_client.py +0 -0
  49. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/security/__init__.py +0 -0
  50. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/security/encryption.py +0 -0
  51. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/security/file_validator.py +0 -0
  52. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/security/injection.py +0 -0
  53. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/security/rate_limit.py +0 -0
  54. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/server/__init__.py +0 -0
  55. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/server/app.py +0 -0
  56. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/server/auth.py +0 -0
  57. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/server/lifecycle.py +0 -0
  58. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/server/models.py +0 -0
  59. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/server/streaming.py +0 -0
  60. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/services/__init__.py +0 -0
  61. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/services/capability_catalog.py +0 -0
  62. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/services/document_extractor.py +0 -0
  63. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/services/error_handler.py +0 -0
  64. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/services/knowledge_service.py +0 -0
  65. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/utils/__init__.py +0 -0
  66. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/utils/config.py +0 -0
  67. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/utils/image.py +0 -0
  68. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/utils/pdf.py +0 -0
  69. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/utils/secret_scrub.py +0 -0
  70. {eq_chatbot_core-4.2.0 → eq_chatbot_core-4.2.1}/src/eq_chatbot_core/utils/url_validation.py +0 -0
@@ -5,6 +5,12 @@ All notable changes to eq-chatbot-core will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.2.1] - 2026-10-12
9
+
10
+ ### Fixed
11
+
12
+ - LangDock's `anthropic` backend now converts a tool call history to the Messages API format, as `AnthropicProvider` always did: an assistant message with `tool_calls` becomes `tool_use` blocks, a `tool` message becomes a user message with a `tool_result` block. Before, the history was passed through unchanged, so every request after the model's first tool call was refused with HTTP 400 (`messages[n].content`: expected string or array, received null). A chat with a Claude model through LangDock failed as soon as the model used a tool. The conversion moved to `anthropic_shared.convert_messages`; `AnthropicProvider._convert_messages` keeps its name and delegates. Verified live 12.10.2026 against LangDock with claude-haiku-5-5.
13
+
8
14
  ## [4.2.0] - 2026-10-12
9
15
 
10
16
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: eq-chatbot-core
3
- Version: 4.2.0
3
+ Version: 4.2.1
4
4
  Summary: Core library for LLM chatbot integration with multi-provider support (OpenAI, Anthropic, LangDock, OpenRouter, Mammouth, LiteLLM, IONOS, Melious, Privatemode, Local)
5
5
  Project-URL: Homepage, https://www.ownerp.com
6
6
  Project-URL: Documentation, https://github.com/equitania/eq-chatbot-core
@@ -1,5 +1,11 @@
1
1
  # Release Notes
2
2
 
3
+ ## Version 4.2.1 (12.10.2026)
4
+
5
+ ### [FIX]
6
+
7
+ - **Claude über LangDock mit Werkzeugen.** Der LangDock-Weg zu Anthropic-Modellen gab den Gesprächsverlauf unverändert im OpenAI-Format weiter. Sobald das Modell ein Werkzeug benutzt hatte, lehnte LangDock jede weitere Anfrage mit HTTP 400 ab („expected string or array, received null“). Der Verlauf wird jetzt wie bei der direkten Anthropic-Anbindung umgewandelt: Werkzeugaufrufe werden zu `tool_use`-Blöcken, Werkzeugergebnisse zu `tool_result`-Blöcken. Live geprüft am 12.10.2026 mit claude-haiku-5-5 über LangDock.
8
+
3
9
  ## Version 4.2.0 (12.10.2026)
4
10
 
5
11
  ### [ADD]
@@ -12,6 +12,7 @@ from typing import Any
12
12
  from eq_chatbot_core.providers import param_learning
13
13
  from eq_chatbot_core.providers.anthropic_shared import (
14
14
  ANTHROPIC_LEARNABLE,
15
+ convert_messages,
15
16
  create_message,
16
17
  list_anthropic_models,
17
18
  open_message_stream,
@@ -186,84 +187,8 @@ class AnthropicProvider(BaseLLMProvider):
186
187
  return blocks, filtered_messages
187
188
 
188
189
  def _convert_messages(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]:
189
- """
190
- Convert OpenAI-style messages to Anthropic format.
191
-
192
- Key conversions:
193
- - assistant messages with tool_calls -> content with tool_use blocks
194
- - tool messages -> user messages with tool_result content blocks
195
- """
196
- converted = []
197
-
198
- for msg in messages:
199
- role = msg.get("role")
200
- content = msg.get("content", "")
201
-
202
- if role == "assistant" and msg.get("tool_calls"):
203
- # Convert assistant message with tool_calls to Anthropic format
204
- content_blocks = []
205
-
206
- # Add text content if present
207
- if content:
208
- content_blocks.append({"type": "text", "text": content})
209
-
210
- # Add tool_use blocks for each tool call
211
- for tool_call in msg.get("tool_calls", []):
212
- func = tool_call.get("function", {})
213
- arguments = func.get("arguments", "{}")
214
-
215
- # Parse arguments - could be string or dict
216
- if isinstance(arguments, str):
217
- try:
218
- parsed_args = json.loads(arguments)
219
- except json.JSONDecodeError:
220
- parsed_args = {"raw": arguments}
221
- else:
222
- parsed_args = arguments
223
-
224
- content_blocks.append(
225
- {
226
- "type": "tool_use",
227
- "id": tool_call.get("id", ""),
228
- "name": func.get("name", ""),
229
- "input": parsed_args,
230
- }
231
- )
232
-
233
- converted.append(
234
- {
235
- "role": "assistant",
236
- "content": content_blocks,
237
- }
238
- )
239
-
240
- elif role == "tool":
241
- # Convert tool message to user message with tool_result block
242
- tool_call_id = msg.get("tool_call_id", "")
243
-
244
- # Handle content that might be JSON or plain text
245
- result_content = content
246
- if isinstance(content, dict):
247
- result_content = json.dumps(content)
248
-
249
- converted.append(
250
- {
251
- "role": "user",
252
- "content": [
253
- {
254
- "type": "tool_result",
255
- "tool_use_id": tool_call_id,
256
- "content": result_content,
257
- }
258
- ],
259
- }
260
- )
261
-
262
- else:
263
- # Pass through user/assistant messages as-is
264
- converted.append(msg)
265
-
266
- return converted
190
+ """Convert OpenAI-style messages to Anthropic format (see ``anthropic_shared.convert_messages``)."""
191
+ return convert_messages(messages)
267
192
 
268
193
  def _convert_tools_to_anthropic(self, tools: list[dict[str, Any]] | None) -> list[dict[str, Any]] | None:
269
194
  """Convert OpenAI-style tools to Anthropic format."""
@@ -9,6 +9,7 @@ learnable: ``reasoning_effort`` is not sent on these paths.
9
9
 
10
10
  from __future__ import annotations
11
11
 
12
+ import json
12
13
  import logging
13
14
  from contextlib import ExitStack
14
15
  from typing import Any
@@ -18,6 +19,89 @@ from eq_chatbot_core.providers import param_learning
18
19
  ANTHROPIC_LEARNABLE: tuple[str, ...] = ("temperature",)
19
20
 
20
21
 
22
+ def convert_messages(messages: list[dict[str, Any]]) -> list[dict[str, Any]]:
23
+ """Convert OpenAI-style messages to the Messages API format.
24
+
25
+ - assistant messages with tool_calls -> content with tool_use blocks
26
+ - tool messages -> user messages with tool_result content blocks
27
+
28
+ Callers keep one OpenAI-shaped history for every provider; this is where it
29
+ becomes Anthropic's. Without it a second turn after a tool call is refused
30
+ (``content`` is null, ``role`` "tool" does not exist in this API).
31
+ """
32
+ converted = []
33
+
34
+ for msg in messages:
35
+ role = msg.get("role")
36
+ content = msg.get("content", "")
37
+
38
+ if role == "assistant" and msg.get("tool_calls"):
39
+ # Convert assistant message with tool_calls to Anthropic format
40
+ content_blocks = []
41
+
42
+ # Add text content if present
43
+ if content:
44
+ content_blocks.append({"type": "text", "text": content})
45
+
46
+ # Add tool_use blocks for each tool call
47
+ for tool_call in msg.get("tool_calls", []):
48
+ func = tool_call.get("function", {})
49
+ arguments = func.get("arguments", "{}")
50
+
51
+ # Parse arguments - could be string or dict
52
+ if isinstance(arguments, str):
53
+ try:
54
+ parsed_args = json.loads(arguments)
55
+ except json.JSONDecodeError:
56
+ parsed_args = {"raw": arguments}
57
+ else:
58
+ parsed_args = arguments
59
+
60
+ content_blocks.append(
61
+ {
62
+ "type": "tool_use",
63
+ "id": tool_call.get("id", ""),
64
+ "name": func.get("name", ""),
65
+ "input": parsed_args,
66
+ }
67
+ )
68
+
69
+ converted.append(
70
+ {
71
+ "role": "assistant",
72
+ "content": content_blocks,
73
+ }
74
+ )
75
+
76
+ elif role == "tool":
77
+ # Convert tool message to user message with tool_result block
78
+ tool_call_id = msg.get("tool_call_id", "")
79
+
80
+ # Handle content that might be JSON or plain text
81
+ result_content = content
82
+ if isinstance(content, dict):
83
+ result_content = json.dumps(content)
84
+
85
+ converted.append(
86
+ {
87
+ "role": "user",
88
+ "content": [
89
+ {
90
+ "type": "tool_result",
91
+ "tool_use_id": tool_call_id,
92
+ "content": result_content,
93
+ }
94
+ ],
95
+ }
96
+ )
97
+
98
+ else:
99
+ # Pass through user/assistant messages as-is
100
+ converted.append(msg)
101
+
102
+ return converted
103
+
104
+
21
105
  def create_message(client: Any, params: dict[str, Any], *, base_url: str, provider: str, logger: logging.Logger) -> Any:
22
106
  """``client.messages.create(**params)``, retried once without a rejected temperature."""
23
107
  return param_learning.call_with_learning(
@@ -20,7 +20,12 @@ from typing import Any
20
20
  import httpx2
21
21
 
22
22
  from eq_chatbot_core.providers import param_learning
23
- from eq_chatbot_core.providers.anthropic_shared import create_message, list_anthropic_models, open_message_stream
23
+ from eq_chatbot_core.providers.anthropic_shared import (
24
+ convert_messages,
25
+ create_message,
26
+ list_anthropic_models,
27
+ open_message_stream,
28
+ )
24
29
  from eq_chatbot_core.providers.base import (
25
30
  AuthenticationError,
26
31
  BaseLLMProvider,
@@ -630,7 +635,7 @@ class LangDockProvider(BaseLLMProvider):
630
635
 
631
636
  params: dict[str, Any] = {
632
637
  "model": model,
633
- "messages": filtered_messages,
638
+ "messages": convert_messages(filtered_messages),
634
639
  "max_tokens": max_tokens or 4096,
635
640
  }
636
641
 
@@ -1029,7 +1034,7 @@ class LangDockProvider(BaseLLMProvider):
1029
1034
 
1030
1035
  params: dict[str, Any] = {
1031
1036
  "model": model,
1032
- "messages": filtered_messages,
1037
+ "messages": convert_messages(filtered_messages),
1033
1038
  "max_tokens": max_tokens or 4096,
1034
1039
  }
1035
1040
 
@@ -1,3 +1,3 @@
1
1
  """Version information for eq-chatbot-core."""
2
2
 
3
- __version__ = "4.2.0"
3
+ __version__ = "4.2.1"
File without changes