lemonade-python-sdk 1.0.3__tar.gz → 1.0.4__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.
Files changed (17) hide show
  1. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/PKG-INFO +20 -4
  2. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/README.md +17 -1
  3. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_python_sdk.egg-info/PKG-INFO +20 -4
  4. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_sdk/client.py +24 -4
  5. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/setup.py +3 -3
  6. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/LICENSE +0 -0
  7. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_python_sdk.egg-info/SOURCES.txt +0 -0
  8. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_python_sdk.egg-info/dependency_links.txt +0 -0
  9. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_python_sdk.egg-info/requires.txt +0 -0
  10. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_python_sdk.egg-info/top_level.txt +0 -0
  11. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_sdk/__init__.py +0 -0
  12. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_sdk/audio_stream.py +0 -0
  13. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_sdk/model_discovery.py +0 -0
  14. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_sdk/port_scanner.py +0 -0
  15. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_sdk/request_builder.py +0 -0
  16. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/lemonade_sdk/utils.py +0 -0
  17. {lemonade_python_sdk-1.0.3 → lemonade_python_sdk-1.0.4}/setup.cfg +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lemonade-python-sdk
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: A clean interface for interacting with the Lemonade LLM server
5
5
  Home-page: https://github.com/Tetramatrix/lemonade-python-sdk
6
- Author: Your Name
7
- Author-email: your.email@example.com
6
+ Author: Tetramatrix
7
+ Author-email: contact@tetramatrix.dev
8
8
  Project-URL: Bug Reports, https://github.com/Tetramatrix/lemonade-python-sdk/issues
9
9
  Project-URL: Source, https://github.com/Tetramatrix/lemonade-python-sdk
10
10
  Keywords: llm,ai,lemonade,sdk,api
@@ -52,7 +52,8 @@ This SDK provides a clean, pythonic interface for interacting with local LLMs ru
52
52
 
53
53
  * **Auto-Discovery:** Automatically scans multiple ports and hosts to find active Lemonade instances.
54
54
  * **Low-Overhead Architecture:** Designed as a thin, efficient wrapper to leverage Lemonade's C++ performance with minimal Python latency.
55
- * **Health Checks & Recovery:** Built-in utilities to verify server status and handle connection drops.
55
+ * **Health Checks & Stats:** Lightweight `/api/v1/health` endpoint for connectivity checks plus `get_stats()` for server performance metrics.
56
+ * **Server Statistics:** Retrieve token usage, requests served, and performance metrics via `get_stats()`.
56
57
  * **Type-Safe Client:** Full Python type hinting for better developer experience (IDE autocompletion).
57
58
  * **Model Management:** Simple API to load, unload, and list models dynamically.
58
59
  * **Embeddings API:** Generate text embeddings for semantic search, RAG, and clustering (FLM & llamacpp backends).
@@ -92,6 +93,21 @@ else:
92
93
  print("No Lemonade instance found.")
93
94
  ```
94
95
 
96
+ ### 1.1 Health Check & Stats
97
+
98
+ ```python
99
+ # Check if server is alive (uses /api/v1/health endpoint)
100
+ if client.health_check():
101
+ print("Lemonade is running!")
102
+
103
+ # Get server statistics
104
+ stats = client.get_stats()
105
+ if stats:
106
+ print(f"Tokens generated: {stats.get('total_tokens', 0)}")
107
+ print(f"Tokens/sec: {stats.get('tokens_per_second', 0):.1f}")
108
+ print(f"Requests served: {stats.get('requests_served', 0)}")
109
+ ```
110
+
95
111
  ### 2. Chat Completion
96
112
 
97
113
  ```python
@@ -11,7 +11,8 @@ This SDK provides a clean, pythonic interface for interacting with local LLMs ru
11
11
 
12
12
  * **Auto-Discovery:** Automatically scans multiple ports and hosts to find active Lemonade instances.
13
13
  * **Low-Overhead Architecture:** Designed as a thin, efficient wrapper to leverage Lemonade's C++ performance with minimal Python latency.
14
- * **Health Checks & Recovery:** Built-in utilities to verify server status and handle connection drops.
14
+ * **Health Checks & Stats:** Lightweight `/api/v1/health` endpoint for connectivity checks plus `get_stats()` for server performance metrics.
15
+ * **Server Statistics:** Retrieve token usage, requests served, and performance metrics via `get_stats()`.
15
16
  * **Type-Safe Client:** Full Python type hinting for better developer experience (IDE autocompletion).
16
17
  * **Model Management:** Simple API to load, unload, and list models dynamically.
17
18
  * **Embeddings API:** Generate text embeddings for semantic search, RAG, and clustering (FLM & llamacpp backends).
@@ -51,6 +52,21 @@ else:
51
52
  print("No Lemonade instance found.")
