appkit-assistant 0.7.3__py3-none-any.whl → 0.7.4__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.
@@ -0,0 +1,330 @@
1
+ Metadata-Version: 2.4
2
+ Name: appkit-assistant
3
+ Version: 0.7.4
4
+ Summary: Add your description here
5
+ Author: Jens Rehpöhler
6
+ Requires-Python: >=3.13
7
+ Requires-Dist: appkit-commons
8
+ Requires-Dist: openai>=2.3.0
9
+ Description-Content-Type: text/markdown
10
+
11
+ # appkit-assistant
12
+
13
+ [![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/)
14
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
15
+
16
+ **AI assistant component for Reflex applications with MCP server integration.**
17
+
18
+ appkit-assistant provides a complete conversational AI interface built on Reflex, featuring OpenAI and Perplexity integrations, Model Context Protocol (MCP) server management, and secure credential handling. It includes both backend processing services and ready-to-use UI components for building AI-powered applications.
19
+
20
+ ![Assistant](./docs/assistant.png)
21
+
22
+ ---
23
+
24
+ ## ✨ Features
25
+
26
+ - **Multi-Model Support** - OpenAI Chat Completions, OpenAI Responses API, Perplexity, and fallback Lorem Ipsum processor
27
+ - **MCP Server Integration** - Manage and connect to Model Context Protocol servers as tools
28
+ - **Secure Credential Management** - Encrypted storage and handling of API keys and server credentials
29
+ - **Reflex UI Components** - Pre-built assistant interface with composer, thread management, and message display
30
+ - **Streaming Responses** - Real-time streaming of AI responses with chunked content
31
+ - **Thread Management** - Persistent conversation threads with state management
32
+
33
+ ---
34
+
35
+ ## 🚀 Installation
36
+
37
+ ### As Part of AppKit Workspace
38
+
39
+ If you're using the full AppKit workspace:
40
+
41
+ ```bash
42
+ git clone https://github.com/jenreh/appkit.git
43
+ cd appkit
44
+ uv sync
45
+ ```
46
+
47
+ ### Standalone Installation
48
+
49
+ Install from PyPI:
50
+
51
+ ```bash
52
+ pip install appkit-assistant
53
+ ```
54
+
55
+ Or with uv:
56
+
57
+ ```bash
58
+ uv add appkit-assistant
59
+ ```
60
+
61
+ ### Dependencies
62
+
63
+ - `appkit-commons` (shared utilities)
64
+ - `openai>=2.3.0` (OpenAI API client)
65
+
66
+ ---
67
+
68
+ ## 🏁 Quick Start
69
+
70
+ ### Basic Setup
71
+
72
+ 1. Configure your API keys in your application's configuration:
73
+
74
+ ```python
75
+ from appkit_assistant.configuration import AssistantConfig
76
+
77
+ # In your app configuration
78
+ assistant_config = AssistantConfig(
79
+ openai_api_key="your-openai-key",
80
+ perplexity_api_key="your-perplexity-key",
81
+ # Optional: custom OpenAI base URL
82
+ openai_base_url="https://api.openai.com/v1"
83
+ )
84
+ ```
85
+
86
+ 2. Register processors with the ModelManager:
87
+
88
+ ```python
89
+ from appkit_assistant.backend.model_manager import ModelManager
90
+ from appkit_assistant.backend.processors.openai_chat_completion_processor import OpenAIChatCompletionProcessor
91
+ from appkit_assistant.backend.processors.perplexity_processor import PerplexityProcessor
92
+
93
+ manager = ModelManager()
94
+ manager.register_processor("openai", OpenAIChatCompletionProcessor(assistant_config))
95
+ manager.register_processor("perplexity", PerplexityProcessor(assistant_config))
96
+ ```
97
+
98
+ 3. Use the assistant component in your Reflex app:
99
+
100
+ ```python
101
+ import reflex as rx
102
+ import appkit_assistant as assistant
103
+
104
+ def assistant_page():
105
+ return rx.container(
106
+ assistant.Assistant(),
107
+ height="100vh"
108
+ )
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 📖 Usage
114
+
115
+ ### Model Management
116
+
117
+ The `ModelManager` singleton handles all AI processors and models:
118
+
119
+ ```python
120
+ from appkit_assistant.backend.model_manager import ModelManager
121
+
122
+ manager = ModelManager()
123
+
124
+ # Get all available models
125
+ models = manager.get_all_models()
126
+
127
+ # Get a specific model
128
+ model = manager.get_model("gpt-4")
129
+
130
+ # Set default model
131
+ manager.set_default_model("gpt-4")
132
+ ```
133
+
134
+ ### Processing Messages
135
+
136
+ Process conversations using the registered processors:
137
+
138
+ ```python
139
+ from appkit_assistant.backend.models import Message, MessageType
140
+
141
+ messages = [
142
+ Message(role="user", content="Hello, how are you?", type=MessageType.TEXT)
143
+ ]
144
+
145
+ async for chunk in manager.get_processor_for_model("gpt-4").process(messages, "gpt-4"):
146
+ print(f"Received: {chunk.content}")
147
+ ```
148
+
149
+ ### MCP Server Management
150
+
151
+ Manage MCP servers for tool integration:
152
+
153
+ ```python
154
+ from appkit_assistant.backend.models import MCPServer
155
+
156
+ mcp_server = MCPServer(
157
+ name="my-server",
158
+ command="python",
159
+ args=["-m", "my_mcp_server"],
160
+ headers={"Authorization": "Bearer token"}
161
+ )
162
+
163
+ # Use in processing
164
+ async for chunk in processor.process(messages, "gpt-4", mcp_servers=[mcp_server]):
165
+ # Handle response with MCP tools
166
+ pass
167
+ ```
168
+
169
+ ### UI Components
170
+
171
+ #### Assistant Interface
172
+
173
+ The main `Assistant` component provides a complete chat interface:
174
+
175
+ ```python
176
+ import appkit_assistant as assistant
177
+
178
+ def chat_page():
179
+ return assistant.Assistant()
180
+ ```
181
+
182
+ #### Individual Components
183
+
184
+ Use individual components for custom layouts:
185
+
186
+ ```python
187
+ import appkit_assistant as assistant
188
+
189
+ def custom_assistant():
190
+ return rx.vstack(
191
+ assistant.ThreadList(),
192
+ assistant.composer(),
193
+ spacing="4"
194
+ )
195
+ ```
196
+
197
+ #### MCP Server Management UI
198
+
199
+ Display and manage MCP servers:
200
+
201
+ ```python
202
+ def servers_page():
203
+ return assistant.mcp_servers_table()
204
+ ```
205
+
206
+ ---
207
+
208
+ ## 🔧 Configuration
209
+
210
+ ### AssistantConfig
211
+
212
+ Configure API keys and settings:
213
+
214
+ ```python
215
+ from appkit_assistant.configuration import AssistantConfig
216
+
217
+ config = AssistantConfig(
218
+ openai_api_key="sk-...",
219
+ openai_base_url="https://custom.openai.endpoint/v1",
220
+ perplexity_api_key="pplx-...",
221
+ google_api_key="AIza..." # For future Google integrations
222
+ )
223
+ ```
224
+
225
+ ### Processor Registration
226
+
227
+ Register processors based on available credentials:
228
+
229
+ ```python
230
+ from appkit_assistant.backend.processors import (
231
+ OpenAIChatCompletionProcessor,
232
+ PerplexityProcessor,
233
+ LoremIpsumProcessor
234
+ )
235
+
236
+ manager = ModelManager()
237
+
238
+ if config.openai_api_key:
239
+ manager.register_processor("openai", OpenAIChatCompletionProcessor(config))
240
+
241
+ if config.perplexity_api_key:
242
+ manager.register_processor("perplexity", PerplexityProcessor(config))
243
+
244
+ # Always available fallback
245
+ manager.register_processor("lorem", LoremIpsumProcessor())
246
+ ```
247
+
248
+ ---
249
+
250
+ ## 📋 API Reference
251
+
252
+ ### Core Classes
253
+
254
+ - `ModelManager` - Singleton model and processor registry
255
+ - `Processor` - Abstract base for AI processors
256
+ - `AIModel` - Model metadata and configuration
257
+ - `Message` - Conversation message structure
258
+ - `MCPServer` - MCP server configuration
259
+
260
+ ### Component API
261
+
262
+ - `Assistant` - Complete assistant interface
263
+ - `composer` - Message input component
264
+ - `ThreadList` - Conversation thread list
265
+ - `MessageComponent` - Individual message display
266
+ - `mcp_servers_table` - MCP server management table
267
+
268
+ ### State Management
269
+
270
+ - `ThreadState` - Individual thread state
271
+ - `ThreadListState` - Thread list management
272
+
273
+ ---
274
+
275
+ ## 🔒 Security
276
+
277
+ > [!IMPORTANT]
278
+ > API keys and MCP server credentials are handled securely using the appkit-commons configuration system. Never hardcode secrets in your code.
279
+
280
+ - Use `SecretStr` for sensitive configuration values
281
+ - Credentials are encrypted at rest when stored in the database
282
+ - MCP server headers support encrypted storage
283
+
284
+ ---
285
+
286
+ ## 🤝 Integration Examples
287
+
288
+ ### With AppKit User Management
289
+
290
+ Combine with appkit-user for authenticated assistants:
291
+
292
+ ```python
293
+ from appkit_user import authenticated, requires_role
294
+
295
+ @authenticated()
296
+ @requires_role("assistant_user")
297
+ def protected_assistant_page():
298
+ return assistant.Assistant()
299
+ ```
300
+
301
+ ### Custom Processor Implementation
302
+
303
+ Implement your own AI processor:
304
+
305
+ ```python
306
+ from appkit_assistant.backend.processor import Processor
307
+ from appkit_assistant.backend.models import AIModel, Chunk, Message
308
+
309
+ class CustomProcessor(Processor):
310
+ def get_supported_models(self):
311
+ return {
312
+ "custom-model": AIModel(
313
+ id="custom-model",
314
+ text="Custom AI Model",
315
+ icon="🤖"
316
+ )
317
+ }
318
+
319
+ async def process(self, messages, model_id, files=None, mcp_servers=None):
320
+ # Your AI processing logic here
321
+ yield Chunk(content="Response from custom model", type="text")
322
+ ```
323
+
324
+ ---
325
+
326
+ ## 📚 Related Components
327
+
328
+ - **[appkit-mantine](./../appkit-mantine)** - UI components used in the assistant interface
329
+ - **[appkit-user](./../appkit-user)** - User authentication and authorization
330
+ - **[appkit-commons](./../appkit-commons)** - Shared utilities and configuration
@@ -22,6 +22,6 @@ appkit_assistant/components/threadlist.py,sha256=NKB9GshghdSlUY2hVIRdhX9nxd6mxJe
22
22
  appkit_assistant/components/tools_modal.py,sha256=gThgOzYa_r74IHWEKxmmT85c2MiHLIhOFtiV9IT_r3E,3355
23
23
  appkit_assistant/state/mcp_server_state.py,sha256=L5r3Bd_OzFh_kgWH81cKVBWhE3Ys6m8TsJs2vadCWhU,7945
24
24
  appkit_assistant/state/thread_state.py,sha256=h8jmE0hZmSWJ5-D4EqxBTO0ydBSNa9IxUTa5tfYdkMk,32618
25
- appkit_assistant-0.7.3.dist-info/METADATA,sha256=tGfeVHTUrVIoJds2L5-4ZXOD-nPF_bbbDGTjq00Ecmo,202
26
- appkit_assistant-0.7.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- appkit_assistant-0.7.3.dist-info/RECORD,,
25
+ appkit_assistant-0.7.4.dist-info/METADATA,sha256=-UtfwMPp-C-2INeT7AgLVvu8I-LAPXgjGGjRLU_nnzY,8123
26
+ appkit_assistant-0.7.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ appkit_assistant-0.7.4.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: appkit-assistant
3
- Version: 0.7.3
4
- Summary: Add your description here
5
- Author: Jens Rehpöhler
6
- Requires-Python: >=3.13
7
- Requires-Dist: appkit-commons
8
- Requires-Dist: openai>=2.3.0