mbxai 2.1.3__py3-none-any.whl → 2.3.0__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.
@@ -1,8 +1,9 @@
1
- mbxai/__init__.py,sha256=Jc0jQm0epVrufRDNvp7YQYDWO6TgoF_XyC64qVu4rf8,407
1
+ mbxai/__init__.py,sha256=hYX0nNosmxC-fzg4eshrd_2x39Xn6a4sJWmiFB1QeLo,1043
2
2
  mbxai/core.py,sha256=WMvmU9TTa7M_m-qWsUew4xH8Ul6xseCZ2iBCXJTW-Bs,196
3
- mbxai/agent/__init__.py,sha256=5j3mW2NZtAU1s2w8n833axWBQsxW8U0qKwoQ9JtQZ4k,289
4
- mbxai/agent/client.py,sha256=M4n1RKeSi3e59nvJUjDdFR0dgWP-X1pe5j1YzjSV1js,37870
5
- mbxai/agent/models.py,sha256=sjBtaAENDABHl8IqTON1gxFFSZIaQYUCBFHB5804_Fw,5780
3
+ mbxai/agent/__init__.py,sha256=PWoj2HKZf9j3CE1g6srTgNcvXW0HmJRKzz7dIOhZ2vk,885
4
+ mbxai/agent/client.py,sha256=5mB270H2ukLk7tEqq5sWfDAu1ZbzKmi8Ba3I6YI3cB4,44196
5
+ mbxai/agent/client_legacy.py,sha256=M4n1RKeSi3e59nvJUjDdFR0dgWP-X1pe5j1YzjSV1js,37870
6
+ mbxai/agent/models.py,sha256=BHjtxBEqgetZxqFB6GzyeLuucss7IDUQhICcnVBwX00,16809
6
7
  mbxai/examples/agent_example.py,sha256=7gQHcMVWBu2xdxnVNzz4UfW0lkUnw9a5DN2-YoIRxXE,7420
7
8
  mbxai/examples/agent_iterations_example.py,sha256=xMqZhBWS67EkRkArjOAY2fCgLkQ32Qn9E4CSfEKW4MU,7905
8
9
  mbxai/examples/agent_logging_example.py,sha256=P5LDcoIn0XCYWMPJVTjeXNkY32ELyKEf63Z_1nu5QkA,10232
@@ -11,10 +12,12 @@ mbxai/examples/agent_validation_example.py,sha256=xlEf5Mwq5_Iu8bNU4cuHGZVYvAyZNh
11
12
  mbxai/examples/auto_schema_example.py,sha256=ymuJJqqDxYznZT2VN6zVFEM7m_lDuccZ1AKSx-xzLTM,8174
12
13
  mbxai/examples/conversation_history_test.py,sha256=TpOh5ruQlXDPTPEu_0qTACAaQPSklKp8RYiOm1UzqPI,7773
13
14
  mbxai/examples/dialog_agent_example.py,sha256=Za4m_JPusn3f60xYE0DTfqGwyz0rXoiCHLP-AFkiQYQ,7884
15
+ mbxai/examples/enhanced_agent_example.py,sha256=jRD7Z1nMibQgAc1Lvl-Xm7bHvUGhg2NkSo8ibmyqtaM,13323
14
16
  mbxai/examples/openrouter_example.py,sha256=-grXHKMmFLoh-yUIEMc31n8Gg1S7uSazBWCIOWxgbyQ,1317
15
17
  mbxai/examples/optional_prompt_example.py,sha256=dG9aRKZL_xIZX2OgbnYAJX-4_QGi3op31nn2fRthYKo,6386
16
18
  mbxai/examples/parse_example.py,sha256=eCKMJoOl6qwo8sDP6Trc6ncgjPlgTqi5tPE2kB5_P0k,3821
17
19
  mbxai/examples/parse_tool_example.py,sha256=duHN8scI9ZK6XZ5hdiz1Adzyc-_7tH9Ls9qP4S0bf5s,5477
20
+ mbxai/examples/redis_session_handler_example.py,sha256=BjVqlw-kKTPUIra49JwCjmbIDvCzTwtMUa2LVg0BF4E,8309
18
21
  mbxai/examples/request.json,sha256=fjVMses305wVUXgcmjESCvPgP81Js8Kk6zHjZ8EDyEg,5434