52
53
  ```
53
54
 
55
+ ### 1.1 Health Check & Stats
56
+
57
+ ```python
58
+ # Check if server is alive (uses /api/v1/health endpoint)
59
+ if client.health_check():
60
+ print("Lemonade is running!")
61
+
62
+ # Get server statistics
63
+ stats = client.get_stats()
64
+ if stats:
65
+ print(f"Tokens generated: {stats.get('total_tokens', 0)}")
66
+ print(f"Tokens/sec: {stats.get('tokens_per_second', 0):.1f}")
67
+ print(f"Requests served: {stats.get('requests_served', 0)}")
68
+ ```
69
+
54
70
  ### 2. Chat Completion
55
71
 
56
72
  ```python
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lemonade-python-sdk
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: A clean interface for interacting with the Lemonade LLM server
5
5
  Home-page: https://github.com/Tetramatrix/lemonade-python-sdk
6
- Author: Your Name
7
- Author-email: your.email@example.com
6
+ Author: Tetramatrix
7
+ Author-email: contact@tetramatrix.dev
8
8
  Project-URL: Bug Reports, https://github.com/Tetramatrix/lemonade-python-sdk/issues
9
9
  Project-URL: Source, https://github.com/Tetramatrix/lemonade-python-sdk
10
10
  Keywords: llm,ai,lemonade,sdk,api
@@ -52,7 +52,8 @@ This SDK provides a clean, pythonic interface for interacting with local LLMs ru
52
52
 
53
53
  * **Auto-Discovery:** Automatically scans multiple ports and hosts to find active Lemonade instances.
54
54
  * **Low-Overhead Architecture:** Designed as a thin, efficient wrapper to leverage Lemonade's C++ performance with minimal Python latency.
55
- * **Health Checks & Recovery:** Built-in utilities to verify server status and handle connection drops.
55
+ * **Health Checks & Stats:** Lightweight `/api/v1/health` endpoint for connectivity checks plus `get_stats()` for server performance metrics.
56
+ * **Server Statistics:** Retrieve token usage, requests served, and performance metrics via `get_stats()`.
56
57
  * **Type-Safe Client:** Full Python type hinting for better developer experience (IDE autocompletion).
57
58
  * **Model Management:** Simple API to load, unload, and list models dynamically.
58
59
  * **Embeddings API:** Generate text embeddings for semantic search, RAG, and clustering (FLM & llamacpp backends).
@@ -92,6 +93,21 @@ else:
92
93
  print("No Lemonade instance found.")
93
94
  ```
94
95
 
96
+ ### 1.1 Health Check & Stats
97
+
98
+ ```python
99
+ # Check if server is alive (uses /api/v1/health endpoint)
100
+ if client.health_check():
101
+ print("Lemonade is running!")
102
+
103
+ # Get server statistics
104
+ stats = client.get_stats()
105
+ if stats:
106
+ print(f"Tokens generated: {stats.get('total_tokens', 0)}")
107
+ print(f"Tokens/sec: {stats.get('tokens_per_second', 0):.1f}")
108
+ print(f"Requests served: {stats.get('requests_served', 0)}")
109
+ ```
110
+
95
111
  ### 2. Chat Completion
96
112
 
97
113
  ```python
@@ -79,11 +79,31 @@ class LemonadeClient:
79
79
  bool: True if the server is reachable, otherwise False
80
80
  """
81
81
  try:
82
- models = self.list_models()
83
- return len(models) >= 0 # If we don't get an error, the server is reachable
84
- except:
82
+ url = f"{self.base_url}/api/v1/health"
83
+ response = self.session.get(url, timeout=10)
84
+ return response.status_code == 200
85
+ except Exception:
85
86
  return False
86
-
87
+
88
+ def get_stats(self) -> Dict[str, Any]:
89
+ """
90
+ Retrieves server statistics including token usage, requests served, and performance metrics.
91
+
92
+ Returns:
93
+ Dict[str, Any]: Server stats with token counts, tokens_per_second, etc.
94
+ """
95
+ url = f"{self.base_url}/api/v1/stats"
96
+ try:
97
+ response = self.session.get(url, timeout=10)
98
+ response.raise_for_status()
99
+ return response.json()
100
+ except requests.exceptions.RequestException as e:
101
+ print(f"Error retrieving stats: {e}")
102
+ return {}
103
+ except json.JSONDecodeError as e:
104
+ print(f"Error parsing stats response: {e}")
105
+ return {}
106
+
87
107
  def get_current_model(self) -> Optional[str]:
88
108
  """
89
109
  Retrieves the currently active model from the Lemonade server.
@@ -13,9 +13,9 @@ with open("LICENSE", "r", encoding="utf-8") as fh:
13
13
 
14
14
  setup(
15
15
  name="lemonade-python-sdk",
16
- version="1.0.3",
17
- author="Your Name",
18
- author_email="your.email@example.com",
16
+ version="1.0.4",
17
+ author="Tetramatrix",
18
+ author_email="contact@tetramatrix.dev",
19
19
  description="A clean interface for interacting with the Lemonade LLM server",
20
20
  long_description=long_description,
21
21
  long_description_content_type="text/markdown",