mira-network 0.1.3__py3-none-any.whl → 0.1.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.
- {mira_sdk → mira_network}/__init__.py +1 -6
- {mira_sdk → mira_network}/client.py +70 -75
- {mira_sdk → mira_network}/models.py +26 -24
- mira_network/sync_client.py +111 -0
- mira_network-0.1.4.dist-info/METADATA +178 -0
- mira_network-0.1.4.dist-info/RECORD +8 -0
- mira_network-0.1.3.dist-info/METADATA +0 -108
- mira_network-0.1.3.dist-info/RECORD +0 -7
- {mira_network-0.1.3.dist-info → mira_network-0.1.4.dist-info}/WHEEL +0 -0
- {mira_network-0.1.3.dist-info → mira_network-0.1.4.dist-info}/entry_points.txt +0 -0
@@ -1,12 +1,10 @@
|
|
1
1
|
from .client import MiraClient
|
2
|
+
from .sync_client import MiraSyncClient
|
2
3
|
from .models import (
|
3
4
|
Message,
|
4
5
|
ModelProvider,
|
5
6
|
AiRequest,
|
6
|
-
FlowChatCompletion,
|
7
|
-
FlowRequest,
|
8
7
|
ApiTokenRequest,
|
9
|
-
AddCreditRequest,
|
10
8
|
)
|
11
9
|
|
12
10
|
__all__ = [
|
@@ -14,8 +12,5 @@ __all__ = [
|
|
14
12
|
"Message",
|
15
13
|
"ModelProvider",
|
16
14
|
"AiRequest",
|
17
|
-
"FlowChatCompletion",
|
18
|
-
"FlowRequest",
|
19
15
|
"ApiTokenRequest",
|
20
|
-
"AddCreditRequest",
|
21
16
|
]
|
@@ -1,13 +1,8 @@
|
|
1
1
|
from typing import AsyncIterator, Optional, List, Dict, AsyncGenerator, Union
|
2
2
|
import httpx
|
3
3
|
from .models import (
|
4
|
-
Message,
|
5
|
-
ModelProvider,
|
6
4
|
AiRequest,
|
7
|
-
FlowChatCompletion,
|
8
|
-
FlowRequest,
|
9
5
|
ApiTokenRequest,
|
10
|
-
AddCreditRequest,
|
11
6
|
)
|
12
7
|
|
13
8
|
|
@@ -15,7 +10,7 @@ class MiraClient:
|
|
15
10
|
|
16
11
|
def __init__(
|
17
12
|
self,
|
18
|
-
base_url: str = "https://mira
|
13
|
+
base_url: str = "https://apis.mira.network/",
|
19
14
|
api_token: Optional[str] = None,
|
20
15
|
):
|
21
16
|
"""Initialize Mira client.
|
@@ -64,63 +59,63 @@ class MiraClient:
|
|
64
59
|
else:
|
65
60
|
return response.json()
|
66
61
|
|
67
|
-
async def generate_with_flow(
|
68
|
-
|
69
|
-
) -> Union[str, AsyncGenerator[str, None]]:
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
async def list_flows(self) -> List[Dict]:
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
async def get_flow(self, flow_id: str) -> Dict:
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
async def create_flow(self, request: FlowRequest) -> Dict:
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
async def update_flow(self, flow_id: str, request: FlowRequest) -> Dict:
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
async def delete_flow(self, flow_id: str) -> None:
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
62
|
+
# async def generate_with_flow(
|
63
|
+
# self, flow_id: str, request: FlowChatCompletion
|
64
|
+
# ) -> Union[str, AsyncGenerator[str, None]]:
|
65
|
+
# """Generate text using a specific flow."""
|
66
|
+
# response = await self._client.post(
|
67
|
+
# f"{self.base_url}/v1/flows/{flow_id}/chat/completions",
|
68
|
+
# headers=self._get_headers(),
|
69
|
+
# json=request.model_dump(),
|
70
|
+
# )
|
71
|
+
# response.raise_for_status()
|
72
|
+
# return response.json()
|
73
|
+
|
74
|
+
# async def list_flows(self) -> List[Dict]:
|
75
|
+
# """List all flows."""
|
76
|
+
# response = await self._client.get(
|
77
|
+
# f"{self.base_url}/flows",
|
78
|
+
# headers=self._get_headers(),
|
79
|
+
# )
|
80
|
+
# response.raise_for_status()
|
81
|
+
# return response.json()
|
82
|
+
|
83
|
+
# async def get_flow(self, flow_id: str) -> Dict:
|
84
|
+
# """Get details of a specific flow."""
|
85
|
+
# response = await self._client.get(
|
86
|
+
# f"{self.base_url}/flows/{flow_id}",
|
87
|
+
# headers=self._get_headers(),
|
88
|
+
# )
|
89
|
+
# response.raise_for_status()
|
90
|
+
# return response.json()
|
91
|
+
|
92
|
+
# async def create_flow(self, request: FlowRequest) -> Dict:
|
93
|
+
# """Create a new flow."""
|
94
|
+
# response = await self._client.post(
|
95
|
+
# f"{self.base_url}/flows",
|
96
|
+
# headers=self._get_headers(),
|
97
|
+
# json=request.model_dump(),
|
98
|
+
# )
|
99
|
+
# response.raise_for_status()
|
100
|
+
# return response.json()
|
101
|
+
|
102
|
+
# async def update_flow(self, flow_id: str, request: FlowRequest) -> Dict:
|
103
|
+
# """Update an existing flow."""
|
104
|
+
# response = await self._client.put(
|
105
|
+
# f"{self.base_url}/flows/{flow_id}",
|
106
|
+
# headers=self._get_headers(),
|
107
|
+
# json=request.model_dump(),
|
108
|
+
# )
|
109
|
+
# response.raise_for_status()
|
110
|
+
# return response.json()
|
111
|
+
|
112
|
+
# async def delete_flow(self, flow_id: str) -> None:
|
113
|
+
# """Delete a flow."""
|
114
|
+
# response = await self._client.delete(
|
115
|
+
# f"{self.base_url}/flows/{flow_id}",
|
116
|
+
# headers=self._get_headers(),
|
117
|
+
# )
|
118
|
+
# response.raise_for_status()
|
124
119
|
|
125
120
|
async def create_api_token(self, request: ApiTokenRequest) -> Dict:
|
126
121
|
"""Create a new API token."""
|
@@ -135,7 +130,7 @@ class MiraClient:
|
|
135
130
|
async def list_api_tokens(self) -> List[Dict]:
|
136
131
|
"""List all API tokens."""
|
137
132
|
response = await self._client.get(
|
138
|
-
f"{self.base_url}/tokens",
|
133
|
+
f"{self.base_url}/api-tokens",
|
139
134
|
headers=self._get_headers(),
|
140
135
|
)
|
141
136
|
response.raise_for_status()
|
@@ -144,7 +139,7 @@ class MiraClient:
|
|
144
139
|
async def delete_api_token(self, token: str) -> None:
|
145
140
|
"""Delete an API token."""
|
146
141
|
response = await self._client.delete(
|
147
|
-
f"{self.base_url}/tokens/{token}",
|
142
|
+
f"{self.base_url}/api-tokens/{token}",
|
148
143
|
headers=self._get_headers(),
|
149
144
|
)
|
150
145
|
response.raise_for_status()
|
@@ -158,20 +153,20 @@ class MiraClient:
|
|
158
153
|
response.raise_for_status()
|
159
154
|
return response.json()
|
160
155
|
|
161
|
-
async def add_credit(self, request: AddCreditRequest) -> Dict:
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
156
|
+
# async def add_credit(self, request: AddCreditRequest) -> Dict:
|
157
|
+
# """Add credits to a user account."""
|
158
|
+
# response = await self._client.post(
|
159
|
+
# f"{self.base_url}/credits",
|
160
|
+
# headers=self._get_headers(),
|
161
|
+
# json=request.model_dump(),
|
162
|
+
# )
|
163
|
+
# response.raise_for_status()
|
164
|
+
# return response.json()
|
170
165
|
|
171
166
|
async def get_credits_history(self) -> List[Dict]:
|
172
167
|
"""Get user credits history."""
|
173
168
|
response = await self._client.get(
|
174
|
-
f"{self.base_url}/credits
|
169
|
+
f"{self.base_url}/user-credits-history",
|
175
170
|
headers=self._get_headers(),
|
176
171
|
)
|
177
172
|
response.raise_for_status()
|
@@ -22,7 +22,9 @@ class ModelProvider(BaseModel):
|
|
22
22
|
|
23
23
|
class AiRequest(BaseModel):
|
24
24
|
model: str = Field("mira/llama3.1", title="Model")
|
25
|
-
model_provider: Optional[ModelProvider] = Field(
|
25
|
+
model_provider: Optional[ModelProvider] = Field(
|
26
|
+
None, title="Model Provider (optional)"
|
27
|
+
)
|
26
28
|
messages: List[Message] = Field([], title="Messages")
|
27
29
|
stream: Optional[bool] = Field(False, title="Stream")
|
28
30
|
|
@@ -34,34 +36,34 @@ class AiRequest(BaseModel):
|
|
34
36
|
return v
|
35
37
|
|
36
38
|
|
37
|
-
class FlowChatCompletion(BaseModel):
|
38
|
-
|
39
|
+
# class FlowChatCompletion(BaseModel):
|
40
|
+
# variables: Optional[Dict] = Field(None, title="Variables")
|
39
41
|
|
40
42
|
|
41
|
-
class FlowRequest(BaseModel):
|
42
|
-
|
43
|
-
|
43
|
+
# class FlowRequest(BaseModel):
|
44
|
+
# system_prompt: str
|
45
|
+
# name: str
|
44
46
|
|
45
47
|
|
46
48
|
class ApiTokenRequest(BaseModel):
|
47
49
|
description: Optional[str] = None
|
48
50
|
|
49
51
|
|
50
|
-
class AddCreditRequest(BaseModel):
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
52
|
+
# class AddCreditRequest(BaseModel):
|
53
|
+
# user_id: str
|
54
|
+
# amount: float
|
55
|
+
# description: Optional[str] = None
|
56
|
+
|
57
|
+
# @field_validator("amount")
|
58
|
+
# @classmethod
|
59
|
+
# def validate_amount(cls, v: float) -> float:
|
60
|
+
# if v <= 0:
|
61
|
+
# raise ValueError("Amount must be greater than 0")
|
62
|
+
# return v
|
63
|
+
|
64
|
+
# @field_validator("user_id")
|
65
|
+
# @classmethod
|
66
|
+
# def validate_user_id(cls, v: str) -> str:
|
67
|
+
# if not v.strip():
|
68
|
+
# raise ValueError("User ID cannot be empty")
|
69
|
+
# return v
|
@@ -0,0 +1,111 @@
|
|
1
|
+
from typing import Optional, List, Dict, Iterator, Union
|
2
|
+
import requests
|
3
|
+
from .models import (
|
4
|
+
AiRequest,
|
5
|
+
ApiTokenRequest,
|
6
|
+
)
|
7
|
+
|
8
|
+
|
9
|
+
class MiraSyncClient:
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
base_url: str = "https://apis.mira.network/",
|
13
|
+
api_token: Optional[str] = None,
|
14
|
+
):
|
15
|
+
"""Initialize Mira synchronous client.
|
16
|
+
|
17
|
+
Args:
|
18
|
+
base_url: Base URL of the Mira API
|
19
|
+
api_token: Optional API token for authentication
|
20
|
+
"""
|
21
|
+
self.base_url = base_url
|
22
|
+
self.api_token = api_token
|
23
|
+
self._session = requests.Session()
|
24
|
+
|
25
|
+
def __enter__(self):
|
26
|
+
return self
|
27
|
+
|
28
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
29
|
+
self._session.close()
|
30
|
+
|
31
|
+
def _get_headers(self) -> Dict[str, str]:
|
32
|
+
headers = {"Content-Type": "application/json"}
|
33
|
+
if self.api_token:
|
34
|
+
headers["Authorization"] = f"Bearer {self.api_token}"
|
35
|
+
return headers
|
36
|
+
|
37
|
+
def list_models(self) -> List[str]:
|
38
|
+
"""List available models."""
|
39
|
+
response = self._session.get(
|
40
|
+
f"{self.base_url}/v1/models",
|
41
|
+
headers=self._get_headers(),
|
42
|
+
)
|
43
|
+
response.raise_for_status()
|
44
|
+
return response.json()
|
45
|
+
|
46
|
+
def generate(self, request: AiRequest) -> Union[str, Iterator[str]]:
|
47
|
+
"""Generate text using the specified model.
|
48
|
+
|
49
|
+
Args:
|
50
|
+
request: The AI request configuration
|
51
|
+
|
52
|
+
Returns:
|
53
|
+
Either a string response (when stream=False) or an iterator of string chunks (when stream=True)
|
54
|
+
"""
|
55
|
+
response = self._session.post(
|
56
|
+
f"{self.base_url}/v1/chat/completions",
|
57
|
+
headers=self._get_headers(),
|
58
|
+
json=request.model_dump(),
|
59
|
+
stream=request.stream,
|
60
|
+
)
|
61
|
+
response.raise_for_status()
|
62
|
+
|
63
|
+
if request.stream:
|
64
|
+
return response.iter_lines(decode_unicode=True)
|
65
|
+
else:
|
66
|
+
return response.json()
|
67
|
+
|
68
|
+
def create_api_token(self, request: ApiTokenRequest) -> Dict:
|
69
|
+
"""Create a new API token."""
|
70
|
+
response = self._session.post(
|
71
|
+
f"{self.base_url}/api-tokens",
|
72
|
+
headers=self._get_headers(),
|
73
|
+
json=request.model_dump(),
|
74
|
+
)
|
75
|
+
response.raise_for_status()
|
76
|
+
return response.json()
|
77
|
+
|
78
|
+
def list_api_tokens(self) -> List[Dict]:
|
79
|
+
"""List all API tokens."""
|
80
|
+
response = self._session.get(
|
81
|
+
f"{self.base_url}/api-tokens",
|
82
|
+
headers=self._get_headers(),
|
83
|
+
)
|
84
|
+
response.raise_for_status()
|
85
|
+
return response.json()
|
86
|
+
|
87
|
+
def delete_api_token(self, token: str) -> None:
|
88
|
+
"""Delete an API token."""
|
89
|
+
response = self._session.delete(
|
90
|
+
f"{self.base_url}/api-tokens/{token}",
|
91
|
+
headers=self._get_headers(),
|
92
|
+
)
|
93
|
+
response.raise_for_status()
|
94
|
+
|
95
|
+
def get_user_credits(self) -> Dict:
|
96
|
+
"""Get user credits information."""
|
97
|
+
response = self._session.get(
|
98
|
+
f"{self.base_url}/user-credits",
|
99
|
+
headers=self._get_headers(),
|
100
|
+
)
|
101
|
+
response.raise_for_status()
|
102
|
+
return response.json()
|
103
|
+
|
104
|
+
def get_credits_history(self) -> List[Dict]:
|
105
|
+
"""Get user credits history."""
|
106
|
+
response = self._session.get(
|
107
|
+
f"{self.base_url}/user-credits-history",
|
108
|
+
headers=self._get_headers(),
|
109
|
+
)
|
110
|
+
response.raise_for_status()
|
111
|
+
return response.json()
|
@@ -0,0 +1,178 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: mira-network
|
3
|
+
Version: 0.1.4
|
4
|
+
Summary: Python SDK for Mira Network API
|
5
|
+
Author-Email: sarim2000 <sarimbleedblue@gmail.com>
|
6
|
+
License: MIT
|
7
|
+
Requires-Python: ==3.10.*
|
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
|
+
Description-Content-Type: text/markdown
|
14
|
+
|
15
|
+
# Mira Network SDK
|
16
|
+
|
17
|
+
A Python SDK for interacting with the Mira Network API. This SDK provides both synchronous and asynchronous interfaces to access Mira API endpoints for model inference, API token management, and credit system operations.
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
```bash
|
22
|
+
pip install mira-network
|
23
|
+
```
|
24
|
+
|
25
|
+
## Quick Start
|
26
|
+
|
27
|
+
### Synchronous Usage
|
28
|
+
|
29
|
+
```python
|
30
|
+
from mira_network.sync_client import MiraSyncClient
|
31
|
+
from mira_network.models import AiRequest, Message
|
32
|
+
|
33
|
+
# Using context manager (recommended)
|
34
|
+
with MiraSyncClient(api_token="your-api-token") as client:
|
35
|
+
# Example 1: Non-streaming response
|
36
|
+
request = AiRequest(
|
37
|
+
messages=[
|
38
|
+
Message(role="system", content="You are a helpful assistant."),
|
39
|
+
Message(role="user", content="Hello!")
|
40
|
+
],
|
41
|
+
stream=False
|
42
|
+
)
|
43
|
+
response = client.generate(request)
|
44
|
+
print(response)
|
45
|
+
|
46
|
+
# Example 2: Streaming response
|
47
|
+
stream_request = AiRequest(
|
48
|
+
messages=[
|
49
|
+
Message(role="system", content="You are a helpful assistant."),
|
50
|
+
Message(role="user", content="Tell me a story!")
|
51
|
+
],
|
52
|
+
stream=True
|
53
|
+
)
|
54
|
+
for chunk in client.generate(stream_request):
|
55
|
+
print(chunk)
|
56
|
+
```
|
57
|
+
|
58
|
+
### Asynchronous Usage
|
59
|
+
|
60
|
+
```python
|
61
|
+
import asyncio
|
62
|
+
from mira_network.client import MiraClient
|
63
|
+
from mira_network.models import AiRequest, Message
|
64
|
+
|
65
|
+
async def main():
|
66
|
+
# Using async context manager (recommended)
|
67
|
+
async with MiraClient(api_token="your-api-token") as client:
|
68
|
+
# Example 1: Non-streaming response
|
69
|
+
request = AiRequest(
|
70
|
+
messages=[
|
71
|
+
Message(role="system", content="You are a helpful assistant."),
|
72
|
+
Message(role="user", content="Hello!")
|
73
|
+
],
|
74
|
+
stream=False
|
75
|
+
)
|
76
|
+
response = await client.generate(request)
|
77
|
+
print(response)
|
78
|
+
|
79
|
+
# Example 2: Streaming response
|
80
|
+
stream_request = AiRequest(
|
81
|
+
messages=[
|
82
|
+
Message(role="system", content="You are a helpful assistant."),
|
83
|
+
Message(role="user", content="Tell me a story!")
|
84
|
+
],
|
85
|
+
stream=True
|
86
|
+
)
|
87
|
+
async for chunk in await client.generate(stream_request):
|
88
|
+
print(chunk)
|
89
|
+
|
90
|
+
if __name__ == "__main__":
|
91
|
+
asyncio.run(main())
|
92
|
+
```
|
93
|
+
|
94
|
+
## API Reference
|
95
|
+
|
96
|
+
### Client Initialization
|
97
|
+
|
98
|
+
The SDK provides two client classes:
|
99
|
+
- `MiraSyncClient`: Synchronous client using `requests`
|
100
|
+
- `MiraClient`: Asynchronous client using `httpx`
|
101
|
+
|
102
|
+
Both clients support context managers for proper resource cleanup:
|
103
|
+
|
104
|
+
```python
|
105
|
+
# Synchronous
|
106
|
+
with MiraSyncClient(api_token="your-api-token") as client:
|
107
|
+
# Your sync code here
|
108
|
+
|
109
|
+
# Asynchronous
|
110
|
+
async with MiraClient(api_token="your-api-token") as client:
|
111
|
+
# Your async code here
|
112
|
+
```
|
113
|
+
|
114
|
+
### Models
|
115
|
+
|
116
|
+
- `Message`: Represents a chat message
|
117
|
+
- `role`: String ("system", "user", or "assistant")
|
118
|
+
- `content`: String content of the message
|
119
|
+
|
120
|
+
- `AiRequest`: Configuration for model inference
|
121
|
+
- `model`: Model identifier (default: "mira/llama3.1")
|
122
|
+
- `messages`: List of Message objects
|
123
|
+
- `stream`: Boolean to enable streaming responses (default: False)
|
124
|
+
- `model_provider`: Optional ModelProvider configuration
|
125
|
+
|
126
|
+
- `ModelProvider`: Custom provider configuration
|
127
|
+
- `base_url`: Provider's base URL
|
128
|
+
- `api_key`: Provider's API key
|
129
|
+
|
130
|
+
- `ApiTokenRequest`: Request for creating API tokens
|
131
|
+
- `description`: Optional description for the token
|
132
|
+
|
133
|
+
### Available Methods
|
134
|
+
|
135
|
+
Both sync and async clients provide the same methods with identical parameters. The only difference is that async methods must be awaited.
|
136
|
+
|
137
|
+
#### Model Operations
|
138
|
+
```python
|
139
|
+
# Sync
|
140
|
+
models = client.list_models()
|
141
|
+
response = client.generate(AiRequest(messages=[...], stream=False))
|
142
|
+
for chunk in client.generate(AiRequest(messages=[...], stream=True)):
|
143
|
+
print(chunk)
|
144
|
+
|
145
|
+
# Async
|
146
|
+
models = await client.list_models()
|
147
|
+
response = await client.generate(AiRequest(messages=[...], stream=False))
|
148
|
+
async for chunk in await client.generate(AiRequest(messages=[...], stream=True)):
|
149
|
+
print(chunk)
|
150
|
+
```
|
151
|
+
|
152
|
+
#### API Token Operations
|
153
|
+
```python
|
154
|
+
# Sync
|
155
|
+
token = client.create_api_token(ApiTokenRequest(description="My Token"))
|
156
|
+
tokens = client.list_api_tokens()
|
157
|
+
client.delete_api_token("token-to-delete")
|
158
|
+
|
159
|
+
# Async
|
160
|
+
token = await client.create_api_token(ApiTokenRequest(description="My Token"))
|
161
|
+
tokens = await client.list_api_tokens()
|
162
|
+
await client.delete_api_token("token-to-delete")
|
163
|
+
```
|
164
|
+
|
165
|
+
#### Credit Operations
|
166
|
+
```python
|
167
|
+
# Sync
|
168
|
+
credits = client.get_user_credits()
|
169
|
+
history = client.get_credits_history()
|
170
|
+
|
171
|
+
# Async
|
172
|
+
credits = await client.get_user_credits()
|
173
|
+
history = await client.get_credits_history()
|
174
|
+
```
|
175
|
+
|
176
|
+
## License
|
177
|
+
|
178
|
+
MIT License
|
@@ -0,0 +1,8 @@
|
|
1
|
+
mira_network-0.1.4.dist-info/METADATA,sha256=l_M7hizI6V3qfd94wTFRb9tViHhN62_7Ze4QOGy6i_Y,5026
|
2
|
+
mira_network-0.1.4.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
mira_network-0.1.4.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
|
+
mira_network/__init__.py,sha256=82x6bhP9_ZhHaBkW-O10F4ADipp1crGQzTaxQ878buA,272
|
5
|
+
mira_network/client.py,sha256=_Fj4g20CSyzqHnDHhn43TunFLLub_n2Ix3cBAwa7spU,5739
|
6
|
+
mira_network/models.py,sha256=aEJiDHEDFIAQMB-C8ZFY5ruRNGJ-U2Cz9vS5nF7GqVg,1805
|
7
|
+
mira_network/sync_client.py,sha256=0f_oakroMp-OYC-WRvNRcWnQW9YtUdQRdVxKNeNbMUA,3400
|
8
|
+
mira_network-0.1.4.dist-info/RECORD,,
|
@@ -1,108 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: mira-network
|
3
|
-
Version: 0.1.3
|
4
|
-
Summary: Python SDK for Mira Network API
|
5
|
-
Author-Email: sarim2000 <sarimbleedblue@gmail.com>
|
6
|
-
License: MIT
|
7
|
-
Requires-Python: ==3.10.*
|
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
|
-
Description-Content-Type: text/markdown
|
14
|
-
|
15
|
-
# Mira Network SDK
|
16
|
-
|
17
|
-
A Python SDK for interacting with the Mira Network API. This SDK provides a simple interface to access all Mira API endpoints including model inference, flow management, and credit system.
|
18
|
-
|
19
|
-
## Installation
|
20
|
-
|
21
|
-
```bash
|
22
|
-
pip install mira-network
|
23
|
-
```
|
24
|
-
|
25
|
-
## Quick Start
|
26
|
-
|
27
|
-
```python
|
28
|
-
import asyncio
|
29
|
-
from mira_sdk import MiraClient, Message, AiRequest
|
30
|
-
|
31
|
-
async def main():
|
32
|
-
# Initialize client
|
33
|
-
client = MiraClient(
|
34
|
-
base_url="https://api.mira.example.com",
|
35
|
-
api_token="your-api-token"
|
36
|
-
)
|
37
|
-
|
38
|
-
# List available models
|
39
|
-
models = await client.list_models()
|
40
|
-
print("Available models:", models)
|
41
|
-
|
42
|
-
# Generate text
|
43
|
-
request = AiRequest(
|
44
|
-
model="gpt-4o",
|
45
|
-
messages=[
|
46
|
-
Message(role="system", content="You are a helpful assistant."),
|
47
|
-
Message(role="user", content="Hello!")
|
48
|
-
],
|
49
|
-
model_provider=None
|
50
|
-
)
|
51
|
-
|
52
|
-
response = await client.generate(request)
|
53
|
-
print("Response:", response)
|
54
|
-
|
55
|
-
if __name__ == "__main__":
|
56
|
-
asyncio.run(main())
|
57
|
-
```
|
58
|
-
|
59
|
-
## Features
|
60
|
-
|
61
|
-
- Asynchronous API using `httpx`
|
62
|
-
- Full type hints support
|
63
|
-
- Pydantic models for request/response validation
|
64
|
-
- Support for all Mira API endpoints:
|
65
|
-
- Model inference
|
66
|
-
- Flow management
|
67
|
-
- API token management
|
68
|
-
- Credit system
|
69
|
-
|
70
|
-
## API Reference
|
71
|
-
|
72
|
-
### Models
|
73
|
-
|
74
|
-
- `Message`: Represents a chat message
|
75
|
-
- `ModelProvider`: Configuration for custom model providers
|
76
|
-
- `AiRequest`: Request for model inference
|
77
|
-
- `FlowChatCompletion`: Request for flow-based chat completion
|
78
|
-
- `FlowRequest`: Request for creating/updating flows
|
79
|
-
- `ApiTokenRequest`: Request for creating API tokens
|
80
|
-
- `AddCreditRequest`: Request for adding credits
|
81
|
-
|
82
|
-
### Client Methods
|
83
|
-
|
84
|
-
#### Model Operations
|
85
|
-
- `list_models()`: List available models
|
86
|
-
- `generate(request: AiRequest)`: Generate text using specified model
|
87
|
-
|
88
|
-
#### Flow Operations
|
89
|
-
- `list_flows()`: List all flows
|
90
|
-
- `get_flow(flow_id: str)`: Get flow details
|
91
|
-
- `create_flow(request: FlowRequest)`: Create new flow
|
92
|
-
- `update_flow(flow_id: str, request: FlowRequest)`: Update flow
|
93
|
-
- `delete_flow(flow_id: str)`: Delete flow
|
94
|
-
- `generate_with_flow(flow_id: str, request: FlowChatCompletion)`: Generate using flow
|
95
|
-
|
96
|
-
#### Token Operations
|
97
|
-
- `create_api_token(request: ApiTokenRequest)`: Create API token
|
98
|
-
- `list_api_tokens()`: List API tokens
|
99
|
-
- `delete_api_token(token: str)`: Delete API token
|
100
|
-
|
101
|
-
#### Credit Operations
|
102
|
-
- `get_user_credits()`: Get credit information
|
103
|
-
- `add_credit(request: AddCreditRequest)`: Add credits
|
104
|
-
- `get_credits_history()`: Get credit history
|
105
|
-
|
106
|
-
## License
|
107
|
-
|
108
|
-
MIT License
|
@@ -1,7 +0,0 @@
|
|
1
|
-
mira_network-0.1.3.dist-info/METADATA,sha256=Bii_N1AYNnH5H8qjsfMVC8CEsaoqjva_x7ZGtRuWLfI,2941
|
2
|
-
mira_network-0.1.3.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
-
mira_network-0.1.3.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
|
-
mira_sdk/__init__.py,sha256=KVFj7e20pprJuOWCG9Ky_w2JqKBu8TFPCilPDKRhkyI,364
|
5
|
-
mira_sdk/client.py,sha256=35g97GTbcTMojCn6Jh0RK7cEZ3ahYjoS5PiuCgZr8LU,5703
|
6
|
-
mira_sdk/models.py,sha256=FQfxjK_Cs7Nt0dB1qYHd7rov3VJSVr6rNAqZqOarU48,1749
|
7
|
-
mira_network-0.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|