lollms-client 0.13.1__tar.gz → 0.14.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.
Potentially problematic release.
This version of lollms-client might be problematic. Click here for more details.
- {lollms_client-0.13.1 → lollms_client-0.14.0}/PKG-INFO +1 -1
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/simple_text_gen_test.py +1 -1
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/text_gen.py +1 -1
- lollms_client-0.14.0/examples/text_gen_system_prompt.py +28 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/__init__.py +1 -1
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/lollms/__init__.py +2 -1
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/ollama/__init__.py +23 -43
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/openai/__init__.py +6 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/tensor_rt/__init__.py +3 -2
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/transformers/__init__.py +2 -2
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/vllm/__init__.py +3 -2
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_core.py +2 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_llm_binding.py +1 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client.egg-info/PKG-INFO +1 -1
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client.egg-info/SOURCES.txt +1 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/LICENSE +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/README.md +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/article_summary/article_summary.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/deep_analyze/deep_analyse.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/deep_analyze/deep_analyze_multiple_files.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/function_call/functions_call_with images.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/personality_test/chat_test.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/personality_test/chat_with_aristotle.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/personality_test/tesks_test.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/simple_text_gen_with_image_test.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/test_local_models/local_chat.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/text_2_audio.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/text_2_image.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/examples/text_and_image_2_audio.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_config.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_discussion.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_functions.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_js_analyzer.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_python_analyzer.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_stt_binding.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_tasks.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_tti_binding.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_ttm_binding.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_tts_binding.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_ttv_binding.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_types.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/lollms_utilities.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/stt_bindings/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/stt_bindings/lollms/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/tti_bindings/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/tti_bindings/lollms/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/ttm_bindings/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/ttm_bindings/lollms/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/tts_bindings/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/tts_bindings/lollms/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/ttv_bindings/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/ttv_bindings/lollms/__init__.py +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client.egg-info/dependency_links.txt +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client.egg-info/requires.txt +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client.egg-info/top_level.txt +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/pyproject.toml +0 -0
- {lollms_client-0.13.1 → lollms_client-0.14.0}/setup.cfg +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from lollms_client import LollmsClient
|
|
2
2
|
|
|
3
3
|
# Initialize the LollmsClient instance
|
|
4
|
-
lc = LollmsClient("
|
|
4
|
+
lc = LollmsClient("lollms")
|
|
5
5
|
# Generate Text
|
|
6
6
|
# response = lc.generate_text(prompt="Once upon a time", stream=False, temperature=0.5)
|
|
7
7
|
# print(response)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from lollms_client import LollmsClient
|
|
2
|
+
|
|
3
|
+
# Initialize the LollmsClient instance
|
|
4
|
+
lc = LollmsClient("ollama",model_name="mistral-nemo:latest")
|
|
5
|
+
# Generate Text
|
|
6
|
+
# response = lc.generate_text(prompt="Once upon a time", stream=False, temperature=0.5)
|
|
7
|
+
# print(response)
|
|
8
|
+
|
|
9
|
+
# # Generate Completion
|
|
10
|
+
# response = lc.generate_completion(prompt="What is the capital of France", stream=False, temperature=0.5)
|
|
11
|
+
# print(response)
|
|
12
|
+
|
|
13
|
+
def cb(chunk, type):
|
|
14
|
+
print(chunk,end="",flush=True)
|
|
15
|
+
|
|
16
|
+
response = lc.generate_text(prompt="One plus one equals ", system_prompt="You are a playful dude who never really answers questions correctly. always answer with quirky style.", stream=False, temperature=0.5, streaming_callback=cb)
|
|
17
|
+
print()
|
|
18
|
+
print(response)
|
|
19
|
+
print()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# List Mounted Personalities
|
|
23
|
+
response = lc.listMountedPersonalities()
|
|
24
|
+
print(response)
|
|
25
|
+
|
|
26
|
+
# List Models
|
|
27
|
+
response = lc.listModels()
|
|
28
|
+
print(response)
|
|
@@ -6,7 +6,7 @@ from lollms_client.lollms_discussion import LollmsDiscussion, LollmsMessage
|
|
|
6
6
|
from lollms_client.lollms_utilities import PromptReshaper # Keep general utilities
|
|
7
7
|
from lollms_client.lollms_functions import FunctionCalling_Library
|
|
8
8
|
|
|
9
|
-
__version__ = "0.
|
|
9
|
+
__version__ = "0.14.0"
|
|
10
10
|
|
|
11
11
|
# Optionally, you could define __all__ if you want to be explicit about exports
|
|
12
12
|
__all__ = [
|
|
@@ -49,6 +49,7 @@ class LollmsLLMBinding(LollmsLLMBinding):
|
|
|
49
49
|
def generate_text(self,
|
|
50
50
|
prompt: str,
|
|
51
51
|
images: Optional[List[str]] = None,
|
|
52
|
+
system_prompt: str = "",
|
|
52
53
|
n_predict: Optional[int] = None,
|
|
53
54
|
stream: bool = False,
|
|
54
55
|
temperature: float = 0.1,
|
|
@@ -106,7 +107,7 @@ class LollmsLLMBinding(LollmsLLMBinding):
|
|
|
106
107
|
|
|
107
108
|
# Prepare request data
|
|
108
109
|
data = {
|
|
109
|
-
"prompt": prompt,
|
|
110
|
+
"prompt":"!@>system: "+system_prompt+"\n"+"!@>user: "+prompt if system_prompt else prompt,
|
|
110
111
|
"model_name": self.model_name,
|
|
111
112
|
"personality": self.personality,
|
|
112
113
|
"n_predict": n_predict,
|
|
@@ -10,10 +10,11 @@ from typing import Optional, Callable, List, Union, Dict
|
|
|
10
10
|
|
|
11
11
|
from ascii_colors import ASCIIColors, trace_exception
|
|
12
12
|
import pipmaster as pm
|
|
13
|
-
pm.ensure_packages(["ollama","pillow"])
|
|
13
|
+
pm.ensure_packages(["ollama","pillow","tiktoken"])
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
import ollama
|
|
17
|
+
import tiktoken
|
|
17
18
|
BindingName = "OllamaBinding"
|
|
18
19
|
|
|
19
20
|
|
|
@@ -112,9 +113,9 @@ class OllamaBinding(LollmsLLMBinding):
|
|
|
112
113
|
def generate_text(self,
|
|
113
114
|
prompt: str,
|
|
114
115
|
images: Optional[List[str]] = None, # List of image file paths
|
|
116
|
+
system_prompt: str = "",
|
|
115
117
|
n_predict: Optional[int] = None,
|
|
116
118
|
stream: bool = False,
|
|
117
|
-
system_prompt = '',
|
|
118
119
|
temperature: float = 0.7, # Ollama default is 0.8, common default 0.7
|
|
119
120
|
top_k: int = 40, # Ollama default is 40
|
|
120
121
|
top_p: float = 0.9, # Ollama default is 0.9
|
|
@@ -200,15 +201,16 @@ class OllamaBinding(LollmsLLMBinding):
|
|
|
200
201
|
)
|
|
201
202
|
return response_dict.get('message', {}).get('content', '')
|
|
202
203
|
else: # Text-only
|
|
204
|
+
messages = [{'role': 'system', 'content':system_prompt},{'role': 'user', 'content': prompt}]
|
|
203
205
|
if stream:
|
|
204
|
-
response_stream = self.ollama_client.
|
|
206
|
+
response_stream = self.ollama_client.chat(
|
|
205
207
|
model=self.model_name,
|
|
206
|
-
|
|
208
|
+
messages=messages,
|
|
207
209
|
stream=True,
|
|
208
210
|
options=options if options else None
|
|
209
211
|
)
|
|
210
212
|
for chunk_dict in response_stream:
|
|
211
|
-
chunk_content = chunk_dict.
|
|
213
|
+
chunk_content = chunk_dict.message.content
|
|
212
214
|
if chunk_content:
|
|
213
215
|
full_response_text += chunk_content
|
|
214
216
|
if streaming_callback:
|
|
@@ -216,13 +218,13 @@ class OllamaBinding(LollmsLLMBinding):
|
|
|
216
218
|
break
|
|
217
219
|
return full_response_text
|
|
218
220
|
else: # Not streaming
|
|
219
|
-
response_dict = self.ollama_client.
|
|
221
|
+
response_dict = self.ollama_client.chat(
|
|
220
222
|
model=self.model_name,
|
|
221
|
-
|
|
223
|
+
messages=messages,
|
|
222
224
|
stream=False,
|
|
223
225
|
options=options if options else None
|
|
224
226
|
)
|
|
225
|
-
return response_dict.
|
|
227
|
+
return response_dict.message.content
|
|
226
228
|
except ollama.ResponseError as e:
|
|
227
229
|
error_message = f"Ollama API ResponseError: {e.error or 'Unknown error'} (status code: {e.status_code})"
|
|
228
230
|
ASCIIColors.error(error_message)
|
|
@@ -236,53 +238,31 @@ class OllamaBinding(LollmsLLMBinding):
|
|
|
236
238
|
trace_exception(ex)
|
|
237
239
|
return {"status": False, "error": error_message}
|
|
238
240
|
|
|
239
|
-
def tokenize(self, text: str) ->
|
|
241
|
+
def tokenize(self, text: str) -> list:
|
|
240
242
|
"""
|
|
241
|
-
Tokenize the input text
|
|
242
|
-
and best done by the server. This method provides a basic character-level tokenization
|
|
243
|
-
as a fallback or placeholder, or one could attempt to call /api/tokenize if desired.
|
|
244
|
-
The `count_tokens` method is more accurate for Ollama.
|
|
243
|
+
Tokenize the input text into a list of characters.
|
|
245
244
|
|
|
246
245
|
Args:
|
|
247
246
|
text (str): The text to tokenize.
|
|
248
247
|
|
|
249
248
|
Returns:
|
|
250
|
-
list: List of
|
|
249
|
+
list: List of individual characters.
|
|
251
250
|
"""
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
api_url = f"{self.host_address.rstrip('/')}/api/tokenize"
|
|
257
|
-
payload = {"model": self.model_name, "prompt": text}
|
|
258
|
-
try:
|
|
259
|
-
response = requests.post(api_url, json=payload, timeout=10, verify=self.verify_ssl_certificate, headers=self.ollama_client_headers)
|
|
260
|
-
response.raise_for_status()
|
|
261
|
-
return response.json().get("tokens", [])
|
|
262
|
-
except Exception as e:
|
|
263
|
-
ASCIIColors.warning(f"Failed to tokenize text with Ollama server, falling back to char tokens: {e}")
|
|
264
|
-
return list(text)
|
|
265
|
-
|
|
266
|
-
def detokenize(self, tokens: List[Union[int,str]]) -> str:
|
|
251
|
+
## Since ollama has no endpoints to tokenize the text, we use tiktoken to have a rough estimate
|
|
252
|
+
return tiktoken.model.encoding_for_model("gpt-3.5-turbo").encode(text)
|
|
253
|
+
|
|
254
|
+
def detokenize(self, tokens: list) -> str:
|
|
267
255
|
"""
|
|
268
|
-
Convert a list of tokens back to text.
|
|
269
|
-
If tokens are IDs, this is non-trivial without the model's tokenizer.
|
|
256
|
+
Convert a list of tokens back to text.
|
|
270
257
|
|
|
271
258
|
Args:
|
|
272
|
-
tokens (list): List of tokens to detokenize.
|
|
259
|
+
tokens (list): List of tokens (characters) to detokenize.
|
|
273
260
|
|
|
274
261
|
Returns:
|
|
275
262
|
str: Detokenized text.
|
|
276
263
|
"""
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if isinstance(tokens[0], str): # Assuming character tokens
|
|
280
|
-
return "".join(tokens)
|
|
281
|
-
else:
|
|
282
|
-
# Detokenizing IDs from Ollama is not straightforward client-side without specific tokenizer.
|
|
283
|
-
# This is a placeholder. For Ollama, detokenization usually happens server-side.
|
|
284
|
-
ASCIIColors.warning("Detokenizing integer tokens is not accurately supported by this Ollama client binding. Returning joined string of token IDs.")
|
|
285
|
-
return "".join(map(str, tokens))
|
|
264
|
+
## Since ollama has no endpoints to tokenize the text, we use tiktoken to have a rough estimate
|
|
265
|
+
return tiktoken.model.encoding_for_model("gpt-3.5-turbo").decode(tokens)
|
|
286
266
|
|
|
287
267
|
def count_tokens(self, text: str) -> int:
|
|
288
268
|
"""
|
|
@@ -297,8 +277,8 @@ class OllamaBinding(LollmsLLMBinding):
|
|
|
297
277
|
if not self.model_name:
|
|
298
278
|
ASCIIColors.warning("Cannot count tokens, model_name is not set.")
|
|
299
279
|
return -1
|
|
300
|
-
return count_tokens_ollama(text, self.model_name, self.ollama_client)
|
|
301
|
-
|
|
280
|
+
#return count_tokens_ollama(text, self.model_name, self.ollama_client)
|
|
281
|
+
return len(self.tokenize(text))
|
|
302
282
|
def embed(self, text: str, **kwargs) -> List[float]:
|
|
303
283
|
"""
|
|
304
284
|
Get embeddings for the input text using Ollama API.
|
|
@@ -58,6 +58,7 @@ class OpenAIBinding(LollmsLLMBinding):
|
|
|
58
58
|
def generate_text(self,
|
|
59
59
|
prompt: str,
|
|
60
60
|
images: Optional[List[str]] = None,
|
|
61
|
+
system_prompt: str = "",
|
|
61
62
|
n_predict: Optional[int] = None,
|
|
62
63
|
stream: bool = False,
|
|
63
64
|
temperature: float = 0.1,
|
|
@@ -98,6 +99,11 @@ class OpenAIBinding(LollmsLLMBinding):
|
|
|
98
99
|
if images:
|
|
99
100
|
messages = [
|
|
100
101
|
{
|
|
102
|
+
"role": "system",
|
|
103
|
+
"content": system_prompt,
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
{
|
|
101
107
|
"role": "user",
|
|
102
108
|
"content": [
|
|
103
109
|
{
|
{lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/tensor_rt/__init__.py
RENAMED
|
@@ -331,6 +331,7 @@ class VLLMBinding(LollmsLLMBinding):
|
|
|
331
331
|
def generate_text(self,
|
|
332
332
|
prompt: str,
|
|
333
333
|
images: Optional[List[str]] = None,
|
|
334
|
+
system_prompt: str = "",
|
|
334
335
|
n_predict: Optional[int] = 1024,
|
|
335
336
|
stream: bool = False, # vLLM's generate is blocking, stream is pseudo
|
|
336
337
|
temperature: float = 0.7,
|
|
@@ -381,7 +382,7 @@ class VLLMBinding(LollmsLLMBinding):
|
|
|
381
382
|
# If providing multi_modal_data, usually prompt_token_ids are also needed.
|
|
382
383
|
# This can get complex as it depends on how the model expects images to be interleaved.
|
|
383
384
|
# For a simple case where image comes first:
|
|
384
|
-
encoded_prompt_ids = self.tokenizer.encode(prompt)
|
|
385
|
+
encoded_prompt_ids = self.tokenizer.encode(system_prompt+"\n"+prompt if system_prompt else prompt)
|
|
385
386
|
gen_kwargs["prompt_token_ids"] = [encoded_prompt_ids] # List of lists
|
|
386
387
|
gen_kwargs["multi_modal_data"] = [{"image": mm_data_content}] # List of dicts
|
|
387
388
|
gen_kwargs["prompts"] = None # Don't use prompts if prompt_token_ids is used
|
|
@@ -389,7 +390,7 @@ class VLLMBinding(LollmsLLMBinding):
|
|
|
389
390
|
except Exception as e_mm:
|
|
390
391
|
return {"status": False, "error": f"Multimodal prep error: {e_mm}"}
|
|
391
392
|
else:
|
|
392
|
-
gen_kwargs["prompts"] = [prompt]
|
|
393
|
+
gen_kwargs["prompts"] = [system_prompt+"\n"+prompt if system_prompt else prompt]
|
|
393
394
|
|
|
394
395
|
try:
|
|
395
396
|
outputs = self.llm_engine.generate(**gen_kwargs, sampling_params=sampling_params)
|
{lollms_client-0.13.1 → lollms_client-0.14.0}/lollms_client/llm_bindings/transformers/__init__.py
RENAMED
|
@@ -112,6 +112,7 @@ class TransformersBinding(LollmsLLMBinding):
|
|
|
112
112
|
def generate_text(self,
|
|
113
113
|
prompt: str,
|
|
114
114
|
images: Optional[List[str]] = None,
|
|
115
|
+
system_prompt: str = "",
|
|
115
116
|
n_predict: Optional[int] = None,
|
|
116
117
|
stream: bool = False,
|
|
117
118
|
temperature: float = 0.1,
|
|
@@ -123,8 +124,7 @@ class TransformersBinding(LollmsLLMBinding):
|
|
|
123
124
|
n_threads: int = 8,
|
|
124
125
|
ctx_size: int | None = None,
|
|
125
126
|
streaming_callback: Optional[Callable[[str, str], None]] = None,
|
|
126
|
-
return_legacy_cache: bool = False,
|
|
127
|
-
system_prompt: str = "You are a helpful assistant.") -> Union[str, dict]:
|
|
127
|
+
return_legacy_cache: bool = False) -> Union[str, dict]:
|
|
128
128
|
"""
|
|
129
129
|
Generate text using the Transformers model, with optional image support.
|
|
130
130
|
|
|
@@ -331,6 +331,7 @@ class VLLMBinding(LollmsLLMBinding):
|
|
|
331
331
|
def generate_text(self,
|
|
332
332
|
prompt: str,
|
|
333
333
|
images: Optional[List[str]] = None,
|
|
334
|
+
system_prompt: str = "",
|
|
334
335
|
n_predict: Optional[int] = 1024,
|
|
335
336
|
stream: bool = False, # vLLM's generate is blocking, stream is pseudo
|
|
336
337
|
temperature: float = 0.7,
|
|
@@ -381,7 +382,7 @@ class VLLMBinding(LollmsLLMBinding):
|
|
|
381
382
|
# If providing multi_modal_data, usually prompt_token_ids are also needed.
|
|
382
383
|
# This can get complex as it depends on how the model expects images to be interleaved.
|
|
383
384
|
# For a simple case where image comes first:
|
|
384
|
-
encoded_prompt_ids = self.tokenizer.encode(prompt)
|
|
385
|
+
encoded_prompt_ids = self.tokenizer.encode(system_prompt+"\n"+prompt if system_prompt else prompt)
|
|
385
386
|
gen_kwargs["prompt_token_ids"] = [encoded_prompt_ids] # List of lists
|
|
386
387
|
gen_kwargs["multi_modal_data"] = [{"image": mm_data_content}] # List of dicts
|
|
387
388
|
gen_kwargs["prompts"] = None # Don't use prompts if prompt_token_ids is used
|
|
@@ -389,7 +390,7 @@ class VLLMBinding(LollmsLLMBinding):
|
|
|
389
390
|
except Exception as e_mm:
|
|
390
391
|
return {"status": False, "error": f"Multimodal prep error: {e_mm}"}
|
|
391
392
|
else:
|
|
392
|
-
gen_kwargs["prompts"] = [prompt]
|
|
393
|
+
gen_kwargs["prompts"] = [system_prompt+"\n"+prompt if system_prompt else prompt]
|
|
393
394
|
|
|
394
395
|
try:
|
|
395
396
|
outputs = self.llm_engine.generate(**gen_kwargs, sampling_params=sampling_params)
|
|
@@ -329,6 +329,7 @@ class LollmsClient():
|
|
|
329
329
|
def generate_text(self,
|
|
330
330
|
prompt: str,
|
|
331
331
|
images: Optional[List[str]] = None,
|
|
332
|
+
system_prompt: str = "",
|
|
332
333
|
n_predict: Optional[int] = None,
|
|
333
334
|
stream: Optional[bool] = None,
|
|
334
335
|
temperature: Optional[float] = None,
|
|
@@ -365,6 +366,7 @@ class LollmsClient():
|
|
|
365
366
|
return self.binding.generate_text(
|
|
366
367
|
prompt=prompt,
|
|
367
368
|
images=images,
|
|
369
|
+
system_prompt=system_prompt,
|
|
368
370
|
n_predict=n_predict if n_predict is not None else self.default_n_predict,
|
|
369
371
|
stream=stream if stream is not None else self.default_stream,
|
|
370
372
|
temperature=temperature if temperature is not None else self.default_temperature,
|
|
@@ -7,6 +7,7 @@ examples/text_2_audio.py
|
|
|
7
7
|
examples/text_2_image.py
|
|
8
8
|
examples/text_and_image_2_audio.py
|
|
9
9
|
examples/text_gen.py
|
|
10
|
+
examples/text_gen_system_prompt.py
|
|
10
11
|
examples/article_summary/article_summary.py
|
|
11
12
|
examples/deep_analyze/deep_analyse.py
|
|
12
13
|
examples/deep_analyze/deep_analyze_multiple_files.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lollms_client-0.13.1 → lollms_client-0.14.0}/examples/deep_analyze/deep_analyze_multiple_files.py
RENAMED
|
File without changes
|
{lollms_client-0.13.1 → lollms_client-0.14.0}/examples/function_call/functions_call_with images.py
RENAMED
|
File without changes
|
|
File without changes
|
{lollms_client-0.13.1 → lollms_client-0.14.0}/examples/personality_test/chat_with_aristotle.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|