ragbits-chat 0.0.8.dev23005__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 (68) hide show
  1. ragbits_chat-0.0.8.dev23005/.gitignore +116 -0
  2. ragbits_chat-0.0.8.dev23005/CHANGELOG.md +279 -0
  3. ragbits_chat-0.0.8.dev23005/PKG-INFO +44 -0
  4. ragbits_chat-0.0.8.dev23005/README.md +10 -0
  5. ragbits_chat-0.0.8.dev23005/pyproject.toml +67 -0
  6. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/__init__.py +87 -0
  7. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/_utils.py +40 -0
  8. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/adapters/__init__.py +56 -0
  9. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/adapters/builtin.py +375 -0
  10. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/adapters/pipeline.py +94 -0
  11. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/adapters/protocol.py +185 -0
  12. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/api.py +778 -0
  13. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/auth/__init__.py +11 -0
  14. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/auth/backends.py +177 -0
  15. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/auth/base.py +87 -0
  16. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/auth/types.py +73 -0
  17. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/cli.py +52 -0
  18. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/client/__init__.py +12 -0
  19. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/client/client.py +132 -0
  20. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/client/conversation.py +234 -0
  21. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/client/exceptions.py +11 -0
  22. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/history/__init__.py +0 -0
  23. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/history/compressors/__init__.py +4 -0
  24. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/history/compressors/base.py +31 -0
  25. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/history/compressors/llm.py +86 -0
  26. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/interface/__init__.py +3 -0
  27. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/interface/_interface.py +402 -0
  28. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/interface/forms.py +119 -0
  29. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/interface/summary.py +82 -0
  30. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/interface/types.py +879 -0
  31. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/interface/ui_customization.py +56 -0
  32. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/metrics.py +219 -0
  33. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/persistence/__init__.py +3 -0
  34. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/persistence/base.py +29 -0
  35. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/persistence/file.py +52 -0
  36. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/persistence/sql.py +297 -0
  37. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/providers/__init__.py +9 -0
  38. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/providers/model_provider.py +260 -0
  39. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/py.typed +0 -0
  40. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/AuthGuard-B326tmZN.js +1 -0
  41. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/ChatHistory-Cp_DhrUx.js +2 -0
  42. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/ChatOptionsForm-CNjzbIqN.js +1 -0
  43. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/FeedbackForm-CmRSbYPS.js +1 -0
  44. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/Login-Djq6QJ18.js +1 -0
  45. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/LogoutButton-Cn2L63Hk.js +1 -0
  46. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/ShareButton-lYj0v67r.js +1 -0
  47. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/UsageButton-B-N1J-sZ.js +1 -0
  48. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/authStore-DATNN-ps.js +1 -0
  49. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/chunk-IGSAU2ZA-CsJAveMU.js +1 -0
  50. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/chunk-SSA7SXE4-BJI2Gxdq.js +1 -0
  51. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/index-B3hlerKe.js +131 -0
  52. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/index-B7bSwAmw.js +32 -0
  53. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/index-C_JcEI3R.js +1 -0
  54. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/index-CmsICuOz.css +1 -0
  55. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/index-v15bx9Do.js +4 -0
  56. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/useMenuTriggerState-CTz3KfPq.js +1 -0
  57. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/assets/useSelectableItem-DK6eABKK.js +1 -0
  58. ragbits_chat-0.0.8.dev23005/src/ragbits/chat/ui-build/index.html +13 -0
  59. ragbits_chat-0.0.8.dev23005/tests/unit/adapters/__init__.py +0 -0
  60. ragbits_chat-0.0.8.dev23005/tests/unit/adapters/test_adapters.py +742 -0
  61. ragbits_chat-0.0.8.dev23005/tests/unit/auth/test_list_auth_backend.py +514 -0
  62. ragbits_chat-0.0.8.dev23005/tests/unit/history/test_llm_compressor.py +111 -0
  63. ragbits_chat-0.0.8.dev23005/tests/unit/persistence/test_sql.py +175 -0
  64. ragbits_chat-0.0.8.dev23005/tests/unit/test_api.py +363 -0
  65. ragbits_chat-0.0.8.dev23005/tests/unit/test_chat_client.py +183 -0
  66. ragbits_chat-0.0.8.dev23005/tests/unit/test_conversation.py +203 -0
  67. ragbits_chat-0.0.8.dev23005/tests/unit/test_error_response.py +103 -0
  68. ragbits_chat-0.0.8.dev23005/tests/unit/test_generic_custom_response.py +389 -0