19
22
  mbxai/examples/response.json,sha256=4SGJJyQjWWeN__Mrxm6ZtHIo1NUtLEheldd5KaA2mHw,856
20
23
  mbxai/examples/send_request.py,sha256=O5gCHUHy7RvkEFo9IQATgnSOfOdu8OqKHfjAlLDwWPg,6023
@@ -26,9 +29,9 @@ mbxai/examples/mcp/mcp_server_example.py,sha256=nFfg22Jnc6HMW_ezLO3So1xwDdx2_rIt
26
29
  mbxai/mcp/__init__.py,sha256=_ek9iYdYqW5saKetj4qDci11jxesQDiHPJRpHMKkxgU,175
27
30
  mbxai/mcp/client.py,sha256=QRzId6o4_WRWVv3rtm8cfZZGaoY_UlaOO-oqNjY-tmw,5219
28
31
  mbxai/mcp/example.py,sha256=oaol7AvvZnX86JWNz64KvPjab5gg1VjVN3G8eFSzuaE,2350
29
- mbxai/mcp/server.py,sha256=BPVCF-E-fXngysenjG5k9e4HvLEAxB_49r_LJ_D0etE,3332
32
+ mbxai/mcp/server.py,sha256=BjaTe97i5vbrnk8JTH4VztF6mKyo8gymOJ1s9ID1IQ4,3332
30
33
  mbxai/openrouter/__init__.py,sha256=Ito9Qp_B6q-RLGAQcYyTJVWwR2YAZvNqE-HIYXxhtD8,298
31
- mbxai/openrouter/client.py,sha256=3LD6WDJ8wjo_nefH5d1NJCsrWPvBc_KBf2NsItUoSt8,18302
34
+ mbxai/openrouter/client.py,sha256=aWgE_-OqfwIcJmotM7diR0HbzA0qnVTdVH3xVIPyWHA,14542
32
35
  mbxai/openrouter/config.py,sha256=Ia93s-auim9Sq71eunVDbn9ET5xX2zusXpV4JBdHAzs,3251
33
36
  mbxai/openrouter/models.py,sha256=b3IjjtZAjeGOf2rLsdnCD1HacjTnS8jmv_ZXorc-KJQ,2604
34
37
  mbxai/openrouter/schema.py,sha256=H_77ZrA9zmbX155bWpCJj1jehUyJPS0QybEW1IVAoe0,540
@@ -36,7 +39,7 @@ mbxai/tools/__init__.py,sha256=ogxrHvgJ7OR62Lmd5x9Eh5d2C0jqWyQis7Zy3yKpZ78,218
36
39
  mbxai/tools/client.py,sha256=2wFPD-UN3Y2DSyrnqxt2vvFgTYHzUl14_y0r6fhAWmM,17198
37
40
  mbxai/tools/example.py,sha256=1HgKK39zzUuwFbnp3f0ThyWVfA_8P28PZcTwaUw5K78,2232
38
41
  mbxai/tools/types.py,sha256=OFfM7scDGTm4FOcJA2ecj-fxL1MEBkqPsT3hqCL1Jto,9505
