llm-ie 0.1.4__py3-none-any.whl → 0.1.5__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/data_types.py CHANGED
@@ -3,7 +3,7 @@ import yaml
3
3
 
4
4
 
5
5
  class LLMInformationExtractionFrame:
6
- def __init__(self, frame_id:str, start:int, end:int, entity_text:str, attr:Dict[str,str]):
6
+ def __init__(self, frame_id:str, start:int, end:int, entity_text:str, attr:Dict[str,str]=None):
7
7
  """
8
8
  This class holds a frame (entity) extracted by LLM.
9
9
  A frame contains the span (start and end character positions), a entity text, and
@@ -19,7 +19,7 @@ class LLMInformationExtractionFrame:
19
19
  entity end character position
20
20
  entity_text : str
21
21
  entity string. Should be the exact string by [start:end]
22
- attr : Dict[str,str]
22
+ attr : Dict[str,str], Optional
23
23
  dict of attributes
24
24
  """
25
25
  assert isinstance(frame_id, str), "frame_id must be a string."
@@ -27,7 +27,10 @@ class LLMInformationExtractionFrame:
27
27
  self.start = start
28
28
  self.end = end
29
29
  self.entity_text = entity_text
30
- self.attr = attr.copy()
30
+ if attr:
31
+ self.attr = attr.copy()
32
+ else:
33
+ self.attr = None
31
34
 
32
35
  def is_equal(self, frame:"LLMInformationExtractionFrame") -> bool:
33
36
  """
llm_ie/extractors.py CHANGED
@@ -197,9 +197,13 @@ class BasicFrameExtractor(FrameExtractor):
197
197
  Return : str
198
198
  the output from LLM. Need post-processing.
199
199
  """
200
+ messages = []
201
+ if self.system_prompt:
202
+ messages.append({'role': 'system', 'content': self.system_prompt})
203
+
204
+ messages.append({'role': 'user', 'content': self._get_user_prompt(text_content)})
200
205
  response = self.inference_engine.chat(
201
- messages=[{'role': 'system', 'content': self.system_prompt},
202
- {'role': 'user', 'content': self._get_user_prompt(text_content)}],
206
+ messages=messages,
203
207
  max_new_tokens=max_new_tokens,
204
208
  temperature=temperature,
205
209
  stream=stream,
@@ -312,9 +316,11 @@ class ReviewFrameExtractor(BasicFrameExtractor):
312
316
  the output from LLM. Need post-processing.
313
317
  """
314
318
  # Pormpt extraction
315
- messages=[{'role': 'system', 'content': self.system_prompt},
316
- {'role': 'user', 'content': self._get_user_prompt(text_content)}]
317
-
319
+ messages = []
320
+ if self.system_prompt:
321
+ messages.append({'role': 'system', 'content': self.system_prompt})
322
+
323
+ messages.append({'role': 'user', 'content': self._get_user_prompt(text_content)})
318
324
  initial = self.inference_engine.chat(
319
325
  messages=messages,
320
326
  max_new_tokens=max_new_tokens,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llm-ie
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: An LLM-powered tool that transforms everyday language into robust information extraction pipelines.
5
5
  License: MIT
6
6
  Author: Enshuo (David) Hsu
@@ -4,10 +4,10 @@ llm_ie/asset/PromptEditor_prompts/rewrite.txt,sha256=bYLOix7DUBlcWv-Q0JZ5kDnZ9OE
4
4
  llm_ie/asset/prompt_guide/BasicFrameExtractor_prompt_guide.txt,sha256=XbnU8byLGGUA3A3lT0bb2Hw-ggzhcqD3ZuKzduod2ww,1944
5
5
  llm_ie/asset/prompt_guide/ReviewFrameExtractor_prompt_guide.txt,sha256=XbnU8byLGGUA3A3lT0bb2Hw-ggzhcqD3ZuKzduod2ww,1944
6
6
  llm_ie/asset/prompt_guide/SentenceFrameExtractor_prompt_guide.txt,sha256=8nj9OLPJMtr9Soi5JU3Xk-HC7pKNoI54xA_A4u7I5j4,2620
7
- llm_ie/data_types.py,sha256=AxqgfmPkYySDz7VuTWh8yDWofvZgdjgFiW9hihqInHc,6605
7
+ llm_ie/data_types.py,sha256=MnpyXFviFWhxeC5mqbaPdAxGx6vV_PhnUIFfUamq3D8,6687
8
8
  llm_ie/engines.py,sha256=TuxM56_u6-dsAAuNdfuKSH23nb9UfFbg6T60e-OXEA8,9294
9
- llm_ie/extractors.py,sha256=v_VZnpb7PPRlZC4X55k_w2t6X2W3NFWe8ZHo57q7s4Y,22401
9
+ llm_ie/extractors.py,sha256=rpHJhlV3A9-9nldIutxd8rtgf7903Ke6QkwbCIVdUdY,22546
10
10
  llm_ie/prompt_editor.py,sha256=dbu7A3O7O7Iw2v-xCgrTFH1-wTLAGf4SHDqdeS-He2Q,1869
11
- llm_ie-0.1.4.dist-info/METADATA,sha256=-P_iDB6jMLm8Qb-paUAiwGsDu4d_SZIcaDXISnN36H4,28028
12
- llm_ie-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
13
- llm_ie-0.1.4.dist-info/RECORD,,
11
+ llm_ie-0.1.5.dist-info/METADATA,sha256=2z2VDBlBq7GLws7aEcyjRmw0NC3gvKJIXS4LB6AaeI4,28028
12
+ llm_ie-0.1.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
13
+ llm_ie-0.1.5.dist-info/RECORD,,
File without changes