SynteriaAI-api 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,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: SynteriaAI-api
3
+ Version: 0.1.0
4
+ Summary: Official SynteriaAI Python SDK
5
+ Author: Novisek777
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: requests
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: SynteriaAI-api
3
+ Version: 0.1.0
4
+ Summary: Official SynteriaAI Python SDK
5
+ Author: Novisek777
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: requests
@@ -0,0 +1,9 @@
1
+ pyproject.toml
2
+ SynteriaAI_api.egg-info/PKG-INFO
3
+ SynteriaAI_api.egg-info/SOURCES.txt
4
+ SynteriaAI_api.egg-info/dependency_links.txt
5
+ SynteriaAI_api.egg-info/requires.txt
6
+ SynteriaAI_api.egg-info/top_level.txt
7
+ synteriaai_api/__init__.py
8
+ synteriaai_api/chat.py
9
+ synteriaai_api/client.py
@@ -0,0 +1 @@
1
+ synteriaai_api
@@ -0,0 +1,15 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "SynteriaAI-api"
7
+ version = "0.1.0"
8
+ description = "Official SynteriaAI Python SDK"
9
+ authors = [
10
+ { name = "Novisek777" }
11
+ ]
12
+ requires-python = ">=3.8"
13
+ dependencies = [
14
+ "requests"
15
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .client import SynteriaAI
2
+
3
+ __all__ = ["SynteriaAI"]
@@ -0,0 +1,92 @@
1
+ import requests
2
+
3
+ class ChatCompletions:
4
+ def __init__(self, client):
5
+ self._client = client
6
+
7
+ def create(self, messages: list, model: str = "synteria-1", pretty: bool = False):
8
+ url = f"{self._client.base_url}/v1/chat/completions.php"
9
+
10
+ payload = {
11
+ "api_key": self._client.api_key,
12
+ "messages": messages,
13
+ "model": model
14
+ }
15
+
16
+ try:
17
+ response = requests.post(url, json=payload, timeout=120)
18
+ except requests.exceptions.RequestException as e:
19
+ raise Exception(f"❌ Błąd połączenia z API: {e}")
20
+
21
+ if response.status_code != 200:
22
+ raise Exception(f"API Error {response.status_code}: {response.text}")
23
+
24
+ data = response.json()
25
+
26
+ # Obsługa openrouter_response jeśli istnieje
27
+ if "openrouter_response" in data:
28
+ data = data["openrouter_response"]
29
+
30
+ # Usuń reasoning i reasoning_details
31
+ for choice in data.get("choices", []):
32
+ message = choice.get("message", {})
33
+ message.pop("reasoning", None)
34
+ message.pop("reasoning_details", None)
35
+
36
+ if pretty:
37
+ self._pretty_print(data)
38
+
39
+ return data
40
+
41
+ # ===============================
42
+ # CLEAN RESPONSE
43
+ # ===============================
44
+ def _clean_content(self, content: str) -> str:
45
+ lines = content.splitlines()
46
+ cleaned = []
47
+ for line in lines:
48
+ # Pomijamy tłumaczenia i komentarze w nawiasach
49
+ if "translation" in line.lower():
50
+ continue
51
+ if line.strip().startswith("("):
52
+ continue
53
+ # Zamieniamy podwójne spacje na pojedyncze i przycinamy
54
+ cleaned.append(line.replace(" ", " ").strip())
55
+ return "\n".join(cleaned).strip()
56
+
57
+ # ===============================
58
+ # PRETTY PRINT Z FORMATOWANIEM MARKDOWN
59
+ # ===============================
60
+ def _pretty_print(self, data: dict):
61
+ choices = data.get("choices")
62
+ if not choices or len(choices) == 0:
63
+ print("❌ Brak odpowiedzi od API lub błędny format danych:")
64
+ print(data)
65
+ return
66
+
67
+ content = choices[0].get("message", {}).get("content", "")
68
+ content = self._clean_content(content)
69
+ model = data.get("model", "unknown")
70
+ tokens = data.get("usage", {}).get("total_tokens", "unknown")
71
+ masked_key = self._client.api_key[:6] + "****" + self._client.api_key[-4:]
72
+
73
+ print("\n==============================")
74
+ print("🔑 SynteriaAI Chat Response")
75
+ print("==============================")
76
+ print(f"API KEY 🔑 : {masked_key}")
77
+ print(f"Model 🤖 : {model}")
78
+ print(f"Tokens 📊 : {tokens}")
79
+ print("\n💬 Odpowiedź:\n")
80
+
81
+ for line in content.splitlines():
82
+ line = line.strip()
83
+ if line.startswith("**") and line.endswith("**"):
84
+ # Nagłówek pogrubiony
85
+ print(f"\033[1m{line}\033[0m")
86
+ elif line.startswith("*"):
87
+ # Lista z wcięciem
88
+ print(f" {line}")
89
+ else:
90
+ print(line)
91
+
92
+ print("==============================\n")
@@ -0,0 +1,14 @@
1
+ from .chat import ChatCompletions
2
+
3
+
4
+ class _Chat:
5
+ def __init__(self, client):
6
+ self.completions = ChatCompletions(client)
7
+
8
+
9
+ class SynteriaAI:
10
+ def __init__(self, api_key: str,
11
+ base_url: str = "http://site34802.web1.titanaxe.com"):
12
+ self.api_key = api_key
13
+ self.base_url = base_url
14
+ self.chat = _Chat(self)