llm-ie 0.2.0__py3-none-any.whl → 0.2.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.
llm_ie/data_types.py CHANGED
@@ -1,4 +1,5 @@
1
- from typing import List, Dict, Iterable
1
+ from typing import List, Dict, Iterable, Callable
2
+ import importlib.util
2
3
  import json
3
4
 
4
5
 
@@ -281,3 +282,36 @@ class LLMInformationExtractionDocument:
281
282
  json_file, indent=4)
282
283
  json_file.flush()
283
284
 
285
+
286
+ def serve_viz(self, host: str = '0.0.0.0', port: int = 3000, theme:str = "light",
287
+ color_attr_key:str=None, color_map_func:Callable=None):
288
+ """
289
+ This method serves a visualization of the document.
290
+ """
291
+ if importlib.util.find_spec("ie_viz") is None:
292
+ raise ImportError("ie_viz not found. Please install ie_viz (```pip install ie-viz```).")
293
+
294
+ from ie_viz import serve
295
+
296
+ if self.has_frame():
297
+ entities = [{"entity_id": frame.frame_id, "start": frame.start, "end": frame.end, "attr": frame.attr} for frame in self.frames]
298
+ else:
299
+ raise ValueError("No frames in the document.")
300
+
301
+ if self.has_relation():
302
+ relations = []
303
+ for relation in self.relations:
304
+ rel = {"entity_1_id": relation['frame_1'], "entity_2_id": relation['frame_2']}
305
+ relations.append(rel)
306
+ else:
307
+ relations = None
308
+
309
+ serve(text=self.text,
310
+ entities=entities,
311
+ relations=relations,
312
+ host=host,
313
+ port=port,
314
+ theme=theme,
315
+ color_attr_key=color_attr_key,
316
+ color_map_func=color_map_func)
317
+
llm_ie/extractors.py CHANGED
@@ -896,7 +896,7 @@ class MultiClassRelationExtractor(RelationExtractor):
896
896
  if len(rel_json) > 0:
897
897
  if "RelationType" in rel_json[0]:
898
898
  rel = rel_json[0]["RelationType"]
899
- if rel in pos_rel_types:
899
+ if rel in pos_rel_types or rel == "No Relation":
900
900
  return rel_json[0]["RelationType"]
901
901
  else:
902
902
  warnings.warn(f'Extracted relation type "{rel}", which is not in the return of possible_relation_types_func: {pos_rel_types}.'+ \
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llm-ie
3
- Version: 0.2.0
3
+ Version: 0.2.1
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
@@ -6,10 +6,10 @@ llm_ie/asset/prompt_guide/BinaryRelationExtractor_prompt_guide.txt,sha256=z9Xg0f
6
6
  llm_ie/asset/prompt_guide/MultiClassRelationExtractor_prompt_guide.txt,sha256=D5DphUHw8SUERUVdcIjUynuTmYJa6-PwBlF7FzxNsvQ,2276
7
7
  llm_ie/asset/prompt_guide/ReviewFrameExtractor_prompt_guide.txt,sha256=XbnU8byLGGUA3A3lT0bb2Hw-ggzhcqD3ZuKzduod2ww,1944
8
8
  llm_ie/asset/prompt_guide/SentenceFrameExtractor_prompt_guide.txt,sha256=8nj9OLPJMtr9Soi5JU3Xk-HC7pKNoI54xA_A4u7I5j4,2620
9
- llm_ie/data_types.py,sha256=2RKP4wXDuku-Tn4s8uzzUFavG1fZ2e47SaY8oL57LsI,10923
9
+ llm_ie/data_types.py,sha256=zAUx-n1ePTTg1aFrml0lTZPreJx241YTeWFCprRoYbU,12245
10
10
  llm_ie/engines.py,sha256=m9ytGUX61jEy9SmVHbb90mrfGMAwC6dV-v7Jke1U7Ho,9296
11
- llm_ie/extractors.py,sha256=i0m8uFaKXiVY1ucjvzbUFbV1slPYfZ3EGOZrolnFVHA,44079
11
+ llm_ie/extractors.py,sha256=EVuHqW1lW0RpGmnRNmX4ih6ppfvy2gYOAOgc8Pngfkw,44103
12
12
  llm_ie/prompt_editor.py,sha256=dbu7A3O7O7Iw2v-xCgrTFH1-wTLAGf4SHDqdeS-He2Q,1869
13
- llm_ie-0.2.0.dist-info/METADATA,sha256=9CPC3OAd2J0nROZ7z8DI7lvGKOO2H2uAnVQv_YDFItg,40052
14
- llm_ie-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
15
- llm_ie-0.2.0.dist-info/RECORD,,
13
+ llm_ie-0.2.1.dist-info/METADATA,sha256=JOjW83QHlj-rgp09upos2-XvhvvnROBeOoX4U33AZKU,40052
14
+ llm_ie-0.2.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
15
+ llm_ie-0.2.1.dist-info/RECORD,,
File without changes