39
- mbxai-2.1.3.dist-info/METADATA,sha256=21Rj50qEl1nFc_kTjY2d5PeE1WQsaLg2KtDRqMEMnCU,10018
40
- mbxai-2.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
- mbxai-2.1.3.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
42
- mbxai-2.1.3.dist-info/RECORD,,
42
+ mbxai-2.3.0.dist-info/METADATA,sha256=PzrkyW4Zqq683zQfqHgs8JkGoZH4CkLCmq5nmozRnl4,40491
43
+ mbxai-2.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
44
+ mbxai-2.3.0.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
45
+ mbxai-2.3.0.dist-info/RECORD,,
@@ -1,346 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: mbxai
3
- Version: 2.1.3
4
- Summary: MBX AI SDK
5
- Project-URL: Homepage, https://www.mibexx.de
6
- Project-URL: Documentation, https://www.mibexx.de
7
- Project-URL: Repository, https://github.com/yourusername/mbxai.git
8
- Author: MBX AI
9
- License: MIT
10
- License-File: LICENSE
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Operating System :: OS Independent
13
- Classifier: Programming Language :: Python
14
- Classifier: Programming Language :: Python :: 3.12
15
- Requires-Python: >=3.12
16
- Requires-Dist: fastapi>=0.115.12
17
- Requires-Dist: httpx>=0.27.0
18
- Requires-Dist: mcp>=1.7.1
19
- Requires-Dist: openai>=1.77.0
20
- Requires-Dist: pydantic-settings>=2.9.1
21
- Requires-Dist: pydantic>=2.9.1
22
- Requires-Dist: python-multipart>=0.0.20
23
- Requires-Dist: sse-starlette>=2.3.4
24
- Requires-Dist: starlette>=0.46.2
25
- Requires-Dist: typing-inspection<=0.4.0
26
- Requires-Dist: uvicorn>=0.34.2
27
- Provides-Extra: dev
28
- Requires-Dist: black>=24.3.0; extra == 'dev'
29
- Requires-Dist: isort>=5.13.2; extra == 'dev'
30
- Requires-Dist: mypy>=1.8.0; extra == 'dev'
31
- Requires-Dist: pytest-asyncio>=0.26.0; extra == 'dev'
32
- Requires-Dist: pytest-cov>=6.1.1; extra == 'dev'
33
- Requires-Dist: pytest>=8.3.5; extra == 'dev'
34
- Description-Content-Type: text/markdown
35
-
36
- # MBX AI
37
-
38
- A Python library for building AI applications with LLMs.
39
-
40
- ## Features
41
-
42
- - **OpenRouter Integration**: Connect to various LLM providers through OpenRouter
43
- - **Intelligent Agent System**: AgentClient with dialog-based thinking, question generation, and quality iteration
44
- - **Tool Integration**: Easily integrate tools with LLMs using the Model Context Protocol (MCP)
45
- - **Structured Output**: Get structured, typed responses from LLMs
46
- - **Chat Interface**: Simple chat interface for interacting with LLMs
47
- - **FastAPI Server**: Built-in FastAPI server for tool integration
48
-
49
- ## Installation
50
-
51
- ```bash
52
- pip install mbxai
53
- ```
54
-
55
- ## Quick Start
56
-
57
- ### Basic Usage
58
-
59
- ```python
60
- from mbxai import OpenRouterClient
61
-
62
- # Initialize the client
63
- client = OpenRouterClient(api_key="your-api-key")
64
-
65
- # Chat with an LLM
66
- response = await client.chat([
67
- {"role": "user", "content": "Hello, how are you?"}
68
- ])
69
- print(response.choices[0].message.content)
70
- ```
71
-
72
- ### Quick Agent Example
73
-
74
- ```python
75
- from mbxai import AgentClient, OpenRouterClient
76
- from pydantic import BaseModel, Field
77
-
78
- class TravelPlan(BaseModel):
79
- destination: str = Field(description="Travel destination")
80
- activities: list[str] = Field(description="Recommended activities")
81
- budget: str = Field(description="Estimated budget")
82
-
83
- # Initialize agent
84
- client = OpenRouterClient(token="your-api-key")
85
- agent = AgentClient(client)
86
-
87
- # Get intelligent response with automatic quality improvement
88
- response = agent.agent(
89
- prompt="Plan a weekend trip to a mountain destination",
90
- final_response_structure=TravelPlan,
91
- ask_questions=False
92
- )
93
-
94
- plan = response.final_response
95
- print(f"Destination: {plan.destination}")
96
- print(f"Activities: {', '.join(plan.activities)}")
97
- ```
98
-
99
- ### Using Tools
100
-
101
- ```python
102
- from mbxai import OpenRouterClient, ToolClient
103
- from pydantic import BaseModel
104
-
105
- # Define your tool's input and output models
106
- class CalculatorInput(BaseModel):
107
- a: float
108
- b: float
109
-
110
- class CalculatorOutput(BaseModel):
111
- result: float
112
-
113
- # Create a calculator tool
114
- async def calculator(input: CalculatorInput) -> CalculatorOutput:
115
- return CalculatorOutput(result=input.a + input.b)
116
-
117
- # Initialize the client with tools
118
- client = ToolClient(OpenRouterClient(api_key="your-api-key"))
119
- client.add_tool(calculator)
120
-
121
- # Use the tool in a chat
122
- response = await client.chat([
123
- {"role": "user", "content": "What is 2 + 3?"}
124
- ])
125
- print(response.choices[0].message.content)
126
- ```
127
-
128
- ### Using MCP (Model Context Protocol)
129
-
130
- ```python
131
- from mbxai import OpenRouterClient, MCPClient
132
- from mbxai.mcp import MCPServer
133
- from mcp.server.fastmcp import FastMCP
134
- from pydantic import BaseModel
135
-
136
- # Define your tool's input and output models
137
- class CalculatorInput(BaseModel):
138
- a: float
139
- b: float
140
-
141
- class CalculatorOutput(BaseModel):
142
- result: float
143
-
144
- # Create a FastMCP instance
145
- mcp = FastMCP("calculator-service")
146
-
147
- # Create a calculator tool
148
- @mcp.tool()
149
- async def calculator(argument: CalculatorInput) -> CalculatorOutput:
150
- return CalculatorOutput(result=argument.a + argument.b)
151
-
152
- # Start the MCP server
153
- server = MCPServer("calculator-service")
154
- await server.add_tool(calculator)
155
- await server.start()
156
-
157
- # Initialize the MCP client
158
- client = MCPClient(OpenRouterClient(api_key="your-api-key"))
159
- await client.register_mcp_server("calculator-service", "http://localhost:8000")
160
-
161
- # Use the tool in a chat
162
- response = await client.chat([
163
- {"role": "user", "content": "What is 2 + 3?"}
164
- ])
165
- print(response.choices[0].message.content)
166
- ```
167
-
168
- ### Using AgentClient (Intelligent Dialog System)
169
-
170
- The `AgentClient` provides an intelligent dialog-based thinking process that can ask clarifying questions, iterate on responses, and provide structured outputs.
171
-
172
- #### Basic Agent Usage
173
-
174
- ```python
175
- from mbxai import AgentClient, OpenRouterClient
176
- from pydantic import BaseModel, Field
177
-
178
- # Define your response structure
179
- class BookRecommendation(BaseModel):
180
- title: str = Field(description="The title of the recommended book")
181
- author: str = Field(description="The author of the book")
182
- genre: str = Field(description="The genre of the book")
183
- reason: str = Field(description="Why this book is recommended")
184
-
185
- # Initialize the agent
186
- client = OpenRouterClient(token="your-api-key")
187
- agent = AgentClient(client)
188
-
189
- # Get a recommendation with questions
190
- response = agent.agent(
191
- prompt="I want a book recommendation",
192
- final_response_structure=BookRecommendation,
193
- ask_questions=True # Agent will ask clarifying questions
194
- )
195
-
196
- if response.has_questions():
197
- # Display questions to user
198
- for question in response.questions:
199
- print(f"Q: {question.question}")
200
-
201
- # Collect answers and continue
202
- from mbxai import AnswerList, Answer
203
- answers = AnswerList(answers=[
204
- Answer(key="genre", answer="I love science fiction"),
205
- Answer(key="complexity", answer="I prefer complex narratives")
206
- ])
207
-
208
- # Continue the conversation
209
- final_response = agent.answer_to_agent(response.agent_id, answers)
210
- book_rec = final_response.final_response
211
- print(f"Recommended: {book_rec.title} by {book_rec.author}")
212
- else:
213
- # Direct response without questions
214
- book_rec = response.final_response
215
- print(f"Recommended: {book_rec.title} by {book_rec.author}")
216
- ```
217
-
218
- #### Agent with Tool Integration
219
-
220
- ```python
221
- from mbxai import AgentClient, ToolClient, OpenRouterClient
222
-
223
- # Initialize with tool support
224
- openrouter_client = OpenRouterClient(token="your-api-key")
225
- tool_client = ToolClient(openrouter_client)
226
- agent = AgentClient(tool_client)
227
-
228
- # Register tools via the agent (schema auto-generated!)
229
- def get_weather(location: str, unit: str = "fahrenheit") -> dict:
230
- """Get weather information for a location.
231
-
232
- Args:
233
- location: The city or location name
234
- unit: Temperature unit (fahrenheit or celsius)
235
- """
236
- return {"location": location, "temperature": "72°F", "conditions": "Sunny"}
237
-
238
- agent.register_tool(
239
- name="get_weather",
240
- description="Get current weather for a location",
241
- function=get_weather
242
- # Schema automatically generated from function signature!
243
- )
244
-
245
- # Use agent with tools
246
- class WeatherResponse(BaseModel):
247
- location: str = Field(description="The location")
248
- weather: str = Field(description="Weather description")
249
- recommendations: list[str] = Field(description="Clothing recommendations")
250
-
251
- response = agent.agent(
252
- prompt="What's the weather in San Francisco and what should I wear?",
253
- final_response_structure=WeatherResponse,
254
- ask_questions=False
255
- )
256
-
257
- weather_info = response.final_response
258
- print(f"Weather: {weather_info.weather}")
259
- ```
260
-
261
- #### Agent Configuration
262
-
263
- ```python
264
- # Configure quality iterations (default: 2)
265
- agent = AgentClient(
266
- ai_client=openrouter_client,
267
- max_iterations=3 # More iterations = higher quality, slower response
268
- )
269
-
270
- # Different configurations for different use cases:
271
- # max_iterations=0: Fastest, basic quality (chatbots)
272
- # max_iterations=1: Fast, good quality (content generation)
273
- # max_iterations=2: Balanced (default, recommended)
274
- # max_iterations=3+: Highest quality (analysis, reports)
275
- ```
276
-
277
- #### Agent with MCP Client
278
-
279
- ```python
280
- from mbxai import AgentClient, MCPClient
281
-
282
- # Initialize with MCP support
283
- mcp_client = MCPClient(OpenRouterClient(token="your-api-key"))
284
- agent = AgentClient(mcp_client)
285
-
286
- # Register MCP servers
287
- agent.register_mcp_server("data-analysis", "http://localhost:8000")
288
-
289
- # Register individual tools
290
- agent.register_tool("analyze_data", "Analyze dataset", analyze_function, schema)
291
-
292
- # Use agent with full MCP capabilities
293
- response = agent.agent(
294
- prompt="Analyze the sales data and provide insights",
295
- final_response_structure=AnalysisReport,
296
- ask_questions=True
297
- )
298
- ```
299
-
300
- #### Agent Features
301
-
302
- - **Intelligent Questions**: Automatically generates clarifying questions when needed
303
- - **Quality Iteration**: Improves responses through multiple AI review cycles
304
- - **Tool Integration**: Seamlessly works with ToolClient and MCPClient
305
- - **Structured Output**: Always returns properly typed Pydantic models
306
- - **Session Management**: Handles multi-turn conversations with question/answer flow
307
- - **Configurable**: Adjust quality vs speed with max_iterations parameter
308
-
309
- #### Supported AI Clients
310
-
311
- | Client | Structured Responses | Tool Registration | MCP Server Registration |
312
- |--------|---------------------|-------------------|------------------------|
313
- | OpenRouterClient | ✅ | ❌ | ❌ |
314
- | ToolClient | ✅ | ✅ | ❌ |
315
- | MCPClient | ✅ | ✅ | ✅ |
316
-
317
- ## Development
318
-
319
- ### Setup
320
-
321
- 1. Clone the repository:
322
- ```bash
323
- git clone https://github.com/yourusername/mbxai.git
324
- cd mbxai
325
- ```
326
-
327
- 2. Create a virtual environment:
328
- ```bash
329
- python -m venv .venv
330
- source .venv/bin/activate # On Windows: .venv\Scripts\activate
331
- ```
332
-
333
- 3. Install dependencies:
334
- ```bash
335
- pip install -e ".[dev]"
336
- ```
337
-
338
- ### Running Tests
339
-
340
- ```bash
341
- pytest tests/
342
- ```
343
-
344
- ## License
345
-
346
- MIT License
File without changes