llm-ie 0.2.1__tar.gz → 0.2.2__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.
- {llm_ie-0.2.1 → llm_ie-0.2.2}/PKG-INFO +1 -1
- {llm_ie-0.2.1 → llm_ie-0.2.2}/pyproject.toml +1 -1
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/data_types.py +53 -7
- {llm_ie-0.2.1 → llm_ie-0.2.2}/README.md +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/__init__.py +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/PromptEditor_prompts/comment.txt +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/PromptEditor_prompts/rewrite.txt +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/BasicFrameExtractor_prompt_guide.txt +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/BinaryRelationExtractor_prompt_guide.txt +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/MultiClassRelationExtractor_prompt_guide.txt +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/ReviewFrameExtractor_prompt_guide.txt +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/SentenceFrameExtractor_prompt_guide.txt +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/engines.py +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/extractors.py +0 -0
- {llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/prompt_editor.py +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import List, Dict, Iterable, Callable
|
|
1
|
+
from typing import List, Dict, Tuple, Iterable, Callable
|
|
2
2
|
import importlib.util
|
|
3
3
|
import json
|
|
4
4
|
|
|
@@ -283,15 +283,12 @@ class LLMInformationExtractionDocument:
|
|
|
283
283
|
json_file.flush()
|
|
284
284
|
|
|
285
285
|
|
|
286
|
-
def
|
|
287
|
-
color_attr_key:str=None, color_map_func:Callable=None):
|
|
286
|
+
def _viz_preprocess(self) -> Tuple:
|
|
288
287
|
"""
|
|
289
|
-
This method
|
|
288
|
+
This method preprocesses the entities and relations for visualization.
|
|
290
289
|
"""
|
|
291
290
|
if importlib.util.find_spec("ie_viz") is None:
|
|
292
291
|
raise ImportError("ie_viz not found. Please install ie_viz (```pip install ie-viz```).")
|
|
293
|
-
|
|
294
|
-
from ie_viz import serve
|
|
295
292
|
|
|
296
293
|
if self.has_frame():
|
|
297
294
|
entities = [{"entity_id": frame.frame_id, "start": frame.start, "end": frame.end, "attr": frame.attr} for frame in self.frames]
|
|
@@ -306,6 +303,31 @@ class LLMInformationExtractionDocument:
|
|
|
306
303
|
else:
|
|
307
304
|
relations = None
|
|
308
305
|
|
|
306
|
+
return entities, relations
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
def viz_serve(self, host: str = '0.0.0.0', port: int = 5000, theme:str = "light",
|
|
310
|
+
color_attr_key:str=None, color_map_func:Callable=None):
|
|
311
|
+
"""
|
|
312
|
+
This method serves a visualization App of the document.
|
|
313
|
+
|
|
314
|
+
Parameters:
|
|
315
|
+
-----------
|
|
316
|
+
host : str, Optional
|
|
317
|
+
The host address to run the server on.
|
|
318
|
+
port : int, Optional
|
|
319
|
+
The port number to run the server on.
|
|
320
|
+
theme : str, Optional
|
|
321
|
+
The theme of the visualization. Must be either "light" or "dark".
|
|
322
|
+
color_attr_key : str, Optional
|
|
323
|
+
The attribute key to be used for coloring the entities.
|
|
324
|
+
color_map_func : Callable, Optional
|
|
325
|
+
The function to be used for mapping the entity attributes to colors. When provided, the color_attr_key and
|
|
326
|
+
theme will be overwritten. The function must take an entity dictionary as input and return a color string (hex).
|
|
327
|
+
"""
|
|
328
|
+
entities, relations = self._viz_preprocess()
|
|
329
|
+
from ie_viz import serve
|
|
330
|
+
|
|
309
331
|
serve(text=self.text,
|
|
310
332
|
entities=entities,
|
|
311
333
|
relations=relations,
|
|
@@ -314,4 +336,28 @@ class LLMInformationExtractionDocument:
|
|
|
314
336
|
theme=theme,
|
|
315
337
|
color_attr_key=color_attr_key,
|
|
316
338
|
color_map_func=color_map_func)
|
|
317
|
-
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def viz_render(self, theme:str = "light", color_attr_key:str=None, color_map_func:Callable=None) -> str:
|
|
342
|
+
"""
|
|
343
|
+
This method renders visualization html of the document.
|
|
344
|
+
|
|
345
|
+
Parameters:
|
|
346
|
+
-----------
|
|
347
|
+
theme : str, Optional
|
|
348
|
+
The theme of the visualization. Must be either "light" or "dark".
|
|
349
|
+
color_attr_key : str, Optional
|
|
350
|
+
The attribute key to be used for coloring the entities.
|
|
351
|
+
color_map_func : Callable, Optional
|
|
352
|
+
The function to be used for mapping the entity attributes to colors. When provided, the color_attr_key and
|
|
353
|
+
theme will be overwritten. The function must take an entity dictionary as input and return a color string (hex).
|
|
354
|
+
"""
|
|
355
|
+
entities, relations = self._viz_preprocess()
|
|
356
|
+
from ie_viz import render
|
|
357
|
+
|
|
358
|
+
return render(text=self.text,
|
|
359
|
+
entities=entities,
|
|
360
|
+
relations=relations,
|
|
361
|
+
theme=theme,
|
|
362
|
+
color_attr_key=color_attr_key,
|
|
363
|
+
color_map_func=color_map_func)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/BasicFrameExtractor_prompt_guide.txt
RENAMED
|
File without changes
|
{llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/BinaryRelationExtractor_prompt_guide.txt
RENAMED
|
File without changes
|
|
File without changes
|
{llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/ReviewFrameExtractor_prompt_guide.txt
RENAMED
|
File without changes
|
{llm_ie-0.2.1 → llm_ie-0.2.2}/src/llm_ie/asset/prompt_guide/SentenceFrameExtractor_prompt_guide.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|