attachments 0.2.4__tar.gz → 0.2.6__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.
- {attachments-0.2.4/src/attachments.egg-info → attachments-0.2.6}/PKG-INFO +5 -2
- {attachments-0.2.4 → attachments-0.2.6}/README.md +3 -1
- {attachments-0.2.4 → attachments-0.2.6}/pyproject.toml +2 -1
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/core.py +54 -1
- {attachments-0.2.4 → attachments-0.2.6/src/attachments.egg-info}/PKG-INFO +5 -2
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments.egg-info/requires.txt +1 -0
- {attachments-0.2.4 → attachments-0.2.6}/LICENSE +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/setup.cfg +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/__init__.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/audio_processing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/config.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/detectors.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/exceptions.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/image_processing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/office_contact_sheet.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/parsers.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/renderers.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments/utils.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments.egg-info/SOURCES.txt +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments.egg-info/dependency_links.txt +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/src/attachments.egg-info/top_level.txt +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_audio_processing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_base.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_core_functionality.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_document_parsing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_html_parsing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_image_processing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_indexing_slicing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_markdown_rendering.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_office_contact_sheet.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_pdf_parsing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_pptx_parsing.py +0 -0
- {attachments-0.2.4 → attachments-0.2.6}/tests/test_simple.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: attachments
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: A Python library to handle various file types for LLMs.
|
|
5
5
|
Author-email: Maxim Rivest <mrive052@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -35,13 +35,16 @@ Requires-Dist: flake8; extra == "dev"
|
|
|
35
35
|
Requires-Dist: mypy; extra == "dev"
|
|
36
36
|
Requires-Dist: black; extra == "dev"
|
|
37
37
|
Requires-Dist: filelock; extra == "dev"
|
|
38
|
+
Requires-Dist: mystmd; extra == "dev"
|
|
38
39
|
Dynamic: license-file
|
|
39
40
|
|
|
40
|
-
# Attachments
|
|
41
|
+
# Attachments: The Python Library for Effortless LLM Context
|
|
41
42
|
## Easiest way to give context to LLMs
|
|
42
43
|
|
|
43
44
|
Attachments has the ambition to be the general funnel for any files to be transformed into images+text for large language models context. For this to be true we, has a community, have to stop implementing this funnel (file -> images+text) each on our own. If you have a detector + parser + renderer contibute it! This will help you and us. Don't let your code alone in a dark corner of you computer.
|
|
44
45
|
|
|
46
|
+
From a `path` to a `string` and a `base64` image encoded string. That is the goal.
|
|
47
|
+
|
|
45
48
|
## Very quickstart
|
|
46
49
|
|
|
47
50
|
```bash
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
# Attachments
|
|
1
|
+
# Attachments: The Python Library for Effortless LLM Context
|
|
2
2
|
## Easiest way to give context to LLMs
|
|
3
3
|
|
|
4
4
|
Attachments has the ambition to be the general funnel for any files to be transformed into images+text for large language models context. For this to be true we, has a community, have to stop implementing this funnel (file -> images+text) each on our own. If you have a detector + parser + renderer contibute it! This will help you and us. Don't let your code alone in a dark corner of you computer.
|
|
5
5
|
|
|
6
|
+
From a `path` to a `string` and a `base64` image encoded string. That is the goal.
|
|
7
|
+
|
|
6
8
|
## Very quickstart
|
|
7
9
|
|
|
8
10
|
```bash
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "attachments"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.6"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Maxim Rivest", email="mrive052@gmail.com" },
|
|
10
10
|
]
|
|
@@ -53,6 +53,7 @@ dev = [
|
|
|
53
53
|
"mypy",
|
|
54
54
|
"black",
|
|
55
55
|
"filelock",
|
|
56
|
+
"mystmd",
|
|
56
57
|
]
|
|
57
58
|
|
|
58
59
|
[tool.setuptools]
|
|
@@ -278,7 +278,7 @@ class Attachments:
|
|
|
278
278
|
'm4a': 'audio/m4a', # mimetypes might say audio/mp4, which is also fine for .m4a
|
|
279
279
|
'mp4_audio': 'audio/mp4',
|
|
280
280
|
'wav': 'audio/wav',
|
|
281
|
-
'flac': 'audio/flac',
|
|
281
|
+
'flac': 'audio/flac',
|
|
282
282
|
'ogg_audio': 'audio/ogg',
|
|
283
283
|
'oga': 'audio/ogg',
|
|
284
284
|
'webm_audio': 'audio/webm',
|
|
@@ -634,6 +634,59 @@ class Attachments:
|
|
|
634
634
|
def another_method_or_end_of_class_placeholder(self):
|
|
635
635
|
pass
|
|
636
636
|
|
|
637
|
+
def to_openai_content(self, prompt: str) -> List[Dict[str, Any]]:
|
|
638
|
+
"""
|
|
639
|
+
Formats attachments and a prompt for the OpenAI API.
|
|
640
|
+
Currently supports images.
|
|
641
|
+
|
|
642
|
+
Args:
|
|
643
|
+
prompt: The text prompt to include.
|
|
644
|
+
|
|
645
|
+
Returns:
|
|
646
|
+
A list of dictionaries formatted for the OpenAI API,
|
|
647
|
+
combining image data and the text prompt.
|
|
648
|
+
"""
|
|
649
|
+
content = [{"type": "input_image", "image_url": image_data_uri} for image_data_uri in self.images]
|
|
650
|
+
content.append({"type": "input_text", "text": prompt + "\n\n" + self.__str__()})
|
|
651
|
+
return content
|
|
652
|
+
|
|
653
|
+
def to_claude_content(self, prompt: str) -> List[Dict[str, Any]]:
|
|
654
|
+
"""
|
|
655
|
+
Formats attachments and a prompt for the Anthropic Claude API.
|
|
656
|
+
Currently supports images.
|
|
657
|
+
|
|
658
|
+
Args:
|
|
659
|
+
prompt: The text prompt to include.
|
|
660
|
+
|
|
661
|
+
Returns:
|
|
662
|
+
A list of dictionaries formatted for the Anthropic Claude API,
|
|
663
|
+
combining image data and the text prompt.
|
|
664
|
+
"""
|
|
665
|
+
content = []
|
|
666
|
+
for image_data_uri in self.images:
|
|
667
|
+
try:
|
|
668
|
+
# Example data URI: "data:image/jpeg;base64,BASE64_STRING"
|
|
669
|
+
header, base64_data = image_data_uri.split(',', 1)
|
|
670
|
+
media_type = header.split(';')[0].split(':')[1]
|
|
671
|
+
|
|
672
|
+
content.append({
|
|
673
|
+
"type": "image",
|
|
674
|
+
"source": {
|
|
675
|
+
"type": "base64",
|
|
676
|
+
"media_type": media_type,
|
|
677
|
+
"data": base64_data
|
|
678
|
+
}
|
|
679
|
+
})
|
|
680
|
+
except ValueError as e:
|
|
681
|
+
# Handle cases where the data URI might not be as expected, though self.images should provide valid ones.
|
|
682
|
+
if self.verbose:
|
|
683
|
+
print(f"Warning: Could not parse image data URI for Claude content: {image_data_uri}. Error: {e}")
|
|
684
|
+
# Optionally, append an error or skip this image
|
|
685
|
+
continue # Skip malformed URIs for now
|
|
686
|
+
|
|
687
|
+
content.append({"type": "text", "text": prompt})
|
|
688
|
+
return content
|
|
689
|
+
|
|
637
690
|
# Potentially other methods follow, or end of class / file
|
|
638
691
|
|
|
639
692
|
def _format_operations_for_markdown(self, operations: Dict[str, Any]) -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: attachments
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: A Python library to handle various file types for LLMs.
|
|
5
5
|
Author-email: Maxim Rivest <mrive052@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -35,13 +35,16 @@ Requires-Dist: flake8; extra == "dev"
|
|
|
35
35
|
Requires-Dist: mypy; extra == "dev"
|
|
36
36
|
Requires-Dist: black; extra == "dev"
|
|
37
37
|
Requires-Dist: filelock; extra == "dev"
|
|
38
|
+
Requires-Dist: mystmd; extra == "dev"
|
|
38
39
|
Dynamic: license-file
|
|
39
40
|
|
|
40
|
-
# Attachments
|
|
41
|
+
# Attachments: The Python Library for Effortless LLM Context
|
|
41
42
|
## Easiest way to give context to LLMs
|
|
42
43
|
|
|
43
44
|
Attachments has the ambition to be the general funnel for any files to be transformed into images+text for large language models context. For this to be true we, has a community, have to stop implementing this funnel (file -> images+text) each on our own. If you have a detector + parser + renderer contibute it! This will help you and us. Don't let your code alone in a dark corner of you computer.
|
|
44
45
|
|
|
46
|
+
From a `path` to a `string` and a `base64` image encoded string. That is the goal.
|
|
47
|
+
|
|
45
48
|
## Very quickstart
|
|
46
49
|
|
|
47
50
|
```bash
|
|
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
|