brsxcloud 0.1.0__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,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: brsxcloud
3
+ Version: 0.1.0
4
+ Summary: BRSX-Cloud için resmi Python client — chat edilebilir modellere API key ile erişim
5
+ Author: BRSX Labs
6
+ License: MIT
7
+ Project-URL: Homepage, https://cloud.brsxlabs.com
8
+ Project-URL: Documentation, https://help.brsxlabs.com
9
+ Project-URL: Repository, https://brsxlabs.com
10
+ Keywords: brsx,brsx-cloud,ai,chat,api-client
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+
23
+ # brsxcloud
24
+
25
+ [BRSX-Cloud](https://cloud.brsxlabs.com) için resmi Python client. Chat edilebilir olarak paylaşılmış modellere kendi API key'inle, kod içinden erişmeni sağlar.
26
+
27
+ ## Kurulum
28
+
29
+ ```bash
30
+ pip install brsxcloud
31
+ ```
32
+
33
+ ## API Key Alma
34
+
35
+ 1. [cloud.brsxlabs.com](https://cloud.brsxlabs.com) adresinde giriş yap.
36
+ 2. Sol menüden **Kullanıcı Paneli**'ni aç.
37
+ 3. **API Anahtarların** bölümünden **+ Yeni Key** ile bir key oluştur.
38
+ 4. Key sadece o an gösterilir, hemen kopyala — bir daha görüntülenmez.
39
+
40
+ Her key için günlük istek limiti vardır (panelde görebilirsin).
41
+
42
+ ## Kullanım
43
+
44
+ ```python
45
+ from brsxcloud import Client
46
+
47
+ client = Client("brsxk_...") # kendi API key'in
48
+
49
+ reply = client.chat(model_id=1, message="Merhaba, nasılsın?")
50
+ print(reply)
51
+ ```
52
+
53
+ `model_id`'yi, BRSX-Cloud'daki **Modeller** sekmesinde ilgili modelin sayfasından ya da model sahibinin sana verdiği id'den öğrenebilirsin.
54
+
55
+ ## Hata Yönetimi
56
+
57
+ ```python
58
+ from brsxcloud import Client, BrsxCloudError
59
+
60
+ client = Client("brsxk_...")
61
+
62
+ try:
63
+ reply = client.chat(model_id=1, message="Selam")
64
+ except BrsxCloudError as e:
65
+ print(f"Hata: {e.message} (durum kodu: {e.status_code})")
66
+ ```
67
+
68
+ Olası hatalar: geçersiz/iptal edilmiş API key, günlük kota aşımı, model bulunamadı, model chat için paylaşılmamış, model çalıştırılırken hata.
69
+
70
+ ## Lisans
71
+
72
+ MIT
@@ -0,0 +1,50 @@
1
+ # brsxcloud
2
+
3
+ [BRSX-Cloud](https://cloud.brsxlabs.com) için resmi Python client. Chat edilebilir olarak paylaşılmış modellere kendi API key'inle, kod içinden erişmeni sağlar.
4
+
5
+ ## Kurulum
6
+
7
+ ```bash
8
+ pip install brsxcloud
9
+ ```
10
+
11
+ ## API Key Alma
12
+
13
+ 1. [cloud.brsxlabs.com](https://cloud.brsxlabs.com) adresinde giriş yap.
14
+ 2. Sol menüden **Kullanıcı Paneli**'ni aç.
15
+ 3. **API Anahtarların** bölümünden **+ Yeni Key** ile bir key oluştur.
16
+ 4. Key sadece o an gösterilir, hemen kopyala — bir daha görüntülenmez.
17
+
18
+ Her key için günlük istek limiti vardır (panelde görebilirsin).
19
+
20
+ ## Kullanım
21
+
22
+ ```python
23
+ from brsxcloud import Client
24
+
25
+ client = Client("brsxk_...") # kendi API key'in
26
+
27
+ reply = client.chat(model_id=1, message="Merhaba, nasılsın?")
28
+ print(reply)
29
+ ```
30
+
31
+ `model_id`'yi, BRSX-Cloud'daki **Modeller** sekmesinde ilgili modelin sayfasından ya da model sahibinin sana verdiği id'den öğrenebilirsin.
32
+
33
+ ## Hata Yönetimi
34
+
35
+ ```python
36
+ from brsxcloud import Client, BrsxCloudError
37
+
38
+ client = Client("brsxk_...")
39
+
40
+ try:
41
+ reply = client.chat(model_id=1, message="Selam")
42
+ except BrsxCloudError as e:
43
+ print(f"Hata: {e.message} (durum kodu: {e.status_code})")
44
+ ```
45
+
46
+ Olası hatalar: geçersiz/iptal edilmiş API key, günlük kota aşımı, model bulunamadı, model chat için paylaşılmamış, model çalıştırılırken hata.
47
+
48
+ ## Lisans
49
+
50
+ MIT
@@ -0,0 +1,113 @@
1
+ """
2
+ brsxcloud — BRSX-Cloud için resmi Python client.
3
+
4
+ Kurulum:
5
+ pip install brsxcloud
6
+
7
+ Kullanım:
8
+ from brsxcloud import Client
9
+
10
+ client = Client("brsxk_...") # panelden aldığın API key
11
+ reply = client.chat(model_id=1, message="Merhaba!")
12
+ print(reply)
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import json
18
+ import urllib.error
19
+ import urllib.request
20
+
21
+ __version__ = "0.1.0"
22
+ __all__ = ["Client", "BrsxCloudError"]
23
+
24
+ DEFAULT_BASE_URL = "https://cloud.brsxlabs.com"
25
+
26
+
27
+ class BrsxCloudError(Exception):
28
+ """BRSX-Cloud API'sinden dönen bir hata. `status_code` ve `message`
29
+ attribute'ları vardır — ör. kota aşımı, geçersiz key, model bulunamadı."""
30
+
31
+ def __init__(self, message: str, status_code: int | None = None):
32
+ super().__init__(message)
33
+ self.message = message
34
+ self.status_code = status_code
35
+
36
+ def __str__(self) -> str:
37
+ if self.status_code:
38
+ return f"[{self.status_code}] {self.message}"
39
+ return self.message
40
+
41
+
42
+ class Client:
43
+ """BRSX-Cloud API'sine bağlanan basit bir client.
44
+
45
+ Args:
46
+ api_key: Panelden ("Kullanıcı Paneli" > "API Anahtarların")
47
+ aldığın, `brsxk_` ile başlayan API key.
48
+ base_url: Genelde değiştirmene gerek yok, testler için var.
49
+ timeout: Saniye cinsinden istek zaman aşımı (varsayılan 60 —
50
+ model inference'ı CPU'da yavaş olabilir).
51
+ """
52
+
53
+ def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL, timeout: float = 60.0):
54
+ if not api_key or not api_key.startswith("brsxk_"):
55
+ raise ValueError(
56
+ "Geçersiz api_key — 'brsxk_' ile başlayan bir key gerekli. "
57
+ "Panelden (Kullanıcı Paneli > API Anahtarların) alabilirsin."
58
+ )
59
+ self.api_key = api_key
60
+ self.base_url = base_url.rstrip("/")
61
+ self.timeout = timeout
62
+
63
+ def chat(self, model_id: int, message: str) -> str:
64
+ """Chat edilebilir bir modele mesaj gönderir, cevabı döner.
65
+
66
+ Args:
67
+ model_id: BRSX-Cloud'daki model id'si (Modeller sekmesinde
68
+ bir modelin üzerine tıklayınca ya da API listesinden
69
+ görebilirsin).
70
+ message: Modele gönderilecek metin.
71
+
72
+ Returns:
73
+ Modelin ürettiği cevap (str).
74
+
75
+ Raises:
76
+ BrsxCloudError: Kota aşımı, geçersiz key, model bulunamadı,
77
+ model chat için paylaşılmamış, ya da model çalıştırılırken
78
+ hata oluşursa.
79
+ """
80
+ if not message or not message.strip():
81
+ raise ValueError("message boş olamaz.")
82
+
83
+ url = f"{self.base_url}/api/cloud/v1/chat/{model_id}"
84
+ body = json.dumps({"message": message}).encode("utf-8")
85
+
86
+ req = urllib.request.Request(
87
+ url,
88
+ data=body,
89
+ method="POST",
90
+ headers={
91
+ "Content-Type": "application/json",
92
+ "Authorization": f"Bearer {self.api_key}",
93
+ "User-Agent": f"brsxcloud-python/{__version__}",
94
+ },
95
+ )
96
+
97
+ try:
98
+ with urllib.request.urlopen(req, timeout=self.timeout) as resp:
99
+ data = json.loads(resp.read().decode("utf-8"))
100
+ except urllib.error.HTTPError as e:
101
+ try:
102
+ data = json.loads(e.read().decode("utf-8"))
103
+ message_text = data.get("error", str(e))
104
+ except (json.JSONDecodeError, UnicodeDecodeError):
105
+ message_text = str(e)
106
+ raise BrsxCloudError(message_text, status_code=e.code) from None
107
+ except urllib.error.URLError as e:
108
+ raise BrsxCloudError(f"Sunucuya ulaşılamadı: {e.reason}") from None
109
+
110
+ if not data.get("ok"):
111
+ raise BrsxCloudError(data.get("error", "Bilinmeyen hata."))
112
+
113
+ return data["reply"]
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: brsxcloud
3
+ Version: 0.1.0
4
+ Summary: BRSX-Cloud için resmi Python client — chat edilebilir modellere API key ile erişim
5
+ Author: BRSX Labs
6
+ License: MIT
7
+ Project-URL: Homepage, https://cloud.brsxlabs.com
8
+ Project-URL: Documentation, https://help.brsxlabs.com
9
+ Project-URL: Repository, https://brsxlabs.com
10
+ Keywords: brsx,brsx-cloud,ai,chat,api-client
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+
23
+ # brsxcloud
24
+
25
+ [BRSX-Cloud](https://cloud.brsxlabs.com) için resmi Python client. Chat edilebilir olarak paylaşılmış modellere kendi API key'inle, kod içinden erişmeni sağlar.
26
+
27
+ ## Kurulum
28
+
29
+ ```bash
30
+ pip install brsxcloud
31
+ ```
32
+
33
+ ## API Key Alma
34
+
35
+ 1. [cloud.brsxlabs.com](https://cloud.brsxlabs.com) adresinde giriş yap.
36
+ 2. Sol menüden **Kullanıcı Paneli**'ni aç.
37
+ 3. **API Anahtarların** bölümünden **+ Yeni Key** ile bir key oluştur.
38
+ 4. Key sadece o an gösterilir, hemen kopyala — bir daha görüntülenmez.
39
+
40
+ Her key için günlük istek limiti vardır (panelde görebilirsin).
41
+
42
+ ## Kullanım
43
+
44
+ ```python
45
+ from brsxcloud import Client
46
+
47
+ client = Client("brsxk_...") # kendi API key'in
48
+
49
+ reply = client.chat(model_id=1, message="Merhaba, nasılsın?")
50
+ print(reply)
51
+ ```
52
+
53
+ `model_id`'yi, BRSX-Cloud'daki **Modeller** sekmesinde ilgili modelin sayfasından ya da model sahibinin sana verdiği id'den öğrenebilirsin.
54
+
55
+ ## Hata Yönetimi
56
+
57
+ ```python
58
+ from brsxcloud import Client, BrsxCloudError
59
+
60
+ client = Client("brsxk_...")
61
+
62
+ try:
63
+ reply = client.chat(model_id=1, message="Selam")
64
+ except BrsxCloudError as e:
65
+ print(f"Hata: {e.message} (durum kodu: {e.status_code})")
66
+ ```
67
+
68
+ Olası hatalar: geçersiz/iptal edilmiş API key, günlük kota aşımı, model bulunamadı, model chat için paylaşılmamış, model çalıştırılırken hata.
69
+
70
+ ## Lisans
71
+
72
+ MIT
@@ -0,0 +1,7 @@
1
+ README.md
2
+ pyproject.toml
3
+ brsxcloud/__init__.py
4
+ brsxcloud.egg-info/PKG-INFO
5
+ brsxcloud.egg-info/SOURCES.txt
6
+ brsxcloud.egg-info/dependency_links.txt
7
+ brsxcloud.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ brsxcloud
@@ -0,0 +1,31 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "brsxcloud"
7
+ version = "0.1.0"
8
+ description = "BRSX-Cloud için resmi Python client — chat edilebilir modellere API key ile erişim"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "BRSX Labs" }
14
+ ]
15
+ keywords = ["brsx", "brsx-cloud", "ai", "chat", "api-client"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://cloud.brsxlabs.com"
30
+ Documentation = "https://help.brsxlabs.com"
31
+ Repository = "https://brsxlabs.com"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+