mira-network 0.1.5__tar.gz → 0.1.7__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Mira Network
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,362 @@
1
+ Metadata-Version: 2.1
2
+ Name: mira-network
3
+ Version: 0.1.7
4
+ Summary: Python SDK for Mira Network API
5
+ Author-Email: mira-network <sdk@mira.network>
6
+ License: MIT
7
+ Requires-Python: <3.14,>=3.9
8
+ Requires-Dist: httpx>=0.28.1
9
+ Requires-Dist: pydantic>=2.10.4
10
+ Requires-Dist: typing-extensions>=4.8.0
11
+ Requires-Dist: requests>=2.32.3
12
+ Requires-Dist: pytest-cov>=6.0.0
13
+ Requires-Dist: pytest>=8.3.4
14
+ Requires-Dist: pytest-asyncio>=0.25.0
15
+ Requires-Dist: ruff>=0.9.3
16
+ Requires-Dist: black>=25.1.0
17
+ Description-Content-Type: text/markdown
18
+
19
+ <div align="center">
20
+ <img src="https://mira.network/_next/static/media/nav_logo.dfc4db53.svg" alt="Mira Network SDK" width="100"/>
21
+ <h1>Mira Network Python SDK</h1>
22
+ <p><strong>Your Universal Gateway to AI Language Models</strong></p>
23
+ </div>
24
+
25
+ <p align="center">
26
+ <!-- Version and Download stats -->
27
+ <a href="https://pypi.org/project/mira-network/"><img src="https://img.shields.io/pypi/v/mira-network" alt="PyPI Version"></a>
28
+ <a href="https://pypi.org/project/mira-network/"><img src="https://img.shields.io/pypi/dm/mira-network" alt="Downloads"></a>
29
+
30
+ <!-- Package metadata -->
31
+ <a href="https://pypi.org/project/mira-network/"><img src="https://img.shields.io/pypi/format/mira-network" alt="Format"></a>
32
+ <a href="https://pypi.org/project/mira-network/"><img src="https://img.shields.io/pypi/implementation/mira-network" alt="Implementation"></a>
33
+
34
+ <!-- License -->
35
+ <a href="https://pypi.org/project/mira-network/"><img src="https://img.shields.io/pypi/l/mira-network" alt="License"></a>
36
+
37
+ <!-- Build Status -->
38
+ <a href="https://github.com/Aroha-Labs/mira-network/actions/workflows/ci-sdk.yml">
39
+ <img src="https://github.com/Aroha-Labs/mira-network/actions/workflows/ci-sdk.yml/badge.svg" alt="Build Status">
40
+ </a>
41
+ </p>
42
+
43
+ <p align="center">
44
+ <b>Mira Client enables seamless integration with multiple language models while providing advanced routing, load balancing, and flow management capabilities.</b>
45
+ </p>
46
+
47
+ ---
48
+
49
+ ## 🌟 What is Mira Network?
50
+
51
+ Mira Network is your unified interface to the world of AI language models. It provides:
52
+
53
+ - 🔄 **Smart Model Routing**: Route requests across different models
54
+ - ⚖️ **Load Balancing**: Distribute workload across nodes
55
+ - 🌊 **Flow Management**: Handle request patterns efficiently
56
+ - 🔌 **Universal Integration**: Single API for multiple models
57
+ - 📊 **Usage Tracking**: Monitor your model usage
58
+
59
+ ## Why Mira Network SDK?
60
+
61
+ | Feature | Mira SDK | Traditional Approach |
62
+ | ---------------------- | -------------------------- | ----------------------- |
63
+ | 🔄 Multi-model Support | Single unified API | Separate APIs per model |
64
+ | ⚖️ Load Balancing | Built-in | Custom implementation |
65
+ | 🌊 Flow Control | Automatic handling | Manual implementation |
66
+ | 📊 Usage Tracking | Integrated | Custom tracking needed |
67
+ | 🛡️ Error Handling | Standardized across models | Model-specific handling |
68
+
69
+ ## 🎯 Perfect For
70
+
71
+ - 🤖 AI Applications
72
+ - 📝 Text Generation
73
+ - 🔍 Search Enhancement
74
+ - 🎮 Interactive Systems
75
+
76
+ ## 🏃 Quick Start
77
+
78
+ ```bash
79
+ pip install mira-network
80
+ ```
81
+
82
+ ```python
83
+ from mira_network import MiraClient
84
+
85
+ async def get_ai_response(prompt):
86
+ async with MiraClient() as client:
87
+ return await client.chat_completions_create(
88
+ model="your-chosen-model",
89
+ messages=[{"role": "user", "content": prompt}]
90
+ )
91
+ ```
92
+
93
+ ## 🏗️ Architecture
94
+
95
+ ```mermaid
96
+ graph LR
97
+ A[Your App] --> B[Mira SDK]
98
+ B --> C[Load Balancer]
99
+ C --> D[Mira Node 1]
100
+ C --> E[Mira Node 2]
101
+ C --> F[Mira Node N]
102
+ ```
103
+
104
+ ## ✨ Key Features
105
+
106
+ - 🔌 Simple, intuitive API
107
+ - 🔄 Async-first design
108
+ - 🌊 Streaming support
109
+ - 🔐 Error handling
110
+ - 🛠️ Customizable nodes
111
+ - 📊 Usage tracking
112
+
113
+ ## 📑 Table of Contents
114
+
115
+ - [Installation](#installation)
116
+ - [Quick Start](#-quick-start)
117
+ - [Basic Usage](#-basic-usage)
118
+ - [Advanced Usage](#-advanced-usage)
119
+ - [API Reference](#-reference)
120
+ - [Support](#-support)
121
+ - [Contributing](#-contributing)
122
+ - [License](#-license)
123
+
124
+ ## 🔧 Installation
125
+
126
+ Install the SDK using pip:
127
+
128
+ ```bash
129
+ pip install mira-network
130
+ ```
131
+
132
+ ## 🚀 Quick Start
133
+
134
+ Experience the power of Mira Network in just a few lines of code:
135
+
136
+ ```python
137
+ from mira_network import MiraClient
138
+
139
+ async def main():
140
+ # Initialize with your API key
141
+ client = MiraClient(api_key="your-api-key")
142
+
143
+ # Get a response from AI
144
+ response = await client.chat_completions_create(
145
+ model="your-chosen-model",
146
+ messages=[
147
+ {"role": "user", "content": "What is the capital of France?"}
148
+ ]
149
+ )
150
+
151
+ # Print the AI's response
152
+ print(response["choices"][0]["message"]["content"])
153
+
154
+ if __name__ == "__main__":
155
+ import asyncio
156
+ asyncio.run(main())
157
+ ```
158
+
159
+ ## 📝 Basic Usage
160
+
161
+ ### Having a Conversation
162
+
163
+ Engage in natural conversations with AI models. The SDK handles the complexities of managing conversation context and model interactions:
164
+
165
+ ```python
166
+ response = await client.chat_completions_create(
167
+ model="your-chosen-model",
168
+ messages=[
169
+ {"role": "system", "content": "You are a helpful assistant"},
170
+ {"role": "user", "content": "Hi! Can you help me?"},
171
+ ]
172
+ )
173
+ ```
174
+
175
+ ### Checking Available Models
176
+
177
+ Explore the diverse range of available AI models:
178
+
179
+ ```python
180
+ models = await client.list_models()
181
+ print(models)
182
+ ```
183
+
184
+ ### Checking Your Credits
185
+
186
+ Monitor your usage and available credits:
187
+
188
+ ```python
189
+ credits = await client.get_user_credits()
190
+ print(credits)
191
+ ```
192
+
193
+ ## 🔧 Advanced Usage
194
+
195
+ ### Streaming Responses
196
+
197
+ Perfect for real-time applications and interactive experiences:
198
+
199
+ ```python
200
+ stream = await client.chat_completions_create(
201
+ model="your-chosen-model",
202
+ messages=[
203
+ {"role": "user", "content": "Write a story"}
204
+ ],
205
+ stream=True
206
+ )
207
+
208
+ async for chunk in stream:
209
+ print(chunk["choices"][0]["delta"]["content"], end="")
210
+ ```
211
+
212
+ ### Custom Mira Nodes
213
+
214
+ Integrate your preferred Mira nodes seamlessly:
215
+
216
+ ```python
217
+ response = await client.chat_completions_create(
218
+ model="your-model",
219
+ messages=[{"role": "user", "content": "Hello"}],
220
+ mira_node={
221
+ "base_url": "https://custom-node.com",
222
+ "api_key": "node-api-key"
223
+ }
224
+ )
225
+ ```
226
+
227
+ ### API Token Management
228
+
229
+ Secure and flexible token management for your applications:
230
+
231
+ ```python
232
+ # Create new token
233
+ new_token = await client.create_api_token(
234
+ {"description": "Production API Key"}
235
+ )
236
+
237
+ # List tokens
238
+ tokens = await client.list_api_tokens()
239
+
240
+ # Delete token
241
+ await client.delete_api_token("token-id")
242
+ ```
243
+
244
+ ### Using as Context Manager
245
+
246
+ Efficient resource management with context managers:
247
+
248
+ ```python
249
+ async with MiraClient(api_key="your-api-key") as client:
250
+ response = await client.chat_completions_create(...)
251
+ ```
252
+
253
+ ## 📚 Reference
254
+
255
+ ### Message Structure
256
+
257
+ Understanding the core message components:
258
+
259
+ ```python
260
+ Message:
261
+ role: str # "system", "user", or "assistant"
262
+ content: str # The message content
263
+ ```
264
+
265
+ ### Error Handling
266
+
267
+ Robust error handling for production applications:
268
+
269
+ #### Validation Errors
270
+
271
+ ```python
272
+ try:
273
+ response = await client.chat_completions_create(
274
+ model="your-chosen-model",
275
+ messages=[
276
+ {"role": "invalid", "content": "Hello"} # Invalid role
277
+ ]
278
+ )
279
+ except ValueError as e:
280
+ print(f"Validation error: {e}")
281
+ ```
282
+
283
+ #### Network Errors
284
+
285
+ ```python
286
+ try:
287
+ response = await client.chat_completions_create(...)
288
+ except httpx.HTTPError as e:
289
+ print(f"HTTP error: {e}")
290
+ ```
291
+
292
+ ### Environment Configuration
293
+
294
+ Flexible configuration options for different environments:
295
+
296
+ ```python
297
+ import os
298
+ from mira_network import MiraClient
299
+
300
+ client = MiraClient(
301
+ api_key=os.getenv("MIRA_API_KEY"),
302
+ base_url=os.getenv("MIRA_API_URL", "https://apis.mira.network")
303
+ )
304
+ ```
305
+
306
+ ## 💡 Real-world Examples
307
+
308
+ ### AI-powered Customer Service
309
+
310
+ ```python
311
+ async def handle_customer_query(query: str) -> str:
312
+ async with MiraClient() as client:
313
+ response = await client.chat_completions_create(
314
+ model="your-chosen-model",
315
+ messages=[
316
+ {"role": "system", "content": "You are a helpful customer service agent."},
317
+ {"role": "user", "content": query}
318
+ ],
319
+ temperature=0.7,
320
+ max_tokens=150
321
+ )
322
+ return response.choices[0].message.content
323
+ ```
324
+
325
+ ### Content Generation Pipeline
326
+
327
+ ```python
328
+ async def generate_blog_post(topic: str) -> dict:
329
+ async with MiraClient() as client:
330
+ # Generate outline
331
+ outline = await client.chat_completions_create(...)
332
+
333
+ # Generate content
334
+ content = await client.chat_completions_create(...)
335
+
336
+ # Generate meta description
337
+ meta = await client.chat_completions_create(...)
338
+
339
+ return {"outline": outline, "content": content, "meta": meta}
340
+ ```
341
+
342
+ ## 🤝 Support
343
+
344
+ For feature requests and bug reports, please visit our [Console Feedback](https://console-feedback.arohalabs.tech/).
345
+
346
+ ## 👥 Contributing
347
+
348
+ We welcome contributions! Here's how you can help:
349
+
350
+ 1. Fork the repository
351
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
352
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
353
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
354
+ 5. Open a Pull Request
355
+
356
+ ## 📄 License
357
+
358
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
359
+
360
+ ---
361
+
362
+ <p align="center">Built with ❤️ by the Mira Network team</p>