djeli 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.
djeli-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: djeli
3
+ Version: 0.1.0
4
+ Summary: Python client for the djeli local LLM server
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: httpx>=0.27
9
+
10
+ # djeli
11
+
12
+ Python client for the djeli local LLM server.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install djeli
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```python
23
+ from djeli import Djeli
24
+
25
+ client = Djeli()
26
+ answer = client.chat(
27
+ model="qwen2.5-1.5b-instruct-q4_k_m",
28
+ messages=[{"role": "user", "content": "What is the capital of Kenya?"}],
29
+ )
30
+ print(answer)
31
+ ```
32
+
33
+ Requires a djeli serve process running on 127.0.0.1:11435.
34
+
35
+ ## API
36
+
37
+ . Djeli(base_url="http://127.0.0.1:11435", timeout=300.0)
38
+
39
+ . client.models() -> list[dict]
40
+
41
+ . client.chat(model, messages, temperature=0.7, max_tokens=1024, stream=False)
42
+
43
+ . DjeliError
44
+
45
+ ## License
46
+
47
+ ### MIT
48
+
djeli-0.1.0/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # djeli
2
+
3
+ Python client for the djeli local LLM server.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install djeli
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from djeli import Djeli
15
+
16
+ client = Djeli()
17
+ answer = client.chat(
18
+ model="qwen2.5-1.5b-instruct-q4_k_m",
19
+ messages=[{"role": "user", "content": "What is the capital of Kenya?"}],
20
+ )
21
+ print(answer)
22
+ ```
23
+
24
+ Requires a djeli serve process running on 127.0.0.1:11435.
25
+
26
+ ## API
27
+
28
+ . Djeli(base_url="http://127.0.0.1:11435", timeout=300.0)
29
+
30
+ . client.models() -> list[dict]
31
+
32
+ . client.chat(model, messages, temperature=0.7, max_tokens=1024, stream=False)
33
+
34
+ . DjeliError
35
+
36
+ ## License
37
+
38
+ ### MIT
39
+
@@ -0,0 +1,15 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "djeli"
7
+ version = "0.1.0"
8
+ description = "Python client for the djeli local LLM server"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ dependencies = ["httpx>=0.27"]
13
+
14
+ [tool.setuptools.packages.find]
15
+ where = ["src"]
djeli-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ from .client import Djeli, DjeliError
2
+ __all__ = ["Djeli", "DjeliError"]
@@ -0,0 +1,70 @@
1
+ import json
2
+ from typing import Iterator
3
+
4
+ import httpx
5
+
6
+ DEFAULT_BASE = "http://127.0.0.1:11435"
7
+
8
+
9
+ class DjeliError(Exception):
10
+ pass
11
+
12
+
13
+ class Djeli:
14
+ def __init__(self, base_url: str = DEFAULT_BASE, timeout: float = 300.0):
15
+ self.base_url = base_url.rstrip("/")
16
+ self.timeout = timeout
17
+
18
+ def models(self) -> list[dict]:
19
+ r = httpx.get(f"{self.base_url}/v1/models", timeout=10.0)
20
+ r.raise_for_status()
21
+ return r.json().get("data", [])
22
+
23
+ def chat(
24
+ self,
25
+ model: str,
26
+ messages: list[dict],
27
+ temperature: float = 0.7,
28
+ max_tokens: int = 1024,
29
+ stream: bool = False,
30
+ ):
31
+ payload = {
32
+ "model": model,
33
+ "messages": messages,
34
+ "temperature": temperature,
35
+ "max_tokens": max_tokens,
36
+ "stream": stream,
37
+ }
38
+ if not stream:
39
+ r = httpx.post(
40
+ f"{self.base_url}/v1/chat/completions",
41
+ json=payload,
42
+ timeout=self.timeout,
43
+ )
44
+ if r.status_code >= 400:
45
+ raise DjeliError(r.text)
46
+ return r.json()["choices"][0]["message"]["content"]
47
+ return self._stream(payload)
48
+
49
+ def _stream(self, payload: dict) -> Iterator[str]:
50
+ with httpx.stream(
51
+ "POST",
52
+ f"{self.base_url}/v1/chat/completions",
53
+ json=payload,
54
+ timeout=self.timeout,
55
+ ) as r:
56
+ if r.status_code >= 400:
57
+ raise DjeliError(r.read().decode())
58
+ for line in r.iter_lines():
59
+ if not line.startswith("data:"):
60
+ continue
61
+ data = line[5:].strip()
62
+ if data == "[DONE]" or not data:
63
+ continue
64
+ try:
65
+ chunk = json.loads(data)
66
+ content = chunk["choices"][0].get("delta", {}).get("content", "")
67
+ if content:
68
+ yield content
69
+ except (json.JSONDecodeError, KeyError, IndexError):
70
+ continue
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: djeli
3
+ Version: 0.1.0
4
+ Summary: Python client for the djeli local LLM server
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: httpx>=0.27
9
+
10
+ # djeli
11
+
12
+ Python client for the djeli local LLM server.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install djeli
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```python
23
+ from djeli import Djeli
24
+
25
+ client = Djeli()
26
+ answer = client.chat(
27
+ model="qwen2.5-1.5b-instruct-q4_k_m",
28
+ messages=[{"role": "user", "content": "What is the capital of Kenya?"}],
29
+ )
30
+ print(answer)
31
+ ```
32
+
33
+ Requires a djeli serve process running on 127.0.0.1:11435.
34
+
35
+ ## API
36
+
37
+ . Djeli(base_url="http://127.0.0.1:11435", timeout=300.0)
38
+
39
+ . client.models() -> list[dict]
40
+
41
+ . client.chat(model, messages, temperature=0.7, max_tokens=1024, stream=False)
42
+
43
+ . DjeliError
44
+
45
+ ## License
46
+
47
+ ### MIT
48
+
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/djeli/__init__.py
4
+ src/djeli/client.py
5
+ src/djeli.egg-info/PKG-INFO
6
+ src/djeli.egg-info/SOURCES.txt
7
+ src/djeli.egg-info/dependency_links.txt
8
+ src/djeli.egg-info/requires.txt
9
+ src/djeli.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ httpx>=0.27
@@ -0,0 +1 @@
1
+ djeli