llm-ie 0.3.4__py3-none-any.whl → 0.4.0__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.
- llm_ie/__init__.py +9 -0
- llm_ie/engines.py +151 -9
- llm_ie/extractors.py +552 -152
- llm_ie/prompt_editor.py +17 -2
- {llm_ie-0.3.4.dist-info → llm_ie-0.4.0.dist-info}/METADATA +342 -103
- {llm_ie-0.3.4.dist-info → llm_ie-0.4.0.dist-info}/RECORD +7 -7
- {llm_ie-0.3.4.dist-info → llm_ie-0.4.0.dist-info}/WHEEL +0 -0
llm_ie/prompt_editor.py
CHANGED
|
@@ -8,7 +8,7 @@ from colorama import Fore, Style
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class PromptEditor:
|
|
11
|
-
def __init__(self, inference_engine:InferenceEngine, extractor:FrameExtractor):
|
|
11
|
+
def __init__(self, inference_engine:InferenceEngine, extractor:FrameExtractor, prompt_guide:str=None):
|
|
12
12
|
"""
|
|
13
13
|
This class is a LLM agent that rewrite or comment a prompt draft based on the prompt guide of an extractor.
|
|
14
14
|
|
|
@@ -18,10 +18,25 @@ class PromptEditor:
|
|
|
18
18
|
the LLM inferencing engine object. Must implements the chat() method.
|
|
19
19
|
extractor : FrameExtractor
|
|
20
20
|
a FrameExtractor.
|
|
21
|
+
prompt_guide : str, optional
|
|
22
|
+
the prompt guide for the extractor.
|
|
23
|
+
All built-in extractors have a prompt guide in the asset folder. Passing values to this parameter
|
|
24
|
+
will override the built-in prompt guide which is not recommended.
|
|
25
|
+
For custom extractors, this parameter must be provided.
|
|
21
26
|
"""
|
|
22
27
|
self.inference_engine = inference_engine
|
|
23
|
-
self.prompt_guide = extractor.get_prompt_guide()
|
|
24
28
|
|
|
29
|
+
# if prompt_guide is provided, use it anyways
|
|
30
|
+
if prompt_guide:
|
|
31
|
+
self.prompt_guide = prompt_guide
|
|
32
|
+
# if prompt_guide is not provided, get it from the extractor
|
|
33
|
+
else:
|
|
34
|
+
self.prompt_guide = extractor.get_prompt_guide()
|
|
35
|
+
# when extractor does not have a prompt guide (e.g. custom extractor), ValueError
|
|
36
|
+
if self.prompt_guide is None:
|
|
37
|
+
raise ValueError(f"Prompt guide for {extractor.__class__.__name__} is not available. Use `prompt_guide` parameter to provide a prompt guide.")
|
|
38
|
+
|
|
39
|
+
# get system prompt
|
|
25
40
|
file_path = importlib.resources.files('llm_ie.asset.PromptEditor_prompts').joinpath('system.txt')
|
|
26
41
|
with open(file_path, 'r') as f:
|
|
27
42
|
self.system_prompt = f.read()
|