lollms-client 0.11.0__py3-none-any.whl → 0.12.1__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.

Potentially problematic release.


This version of lollms-client might be problematic. Click here for more details.

@@ -0,0 +1,145 @@
1
+ # lollms_client/tts_bindings/lollms/__init__.py
2
+ import requests
3
+ from lollms_client.lollms_tts_binding import LollmsTTSBinding
4
+ from typing import Optional, List
5
+ from ascii_colors import trace_exception, ASCIIColors
6
+ import json
7
+
8
+ # Defines the binding name for the manager
9
+ BindingName = "LollmsTTSBinding_Impl"
10
+
11
+ class LollmsTTSBinding_Impl(LollmsTTSBinding):
12
+ """Concrete implementation of the LollmsTTSBinding for the standard LOLLMS server."""
13
+
14
+ def __init__(self,
15
+ host_address: Optional[str] = "http://localhost:9600",
16
+ model_name: Optional[str] = "main_voice",
17
+ service_key: Optional[str] = None, # This will be used as client_id
18
+ verify_ssl_certificate: bool = True):
19
+ """
20
+ Initialize the LOLLMS TTS binding.
21
+
22
+ Args:
23
+ host_address (Optional[str]): Host address for the LOLLMS service.
24
+ model_name (Optional[str]): Default voice/model name to use.
25
+ service_key (Optional[str]): Authentication key, used as client_id for LOLLMS server.
26
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
27
+ """
28
+ super().__init__(host_address=host_address,
29
+ model_name=model_name,
30
+ service_key=service_key, # Stored in the parent class
31
+ verify_ssl_certificate=verify_ssl_certificate)
32
+ # self.client_id = service_key # Can access via self.service_key from parent
33
+
34
+ def generate_audio(self, text: str, voice: Optional[str] = None, **kwargs) -> bytes:
35
+ """
36
+ Generates audio data from text using the LOLLMS /text2Audio endpoint.
37
+
38
+ Args:
39
+ text (str): The text content to synthesize.
40
+ voice (Optional[str]): The specific voice to use. If None, uses the default from init.
41
+ **kwargs: Accepts 'fn' (filename) for server-side saving,
42
+ and 'client_id' to override the instance's default client_id.
43
+
44
+ Returns:
45
+ bytes: Returns an empty bytes string as the server saves the file and returns status JSON.
46
+
47
+ Raises:
48
+ Exception: If the request fails or the server returns an error status.
49
+ ValueError: If client_id is not available.
50
+ """
51
+ endpoint = f"{self.host_address}/text2Audio"
52
+ voice_to_use = voice if voice else self.model_name
53
+ filename_on_server = kwargs.get("fn")
54
+
55
+ # Determine client_id: use from kwargs if provided, otherwise from instance's service_key
56
+ client_id_to_use = kwargs.get("client_id", self.service_key)
57
+ if not client_id_to_use:
58
+ # Fallback or raise error if client_id is strictly required by the server
59
+ # For /text2Audio, it is strictly required.
60
+ raise ValueError("client_id is required for text2Audio but was not provided during LollmsClient initialization (as service_key) or in this call.")
61
+
62
+
63
+ request_data = {
64
+ "client_id": client_id_to_use, # ADDED client_id
65
+ "text": text,
66
+ "voice": voice_to_use,
67
+ "fn": filename_on_server
68
+ }
69
+ # Filter out None values for 'voice' and 'fn' if the server doesn't expect them or handles defaults
70
+ # client_id and text are mandatory for the server model LollmsText2AudioRequest
71
+ if voice_to_use is None:
72
+ del request_data["voice"]
73
+ if filename_on_server is None:
74
+ del request_data["fn"]
75
+
76
+
77
+ headers = {'Content-Type': 'application/json'}
78
+ # service_key (if different from client_id for auth header) isn't used by this endpoint's auth
79
+ # The check_access on server side uses the client_id from the payload.
80
+
81
+ try:
82
+ ASCIIColors.debug(f"Sending TTS request to {endpoint} with payload: {request_data}")
83
+ response = requests.post(endpoint, json=request_data, headers=headers, verify=self.verify_ssl_certificate)
84
+ response.raise_for_status()
85
+
86
+ response_json = response.json()
87
+ if response_json.get("status") is False or "error" in response_json: # Check for explicit error
88
+ raise Exception(f"Server returned error: {response_json.get('error', 'Unknown error')}")
89
+
90
+ ASCIIColors.info(f"Audio generation requested. Server response: {response_json}")
91
+ return b""
92
+
93
+ except requests.exceptions.HTTPError as e:
94
+ # Log the response content for 422 errors specifically
95
+ if e.response is not None and e.response.status_code == 422:
96
+ try:
97
+ error_details = e.response.json()
98
+ ASCIIColors.error(f"Unprocessable Entity. Server details: {error_details}")
99
+ except json.JSONDecodeError:
100
+ ASCIIColors.error(f"Unprocessable Entity. Server response: {e.response.text}")
101
+ trace_exception(e)
102
+ raise Exception(f"HTTP request failed: {e}") from e # Re-raise the original HTTPError
103
+ except requests.exceptions.RequestException as e:
104
+ trace_exception(e)
105
+ raise Exception(f"HTTP request connection failed: {e}") from e
106
+ except Exception as e:
107
+ trace_exception(e)
108
+ raise Exception(f"Audio generation failed: {e}") from e
109
+
110
+
111
+ def list_voices(self, **kwargs) -> List[str]:
112
+ """
113
+ Lists the available voices using the LOLLMS /list_voices endpoint.
114
+ This endpoint does not require client_id in the request body based on server code.
115
+
116
+ Args:
117
+ **kwargs: Additional parameters (currently unused).
118
+
119
+ Returns:
120
+ List[str]: A list of available voice identifiers. Returns ["main_voice"] on failure.
121
+ """
122
+ endpoint = f"{self.host_address}/list_voices"
123
+ headers = {'Content-Type': 'application/json'}
124
+ # No client_id needed in payload for this specific GET endpoint on the server
125
+
126
+ try:
127
+ response = requests.get(endpoint, headers=headers, verify=self.verify_ssl_certificate)
128
+ response.raise_for_status()
129
+ voices_data = response.json()
130
+ if "error" in voices_data or voices_data.get("status") is False:
131
+ ASCIIColors.error(f"Error listing voices from server: {voices_data.get('error', 'Unknown server error')}")
132
+ return ["main_voice"]
133
+ return voices_data.get("voices", ["main_voice"])
134
+ except requests.exceptions.RequestException as e:
135
+ ASCIIColors.error(f"Couldn't list voices due to connection error: {e}")
136
+ trace_exception(e)
137
+ return ["main_voice"]
138
+ except json.JSONDecodeError as e:
139
+ ASCIIColors.error(f"Couldn't parse voices response from server: {e}")
140
+ trace_exception(e)
141
+ return ["main_voice"]
142
+ except Exception as e:
143
+ ASCIIColors.error(f"An unexpected error occurred while listing voices: {e}")
144
+ trace_exception(e)
145
+ return ["main_voice"]
@@ -0,0 +1,73 @@
1
+ # lollms_client/ttv_bindings/lollms/__init__.py
2
+ import requests
3
+ from lollms_client.lollms_ttv_binding import LollmsTTVBinding
4
+ from typing import Optional, List
5
+ from ascii_colors import trace_exception, ASCIIColors
6
+
7
+ # Defines the binding name for the manager
8
+ BindingName = "LollmsTTVBinding_Impl"
9
+
10
+ class LollmsTTVBinding_Impl(LollmsTTVBinding):
11
+ """Concrete implementation of the LollmsTTVBinding for the standard LOLLMS server (Placeholder)."""
12
+
13
+ def __init__(self,
14
+ host_address: Optional[str] = "http://localhost:9600", # Default LOLLMS host
15
+ model_name: Optional[str] = None, # Default model (server decides if None)
16
+ service_key: Optional[str] = None,
17
+ verify_ssl_certificate: bool = True):
18
+ """
19
+ Initialize the LOLLMS TTV binding.
20
+
21
+ Args:
22
+ host_address (Optional[str]): Host address for the LOLLMS service.
23
+ model_name (Optional[str]): Default TTV model identifier.
24
+ service_key (Optional[str]): Authentication key.
25
+ verify_ssl_certificate (bool): Whether to verify SSL certificates.
26
+ """
27
+ super().__init__(host_address=host_address,
28
+ model_name=model_name,
29
+ service_key=service_key,
30
+ verify_ssl_certificate=verify_ssl_certificate)
31
+ ASCIIColors.warning("LOLLMS TTV binding is not yet fully implemented in the client.")
32
+ ASCIIColors.warning("Please ensure your LOLLMS server has a TTV service running.")
33
+
34
+
35
+ def generate_video(self, prompt: str, **kwargs) -> bytes:
36
+ """
37
+ Generates video data using an assumed LOLLMS /generate_video endpoint. (Not Implemented)
38
+
39
+ Args:
40
+ prompt (str): The text prompt describing the desired video.
41
+ **kwargs: Additional parameters (e.g., duration, fps).
42
+
43
+ Returns:
44
+ bytes: Placeholder empty bytes.
45
+
46
+ Raises:
47
+ NotImplementedError: This method is not yet implemented.
48
+ """
49
+ # endpoint = f"{self.host_address}/generate_video" # Assumed endpoint
50
+ # request_data = {"prompt": prompt, **kwargs}
51
+ # headers = {'Content-Type': 'application/json'}
52
+ # ... make request ...
53
+ # return response.content # Assuming direct bytes response
54
+ raise NotImplementedError("LOLLMS TTV generate_video client binding is not implemented yet.")
55
+
56
+
57
+ def list_models(self, **kwargs) -> List[str]:
58
+ """
59
+ Lists available TTV models using an assumed LOLLMS /list_ttv_models endpoint. (Not Implemented)
60
+
61
+ Args:
62
+ **kwargs: Additional parameters.
63
+
64
+ Returns:
65
+ List[str]: Placeholder empty list.
66
+
67
+ Raises:
68
+ NotImplementedError: This method is not yet implemented.
69
+ """
70
+ # endpoint = f"{self.host_address}/list_ttv_models" # Assumed endpoint
71
+ # ... make request ...
72
+ # return response.json().get("models", [])
73
+ raise NotImplementedError("LOLLMS TTV list_models client binding is not implemented yet.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lollms_client
3
- Version: 0.11.0
3
+ Version: 0.12.1
4
4
  Summary: A client library for LoLLMs generate endpoint
5
5
  Home-page: https://github.com/ParisNeo/lollms_client
6
6
  Author: ParisNeo
@@ -0,0 +1,41 @@
1
+ lollms_client/__init__.py,sha256=CrU6LzlhPyYQOMDgkw8Dqb3nvWYyZk0HixGF0QyTOWc,501
2
+ lollms_client/lollms_config.py,sha256=goEseDwDxYJf3WkYJ4IrLXwg3Tfw73CXV2Avg45M_hE,21876
3
+ lollms_client/lollms_core.py,sha256=NYUmzYxxMAPyy8OQ5fnPSerzM5IEYxhz598zZdA6Qrg,77772
4
+ lollms_client/lollms_discussion.py,sha256=9b83m0D894jwpgssWYTQHbVxp1gJoI-J947Ui_dRXII,2073
5
+ lollms_client/lollms_functions.py,sha256=p8SFtmEPqvVCsIz2fZ5HxyOHaxjrAo5c12uTzJnb6m8,3594
6
+ lollms_client/lollms_js_analyzer.py,sha256=01zUvuO2F_lnUe_0NLxe1MF5aHE1hO8RZi48mNPv-aw,8361
7
+ lollms_client/lollms_llm_binding.py,sha256=3oyj2GF7x27bCQxM8D1ZkKiEfGKFp0E_Bv5bH_meTMk,8331
8
+ lollms_client/lollms_personality.py,sha256=gTOU7WJrxyNE88g-9-is5QxMf84s6xbEMAv--SD2P64,20313
9
+ lollms_client/lollms_personality_worker.py,sha256=rQbZg9Gn-R3b6x0Ryb4JPWJzBfn4fObDzj5IWYez_9o,65331
10
+ lollms_client/lollms_python_analyzer.py,sha256=7gf1fdYgXCOkPUkBAPNmr6S-66hMH4_KonOMsADASxc,10246
11
+ lollms_client/lollms_stt.py,sha256=4knP8SSj2S7DAFGXpIHc-_J6pb9xjExutEBd0RNex5E,1282
12
+ lollms_client/lollms_stt_binding.py,sha256=ovmpFF0fnmPC9VNi1-rxAJA8xI4JZDUBh_YwdtoTx28,5818
13
+ lollms_client/lollms_tasks.py,sha256=Tgqces03gPTHFJCcPaeN9vBCsil3SSJX7nQAjCQ2-yg,34393
14
+ lollms_client/lollms_tti.py,sha256=WznZ5ADhig-SFNmwlgviLZaAfl67NVqnZxYzhel3vxU,1287
15
+ lollms_client/lollms_tti_binding.py,sha256=CBCdXt6GQzRPzq7eEujQ5mBOoYcqUUdYY-POHLbJhx8,7469
16
+ lollms_client/lollms_ttm_binding.py,sha256=ymGvHtFqesm32y1ZoyIgMBC1PckTABS-DOh-8SvMkRs,5706
17
+ lollms_client/lollms_tts.py,sha256=KjFNkRmpM4kZpHm-IrPoYr4kPs2nOHNKPov0HXiinkg,1468
18
+ lollms_client/lollms_tts_binding.py,sha256=c4PQVe6NyPUtNguKMPo5L2nHJXjoIEQpCtVLK06p_iA,5880
19
+ lollms_client/lollms_ttv_binding.py,sha256=u-gLIe22tbu4YsKA5RTyUT7iBlKxPXDmoQzccG3_KuA,5672
20
+ lollms_client/lollms_types.py,sha256=cfc1sremM8KR4avkYX99fIVkkdRvXErrCWKGjLrgv50,2723
21
+ lollms_client/lollms_utilities.py,sha256=YAgamfp0pBVApR68AHKjhp1lh6isMNF8iadwWLl63c0,7045
22
+ lollms_client/llm_bindings/__init__.py,sha256=9sWGpmWSSj6KQ8H4lKGCjpLYwhnVdL_2N7gXCphPqh4,14
23
+ lollms_client/llm_bindings/lollms/__init__.py,sha256=PRQwXOdqR_nWMvxwcL2u-32YBPDrSdQZRUxkbz3-bBk,11911
24
+ lollms_client/llm_bindings/ollama/__init__.py,sha256=7xZpoRQNptTPlHY9o5BD0xH2yR-b3FcT8wfv-SOWS9Q,12534
25
+ lollms_client/llm_bindings/openai/__init__.py,sha256=8VbJ9EF30w0gTlc9e7gzvTxBfWl0mjNBGlHqUoqQ2eg,10463
26
+ lollms_client/llm_bindings/transformers/__init__.py,sha256=vSzg5OWpiFPPP3GzEfoOs9K7Q0B1n6zCi3-j4M9tkWE,12467
27
+ lollms_client/stt_bindings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
+ lollms_client/stt_bindings/lollms/__init__.py,sha256=7-IZkrsn15Vaz0oqkqCxMeNQfMkeilbgScLlrrywES4,6098
29
+ lollms_client/tti_bindings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ lollms_client/tti_bindings/lollms/__init__.py,sha256=y1mcAsaYnWUVEw1Wq3Gxur4srwKDWu2IKRgwtsSPifY,9082
31
+ lollms_client/ttm_bindings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
+ lollms_client/ttm_bindings/lollms/__init__.py,sha256=DU3WLmJaWNM1NAMtJsnaFo4Y9wlfc675M8aUiaLnojA,3143
33
+ lollms_client/tts_bindings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
+ lollms_client/tts_bindings/lollms/__init__.py,sha256=8x2_T9XscvISw2TiaLoFxvrS7TIsVLdqbwSc04cX-wc,7164
35
+ lollms_client/ttv_bindings/__init__.py,sha256=UZ8o2izQOJLQgtZ1D1cXoNST7rzqW22rL2Vufc7ddRc,3141
36
+ lollms_client/ttv_bindings/lollms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ lollms_client-0.12.1.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
38
+ lollms_client-0.12.1.dist-info/METADATA,sha256=KSlyF6abPll_F4-vU03grmQSpt5yTkW6tnOVD93HbG0,6866
39
+ lollms_client-0.12.1.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
40
+ lollms_client-0.12.1.dist-info/top_level.txt,sha256=Bk_kz-ri6Arwsk7YG-T5VsRorV66uVhcHGvb_g2WqgE,14
41
+ lollms_client-0.12.1.dist-info/RECORD,,
@@ -1,34 +0,0 @@
1
- lollms_client/__init__.py,sha256=tBrrYsu4fpi8ZR5ZzTjY88O0UMv9_tqG--VXGQxK2UU,493
2
- lollms_client/lollms_config.py,sha256=goEseDwDxYJf3WkYJ4IrLXwg3Tfw73CXV2Avg45M_hE,21876
3
- lollms_client/lollms_core.py,sha256=EX9G-2hhJNO5kL9DXY_zAvg_R7R_M6IgocXNAd-6-SA,50542
4
- lollms_client/lollms_discussion.py,sha256=9b83m0D894jwpgssWYTQHbVxp1gJoI-J947Ui_dRXII,2073
5
- lollms_client/lollms_functions.py,sha256=p8SFtmEPqvVCsIz2fZ5HxyOHaxjrAo5c12uTzJnb6m8,3594
6
- lollms_client/lollms_js_analyzer.py,sha256=01zUvuO2F_lnUe_0NLxe1MF5aHE1hO8RZi48mNPv-aw,8361
7
- lollms_client/lollms_llm_binding.py,sha256=aegUdAz_3DwJ1nDmq6lxD6x1bI4c4jVa6IbgdAVyaFE,8233
8
- lollms_client/lollms_personality.py,sha256=gTOU7WJrxyNE88g-9-is5QxMf84s6xbEMAv--SD2P64,20313
9
- lollms_client/lollms_personality_worker.py,sha256=rQbZg9Gn-R3b6x0Ryb4JPWJzBfn4fObDzj5IWYez_9o,65331
10
- lollms_client/lollms_python_analyzer.py,sha256=7gf1fdYgXCOkPUkBAPNmr6S-66hMH4_KonOMsADASxc,10246
11
- lollms_client/lollms_stt.py,sha256=4knP8SSj2S7DAFGXpIHc-_J6pb9xjExutEBd0RNex5E,1282
12
- lollms_client/lollms_tasks.py,sha256=Ur-Aaqr3Tm9htlRAI16NKwaVAGkY-_SENhUEikikZwA,34458
13
- lollms_client/lollms_tti.py,sha256=WznZ5ADhig-SFNmwlgviLZaAfl67NVqnZxYzhel3vxU,1287
14
- lollms_client/lollms_tts.py,sha256=KjFNkRmpM4kZpHm-IrPoYr4kPs2nOHNKPov0HXiinkg,1468
15
- lollms_client/lollms_types.py,sha256=cfc1sremM8KR4avkYX99fIVkkdRvXErrCWKGjLrgv50,2723
16
- lollms_client/lollms_utilities.py,sha256=YAgamfp0pBVApR68AHKjhp1lh6isMNF8iadwWLl63c0,7045
17
- lollms_client/llm_bindings/__init__.py,sha256=9sWGpmWSSj6KQ8H4lKGCjpLYwhnVdL_2N7gXCphPqh4,14
18
- lollms_client/llm_bindings/lollms/__init__.py,sha256=lyqvXtIM3CDzY9RrgpxnLdnCknBIR1eYzJ20tqAWsvo,11873
19
- lollms_client/llm_bindings/ollama/__init__.py,sha256=KLLRmcs9OtGW_H-50kkzKz0e25jKEDh1SkLrb2rvD-4,12496
20
- lollms_client/llm_bindings/openai/__init__.py,sha256=4JaiqJc3Zszc2T0XQFQBBwI3p5VqZlamLLgangUrHiY,10423
21
- lollms_client/llm_bindings/transformers/__init__.py,sha256=-tEenmutc5iGoa9kgPBEC998EiQBX7BH6oxMonCmlf8,12423
22
- lollms_client/stt_bindings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- lollms_client/stt_bindings/lollms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- lollms_client/tti_bindings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- lollms_client/tti_bindings/lollms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- lollms_client/tts_bindings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- lollms_client/tts_bindings/lollms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- lollms_client/ttv_bindings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- lollms_client/ttv_bindings/lollms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- lollms_client-0.11.0.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
31
- lollms_client-0.11.0.dist-info/METADATA,sha256=6MmwdbFZydsbJywBslDtbHg7lc2ZA7Tmdi3n-R7QdtQ,6866
32
- lollms_client-0.11.0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
33
- lollms_client-0.11.0.dist-info/top_level.txt,sha256=Bk_kz-ri6Arwsk7YG-T5VsRorV66uVhcHGvb_g2WqgE,14
34
- lollms_client-0.11.0.dist-info/RECORD,,