@@ -0,0 +1,116 @@
1
+ # Directories
2
+ .vscode/
3
+ .idea/
4
+ .neptune/
5
+ .pytest_cache/
6
+ .mypy_cache/
7
+ venv/
8
+ .venv/
9
+ __pycache__/
10
+ **.egg-info/
11
+ .deepeval/
12
+
13
+ # Local cursor rules
14
+ .cursor/rules/local/
15
+
16
+ # Byte-compiled / optimized / DLL files
17
+ __pycache__/
18
+ *.py[cod]
19
+ *$py.class
20
+
21
+ # C extensions
22
+ *.so
23
+
24
+ # Distribution / packaging
25
+ .Python
26
+ env/
27
+ build/
28
+ develop-eggs/
29
+ dist/
30
+ downloads/
31
+ eggs/
32
+ .eggs/
33
+ lib/
34
+ lib64/
35
+ parts/
36
+ sdist/
37
+ var/
38
+ *.egg-info/
39
+ .installed.cfg
40
+ *.egg
41
+
42
+ # Sphinx documentation
43
+ docs/_build/
44
+ public/
45
+ # autogenerated package license table
46
+ docs/licenses_table.rst
47
+
48
+ # license dump file
49
+ licenses.txt
50
+
51
+ # File formats
52
+ *.onnx
53
+ *.pyc
54
+ *.pt
55
+ *.pth
56
+ *.pkl
57
+ *.mar
58
+ *.torchscript
59
+ **/.ipynb_checkpoints
60
+ **/dist/
61
+ **/checkpoints/
62
+ **/outputs/
63
+ **/multirun/
64
+
65
+ # Other env files
66
+ .python-version
67
+ pyvenv.cfg
68
+ pip-selfcheck.json
69
+
70
+ # Unit test / coverage reports
71
+ htmlcov/
72
+ .tox/
73
+ .coverage
74
+ .coverage.*
75
+ .cache
76
+ nosetests.xml
77
+ coverage.xml
78
+ *,cover
79
+ .hypothesis/
80
+
81
+ # dotenv
82
+ .env
83
+
84
+ # coverage and pytest reports
85
+ coverage.xml
86
+ report.xml
87
+
88
+ # CMake
89
+ cmake-build-*/
90
+
91
+ # Terraform
92
+ **/.terraform.lock.hcl
93
+ **/.terraform
94
+
95
+ # mkdocs generated files
96
+ site/
97
+
98
+ # build artifacts
99
+ dist/
100
+
101
+ # examples
102
+ chroma/
103
+ qdrant/
104
+
105
+ .aider*
106
+
107
+ .DS_Store
108
+ node_modules/
109
+
110
+ lazygit
111
+
112
+ lazygit.tar.gz
113
+
114
+ # chat conversation logs
115
+ duet_conversation.log
116
+ worktrees/
@@ -0,0 +1,279 @@
1
+ # CHANGELOG
2
+
3
+ ## Unreleased
4
+
5
+ - Feat: add response adapter system for transforming chat response streams (`ResponseAdapter` protocol, `AdapterPipeline`, `ChatResponseAdapter`, `ToolResultTextAdapter`, `FilterAdapter`, and more)
6
+ - Refactor ragbits-client types to remove excessive use of any (#881)
7
+ - Split params into path params, query params in API client (#871)
8
+ - Fix bug causing conversation not to be selected when navigating to it from url(#872)
9
+ - CI/CD for nightly npm builds, update ragbits-api-client-react deps to install latest version of the @ragbits/api-client (#873)
10
+ - CI/CD for nightlty builds improvements (#874)
11
+ - Add automatic topic extraction to be used as conversation title with ability to edit in the client side (#840)
12
+ - Add todo list component to the UI, add support for todo events in API (#827)
13
+ - Add support for confirmation requests in chat (#853)
14
+ - customizable HeroUI theme (#841)
15
+ - Add error response type to the chat interface with ability to display error messages to the user (#878)
16
+
17
+ ### Added
18
+
19
+ - Add automatic topic extraction to be used as conversation title with ability to edit in the client side (#840)
20
+ - Add todo list component to the UI, add support for todo events in API (#827)
21
+ - Add custom response type to the chat interface with full type safety and validation (#849)
22
+ - New class-based response system: `TextResponse`, `ReferenceResponse`, `StateUpdateResponse`, etc.
23
+ - Support for custom response types by extending `ResponseContent` and `ChatResponse`
24
+ - Full Pydantic validation for all response content
25
+ - customizable HeroUI theme (#841)
26
+
27
+ ### Deprecated
28
+
29
+ - **BACKWARD COMPATIBILITY MAINTAINED**: The following APIs are deprecated and will be removed in version 2.0.0:
30
+ - `ChatResponseType` enum - Use `isinstance()` checks with specific response classes instead
31
+ - `ChatResponse.type` property - Use `isinstance()` checks instead
32
+ - `ChatResponse.as_text()` method - Use `isinstance(response, TextResponse)` instead
33
+ - `ChatResponse.as_reference()` method - Use `isinstance(response, ReferenceResponse)` instead
34
+ - `ChatResponse.as_state_update()` method - Use `isinstance(response, StateUpdateResponse)` instead
35
+ - `ChatResponse.as_conversation_id()` method - Use `isinstance(response, ConversationIdResponse)` instead
36
+
37
+ All deprecated APIs emit `DeprecationWarning` when used and remain fully functional for backward compatibility.
38
+
39
+ **Migration Example:**
40
+
41
+ ```python
42
+ # Old (deprecated but still works):
43
+ if response.type == ChatResponseType.TEXT:
44
+ print(response.as_text())
45
+
46
+ # New (recommended):
47
+ if isinstance(response, TextResponse):
48
+ print(response.content.text)
49
+ ```
50
+
51
+ ## 1.3.0 (2025-09-11)
52
+
53
+ ### Changed
54
+
55
+ - ragbits-core updated to version v1.3.0
56
+
57
+ - fix: replace authenticated_user state tracking with direct user field in ChatContext
58
+ - Refactor chat handlers in the UI to use registry (#805)
59
+ - Add auth token storage and automatic logout on 401 (#802)
60
+ - Improve user settings storage when history is disabled (#799)
61
+ - Remove redundant test for `/api/config` endpoint (#795)
62
+ - Fix bug causing infinite initialization screen (#793)
63
+ - Fix bug that caused messages to be sent when changing chat settings; simplify and harden history logic (#791)
64
+ - Add `clear_message` event type allowing to reset whole message (#789)
65
+ - Add usage component to UI with backend support (#786)
66
+ - Add authentication handling in the UI (#763)
67
+ - Add backend authentication (#761)
68
+
69
+ - Autogenerate typescript types based on backend typing (#727)
70
+ - Add ability to customize favicon and page title (#766)
71
+
72
+ - Autogenerate typescript types based on backend typing (#727)
73
+ - Add ability to customize favicon and page title (#766)
74
+
75
+ ## 1.2.2 (2025-08-08)
76
+
77
+ ### Changed
78
+
79
+ - ragbits-core updated to version v1.2.2
80
+
81
+ ## 1.2.1 (2025-08-04)
82
+
83
+ ### Changed
84
+
85
+ - ragbits-core updated to version v1.2.1
86
+ - Fix routing error causing chat to not be displayed with disabled history (#764)
87
+
88
+ ## 1.2.0 (2025-08-01)
89
+
90
+ ### Changed
91
+
92
+ - ragbits-core updated to version v1.2.0
93
+ - Update TailwindCSS, React, Vite, tailwind config (#742)
94
+ - Add images support in chat message, images gallery (#731)
95
+ - Add persistent user settings (#719)
96
+ - Send chat options under `user_settings` key (#721)
97
+ - Add feedback indicator to messages, allow `extensions` in chat messages (#722)
98
+ - Add unit tests for UI's core components (#717)
99
+ - Add share functionality with informative modal (#726)
100
+ - Add persisent chat history to the default UI using IndexedDB (#732)
101
+ - Redesign history UI, allowed enabling of client side history using config (#744)
102
+ - Allow parallel conversations in the UI (#749)
103
+ - Add missing typography plugin for TailwindCSS (#750)
104
+ - Add client routing with ability for plugins to define custom routes (#754)
105
+
106
+ ## 1.1.0 (2025-07-09)
107
+
108
+ ### Changed
109
+
110
+ - ragbits-core updated to version v1.1.0
111
+
112
+ - Add configurable user setting in Ragbits UI (#692)
113
+ - Live updates support for Python api client(#683)
114
+ - Synchronous and asynchronous Python api client (#647)
115
+ - Live updates support markdown (#684)
116
+ - Added custom styling for multiline and inline-code (#668)
117
+ - Changed toggling darkmode for tailwind class selector (#668)
118
+ - Loading indicator, delayed message buttons, integrated abort controller (#641)
119
+ - Added Eslint, Prettier & CI/CD for Ragbits API Clients (#604)
120
+ - Excluded API connection logic to 2 modules: ragbits-api-client and ragbits-api-client-react which implements hooks for ragbits-api-client (#582)
121
+ - CI/CD changes for new directory structure (#582)
122
+ - Move form definitions to JSONSchema (#616)
123
+ - Allow UI cutomization using config endpoint (#643)
124
+ - Add support for live updates and followup messages (#654)
125
+ - Fix invalid context structure in requests from FE (#663)
126
+ - Arrow Up and Arrow Down now cycle through sent messages in a terminal-like style (#667)
127
+ - Fix followup messages not sending (#680)
128
+ - Improve typing of TypeScript libraries (#681)
129
+ - New metrics in for RagbitsAPI (#615)
130
+ - Add debug panel with debug_mode field in config (#689)
131
+ - Restore relative URL handling for UI build (#699)
132
+ - Add integration tests for UI (#697)
133
+ - Use external store instead of context for history (#706)
134
+
135
+ ## 1.0.0 (2025-06-04)
136
+
137
+ ### Changed
138
+
139
+ - ragbits-core updated to version v1.0.0
140
+
141
+ ## 0.20.1 (2025-06-04)
142
+
143
+ ### Changed
144
+
145
+ - ragbits-core updated to version v0.20.1
146
+
147
+ ## 0.20.0 (2025-06-03)
148
+
149
+ ### Changed
150
+
151
+ - ragbits-core updated to version v0.20.0
152
+
153
+ - remove HeroUI Pro components (#557)
154
+ - refactor UI components to allow modifications (#579)
155
+ - Add setup method to ChatInterface (#586)
156
+ - Rebuild UI with new dependencies (#589)
157
+
158
+ ## 0.19.1 (2025-05-27)
159
+
160
+ ### Changed
161
+
162
+ - ragbits-core updated to version v0.19.1
163
+
164
+ - fix: dont import all persistence strategies in base file (#584)
165
+
166
+ ## 0.19.0 (2025-05-27)
167
+
168
+ ### Changed
169
+
170
+ - ragbits-core updated to version v0.19.0
171
+
172
+ - Add persistance component to save chat interactions from ragbits-chat (#556)
173
+ - Add conversation_id parameter to chat interface context (#556)
174
+ - Add uvicorn to dependencies (#578)
175
+ - Remove HeroUI Pro components (#557)
176
+
177
+ ## 0.18.0 (2025-05-22)
178
+
179
+ ### Changed
180
+
181
+ - ragbits-core updated to version v0.18.0
182
+
183
+ - updated ui build (#553)
184
+ - api integration improvements + history context changes (#552)
185
+ - feedback form integration (#540)
186
+
187
+ ## 0.17.1 (2025-05-09)
188
+
189
+ ### Changed
190
+
191
+ - ragbits-core updated to version v0.17.1
192
+
193
+ ## 0.17.0 (2025-05-06)
194
+
195
+ ### Changed
196
+
197
+ - ragbits-core updated to version v0.17.0
198
+
199
+ ## 0.16.0 (2025-04-29)
200
+
201
+ ### Changed
202
+
203
+ - ragbits-core updated to version v0.16.0
204
+
205
+ ## 0.15.0 (2025-04-28)
206
+
207
+ ### Changed
208
+
209
+ - ragbits-core updated to version v0.15.0
210
+
211
+ ### Added
212
+
213
+ - Added support for state updates in chat interfaces with automatic signature generation (#537).
214
+
215
+ ## 0.14.0 (2025-04-22)
216
+
217
+ ### Changed
218
+
219
+ - ragbits-core updated to version v0.14.0
220
+
221
+ ## 0.13.0 (2025-04-02)
222
+
223
+ ### Changed
224
+
225
+ - ragbits-core updated to version v0.13.0
226
+
227
+ ## 0.12.0 (2025-03-25)
228
+
229
+ ### Changed
230
+
231
+ - ragbits-core updated to version v0.12.0
232
+
233
+ ## 0.11.0 (2025-03-25)
234
+
235
+ ### Changed
236
+
237
+ - ragbits-core updated to version v0.11.0
238
+
239
+ ## 0.10.2 (2025-03-21)
240
+
241
+ ### Changed
242
+
243
+ - ragbits-core updated to version v0.10.2
244
+
245
+ ## 0.10.1 (2025-03-19)
246
+
247
+ ### Changed
248
+
249
+ - ragbits-core updated to version v0.10.1
250
+
251
+ ## 0.10.0 (2025-03-17)
252
+
253
+ ### Changed
254
+
255
+ - ragbits-core updated to version v0.10.0
256
+
257
+ ## 0.9.0 (2025-02-25)
258
+
259
+ ### Changed
260
+
261
+ - ragbits-core updated to version v0.9.0
262
+ - Add support to persisting history of conversations using sqlalchemy (#354).
263
+
264
+ ## 0.8.0 (2025-01-29)
265
+
266
+ ### Changed
267
+
268
+ - ragbits-core updated to version v0.8.0
269
+
270
+ ## 0.7.0 (2025-01-21)
271
+
272
+ ### Changed
273
+
274
+ - ragbits-core updated to version v0.7.0
275
+
276
+ ### Added
277
+
278
+ - Initial release of the package (#271).
279
+ - Added last message recontextualization (#271).
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: ragbits-chat
3
+ Version: 0.0.8.dev23005
4
+ Summary: Building blocks for rapid development of GenAI applications
5
+ Project-URL: Homepage, https://github.com/deepsense-ai/ragbits
6
+ Project-URL: Bug Reports, https://github.com/deepsense-ai/ragbits/issues
7
+ Project-URL: Documentation, https://ragbits.deepsense.ai/
8
+ Project-URL: Source, https://github.com/deepsense-ai/ragbits
9
+ Author-email: "deepsense.ai" <ragbits@deepsense.ai>
10
+ License-Expression: MIT
11
+ Keywords: GenAI,Generative AI,LLMs,Large Language Models,Prompt Management,RAG,Retrieval Augmented Generation
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: bcrypt>=4.2.0
26
+ Requires-Dist: fastapi<1.0.0,>=0.115.0
27
+ Requires-Dist: httpx<1.0.0,>=0.28.1
28
+ Requires-Dist: python-jose[cryptography]>=3.5.0
29
+ Requires-Dist: ragbits-core==0.0.8.dev23005
30
+ Requires-Dist: uvicorn<1.0.0,>=0.31.0
31
+ Provides-Extra: sql
32
+ Requires-Dist: sqlalchemy<3.0.0,>=2.0.39; extra == 'sql'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # Ragbits Chat
36
+
37
+ ragbits-chat is a Python package that provides tools for building conversational AI applications.
38
+
39
+ The package includes:
40
+ - Framework for building chat experiences
41
+ - History management for conversation tracking
42
+ - UI components for building chat interfaces
43
+
44
+ For detailed information, please refer to the [API documentation](https://ragbits.deepsense.ai/how-to/chatbots/api/).
@@ -0,0 +1,10 @@
1
+ # Ragbits Chat
2
+
3
+ ragbits-chat is a Python package that provides tools for building conversational AI applications.
4
+
5
+ The package includes:
6
+ - Framework for building chat experiences
7
+ - History management for conversation tracking
8
+ - UI components for building chat interfaces
9
+
10
+ For detailed information, please refer to the [API documentation](https://ragbits.deepsense.ai/how-to/chatbots/api/).
@@ -0,0 +1,67 @@
1
+ [project]
2
+ name = "ragbits-chat"
3
+ version = "0.0.8.dev23005"
4
+ description = "Building blocks for rapid development of GenAI applications"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "MIT"
8
+ authors = [
9
+ { name = "deepsense.ai", email = "ragbits@deepsense.ai"}
10
+ ]
11
+ keywords = [
12
+ "Retrieval Augmented Generation",
13
+ "RAG",
14
+ "Large Language Models",
15
+ "LLMs",
16
+ "Generative AI",
17
+ "GenAI",
18
+ "Prompt Management"
19
+ ]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Environment :: Console",
23
+ "Intended Audience :: Science/Research",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Natural Language :: English",
26
+ "Operating System :: OS Independent",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
31
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
32
+ "Topic :: Software Development :: Libraries :: Python Modules",
33
+ ]
34
+ dependencies = ["fastapi>=0.115.0,<1.0.0", "uvicorn>=0.31.0,<1.0.0", "httpx>=0.28.1,<1.0.0", "bcrypt>=4.2.0", "python-jose[cryptography]>=3.5.0", "ragbits-core==0.0.8.dev23005"]
35
+
36
+ [project.urls]
37
+ "Homepage" = "https://github.com/deepsense-ai/ragbits"
38
+ "Bug Reports" = "https://github.com/deepsense-ai/ragbits/issues"
39
+ "Documentation" = "https://ragbits.deepsense.ai/"
40
+ "Source" = "https://github.com/deepsense-ai/ragbits"
41
+
42
+ [project.optional-dependencies]
43
+ sql = [
44
+ "sqlalchemy>=2.0.39,<3.0.0",
45
+ ]
46
+
47
+ [tool.uv]
48
+ dev-dependencies = [
49
+ "pre-commit~=3.8.0",
50
+ "pytest~=8.3.3",
51
+ "pytest-cov~=5.0.0",
52
+ "pytest-asyncio~=0.24.0",
53
+ "pip-licenses>=4.0.0,<5.0.0"
54
+ ]
55
+
56
+ [build-system]
57
+ requires = ["hatchling"]
58
+ build-backend = "hatchling.build"
59
+
60
+ [tool.hatch.metadata]
61
+ allow-direct-references = true
62
+
63
+ [tool.hatch.build.targets.wheel]
64
+ packages = ["src/ragbits"]
65
+
66
+ [tool.pytest.ini_options]
67
+ asyncio_mode = "auto"
@@ -0,0 +1,87 @@
1
+ from ragbits.chat.auth import (
2
+ AuthenticationBackend,
3
+ AuthenticationResponse,
4
+ ListAuthenticationBackend,
5
+ User,
6
+ UserCredentials,
7
+ )
8
+ from ragbits.chat.client import (
9
+ RagbitsChatClient,
10
+ RagbitsConversation,
11
+ SyncRagbitsChatClient,
12
+ SyncRagbitsConversation,
13
+ )
14
+ from ragbits.chat.interface.types import (
15
+ ChatResponse,
16
+ ChatResponseType,
17
+ ChatResponseUnion,
18
+ ClearMessageContent,
19
+ ClearMessageResponse,
20
+ ConversationIdContent,
21
+ ConversationIdResponse,
22
+ ConversationSummaryContent,
23
+ ConversationSummaryResponse,
24
+ ErrorContent,
25
+ ErrorResponse,
26
+ FollowupMessagesContent,
27
+ FollowupMessagesResponse,
28
+ ImageResponse,
29
+ LiveUpdateResponse,
30
+ Message,
31
+ MessageIdContent,
32
+ MessageIdResponse,
33
+ MessageRole,
34
+ Reference,
35
+ ReferenceResponse,
36
+ ResponseContent,
37
+ StateUpdate,
38
+ StateUpdateResponse,
39
+ TextContent,
40
+ TextResponse,
41
+ TodoItemContent,
42
+ TodoItemResponse,
43
+ UsageContent,
44
+ UsageResponse,
45
+ )
46
+
47
+ __all__ = [
48
+ "AuthenticationBackend",
49
+ "AuthenticationResponse",
50
+ "ChatResponse",
51
+ "ChatResponseType",
52
+ "ChatResponseUnion",
53
+ "ClearMessageContent",
54
+ "ClearMessageResponse",
55
+ "ConversationIdContent",
56
+ "ConversationIdResponse",
57
+ "ConversationSummaryContent",
58
+ "ConversationSummaryResponse",
59
+ "ErrorContent",
60
+ "ErrorResponse",
61
+ "FollowupMessagesContent",
62
+ "FollowupMessagesResponse",
63
+ "ImageResponse",
64
+ "ListAuthenticationBackend",
65
+ "LiveUpdateResponse",
66
+ "Message",
67
+ "MessageIdContent",
68
+ "MessageIdResponse",
69
+ "MessageRole",
70
+ "RagbitsChatClient",
71
+ "RagbitsConversation",
72
+ "Reference",
73
+ "ReferenceResponse",
74
+ "ResponseContent",
75
+ "StateUpdate",
76
+ "StateUpdateResponse",
77
+ "SyncRagbitsChatClient",
78
+ "SyncRagbitsConversation",
79
+ "TextContent",
80
+ "TextResponse",
81
+ "TodoItemContent",
82
+ "TodoItemResponse",
83
+ "UsageContent",
84
+ "UsageResponse",
85
+ "User",
86
+ "UserCredentials",
87
+ ]
@@ -0,0 +1,40 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import logging
5
+
6
+ from pydantic import TypeAdapter
7
+
8
+ from .interface.types import ChatResponse, ChatResponseUnion
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+
13
+ def build_api_url(base_url: str, path: str) -> str:
14
+ """Join *base_url* and *path* preserving exactly one slash."""
15
+ base = base_url.rstrip("/")
16
+ if not path.startswith("/"):
17
+ path = f"/{path}"
18
+ return f"{base}{path}"
19
+
20
+
21
+ PREFIX = "data: "
22
+
23
+
24
+ def parse_sse_line(line: str) -> ChatResponse | None:
25
+ r"""Parse a single *Server-Sent-Event* line coming from RagbitsAPI.
26
+
27
+ Expected format: ``data: {....json....}\n``
28
+ Returns a *ChatResponse* instance or ``None`` if the line is not a
29
+ data line. Parsing/validation errors are logged (and ``None`` is returned).
30
+ """
31
+ if not line.startswith(PREFIX):
32
+ return None
33
+ try:
34
+ json_payload = line[len(PREFIX) :].strip()
35
+ data = json.loads(json_payload)
36
+ adapter: TypeAdapter[ChatResponseUnion] = TypeAdapter(ChatResponseUnion)
37
+ return adapter.validate_python(data)
38
+ except Exception as exc:
39
+ logger.error("Failed to parse SSE line: %s", exc, exc_info=True)
40
+ return None
@@ -0,0 +1,56 @@
1
+ """Response adapters for transforming chat response streams.
2
+
3
+ This module provides a composable adapter system for transforming chat responses
4
+ through a pipeline of adapters, each handling a specific concern.
5
+
6
+ Example:
7
+ >>> from ragbits.chat.adapters import (
8
+ ... AdapterPipeline,
9
+ ... ChatResponseAdapter,
10
+ ... FilterAdapter,
11
+ ... ToolResultTextAdapter,
12
+ ... )
13
+ >>>
14
+ >>> async def render_products(tool_call):
15
+ ... return f"Found {len(tool_call.result)} products"
16
+ >>>
17
+ >>> pipeline = AdapterPipeline([
18
+ ... ChatResponseAdapter(),
19
+ ... FilterAdapter(exclude_types=(SomeUICommand,)),
20
+ ... ToolResultTextAdapter(
21
+ ... renderers={"show_products": render_products},
22
+ ... pass_through=True,
23
+ ... ),
24
+ ... ])
25
+ >>>
26
+ >>> async for chunk in pipeline.process(chat_stream, context):
27
+ ... print(chunk)
28
+ """
29
+
30
+ from ragbits.chat.adapters.builtin import (
31
+ ChatResponseAdapter,
32
+ FilterAdapter,
33
+ TextAccumulatorAdapter,
34
+ ToolCallAccumulatorAdapter,
35
+ ToolResultTextAdapter,
36
+ UsageAggregatorAdapter,
37
+ )
38
+ from ragbits.chat.adapters.pipeline import AdapterPipeline
39
+ from ragbits.chat.adapters.protocol import (
40
+ AdapterContext,
41
+ BaseAdapter,
42
+ ResponseAdapter,
43
+ )
44
+
45
+ __all__ = [
46
+ "AdapterContext",
47
+ "AdapterPipeline",
48
+ "BaseAdapter",
49
+ "ChatResponseAdapter",
50
+ "FilterAdapter",
51
+ "ResponseAdapter",
52
+ "TextAccumulatorAdapter",
53
+ "ToolCallAccumulatorAdapter",
54
+ "ToolResultTextAdapter",
55
+ "UsageAggregatorAdapter",
56
+ ]