attachments 0.2.3__tar.gz → 0.2.4__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.
Files changed (33) hide show
  1. {attachments-0.2.3/src/attachments.egg-info → attachments-0.2.4}/PKG-INFO +38 -1
  2. {attachments-0.2.3 → attachments-0.2.4}/README.md +37 -0
  3. {attachments-0.2.3 → attachments-0.2.4}/pyproject.toml +1 -1
  4. {attachments-0.2.3 → attachments-0.2.4/src/attachments.egg-info}/PKG-INFO +38 -1
  5. {attachments-0.2.3 → attachments-0.2.4}/LICENSE +0 -0
  6. {attachments-0.2.3 → attachments-0.2.4}/setup.cfg +0 -0
  7. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/__init__.py +0 -0
  8. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/audio_processing.py +0 -0
  9. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/config.py +0 -0
  10. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/core.py +0 -0
  11. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/detectors.py +0 -0
  12. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/exceptions.py +0 -0
  13. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/image_processing.py +0 -0
  14. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/office_contact_sheet.py +0 -0
  15. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/parsers.py +0 -0
  16. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/renderers.py +0 -0
  17. {attachments-0.2.3 → attachments-0.2.4}/src/attachments/utils.py +0 -0
  18. {attachments-0.2.3 → attachments-0.2.4}/src/attachments.egg-info/SOURCES.txt +0 -0
  19. {attachments-0.2.3 → attachments-0.2.4}/src/attachments.egg-info/dependency_links.txt +0 -0
  20. {attachments-0.2.3 → attachments-0.2.4}/src/attachments.egg-info/requires.txt +0 -0
  21. {attachments-0.2.3 → attachments-0.2.4}/src/attachments.egg-info/top_level.txt +0 -0
  22. {attachments-0.2.3 → attachments-0.2.4}/tests/test_audio_processing.py +0 -0
  23. {attachments-0.2.3 → attachments-0.2.4}/tests/test_base.py +0 -0
  24. {attachments-0.2.3 → attachments-0.2.4}/tests/test_core_functionality.py +0 -0
  25. {attachments-0.2.3 → attachments-0.2.4}/tests/test_document_parsing.py +0 -0
  26. {attachments-0.2.3 → attachments-0.2.4}/tests/test_html_parsing.py +0 -0
  27. {attachments-0.2.3 → attachments-0.2.4}/tests/test_image_processing.py +0 -0
  28. {attachments-0.2.3 → attachments-0.2.4}/tests/test_indexing_slicing.py +0 -0
  29. {attachments-0.2.3 → attachments-0.2.4}/tests/test_markdown_rendering.py +0 -0
  30. {attachments-0.2.3 → attachments-0.2.4}/tests/test_office_contact_sheet.py +0 -0
  31. {attachments-0.2.3 → attachments-0.2.4}/tests/test_pdf_parsing.py +0 -0
  32. {attachments-0.2.3 → attachments-0.2.4}/tests/test_pptx_parsing.py +0 -0
  33. {attachments-0.2.3 → attachments-0.2.4}/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
3
+ Version: 0.2.4
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
@@ -121,6 +121,43 @@ message = anthropic.Anthropic().messages.create(
121
121
  print(message.content)
122
122
  ```
123
123
 
124
+ ## How to give a word document (with tables and images) to langchain?
125
+
126
+ I am not a fan of the object that langchain and anthropic make you create, but hey!, I don't make the rules...
127
+
128
+ ```python
129
+ from langchain.chat_models import init_chat_model
130
+ from attachments import Attachments
131
+
132
+ docx_file = Attachments("https://github.com/microsoft/markitdown/raw/refs/heads/main/packages/markitdown/tests/test_files/test.docx")
133
+
134
+ llm = init_chat_model("anthropic:claude-3-5-sonnet-latest")
135
+
136
+ # Creation of a list of object as expected by langchain/anthropic
137
+ content = [{"type": "text", "text": f"Analyze the following documents: {docx_file}"}]
138
+
139
+ for image in docx_file.images
140
+ media_type_i = image.split(";")[0].split(":")[1]
141
+ media_data_i = image.split(",")[1]
142
+ content.append({
143
+ "type": "image",
144
+ "source": {
145
+ "type": "base64",
146
+ "media_type": media_type_i,
147
+ "data": media_data_i
148
+ }
149
+ })
150
+
151
+
152
+ message = {
153
+ "role": "user",
154
+ "content": content,
155
+ }
156
+
157
+ #Finally call the llm
158
+ response = llm.invoke([message])
159
+ print(response.text())
160
+ ```
124
161
 
125
162
  ## Usage
126
163
 
@@ -82,6 +82,43 @@ message = anthropic.Anthropic().messages.create(
82
82
  print(message.content)
83
83
  ```
84
84
 
85
+ ## How to give a word document (with tables and images) to langchain?
86
+
87
+ I am not a fan of the object that langchain and anthropic make you create, but hey!, I don't make the rules...
88
+
89
+ ```python
90
+ from langchain.chat_models import init_chat_model
91
+ from attachments import Attachments
92
+
93
+ docx_file = Attachments("https://github.com/microsoft/markitdown/raw/refs/heads/main/packages/markitdown/tests/test_files/test.docx")
94
+
95
+ llm = init_chat_model("anthropic:claude-3-5-sonnet-latest")
96
+
97
+ # Creation of a list of object as expected by langchain/anthropic
98
+ content = [{"type": "text", "text": f"Analyze the following documents: {docx_file}"}]
99
+
100
+ for image in docx_file.images
101
+ media_type_i = image.split(";")[0].split(":")[1]
102
+ media_data_i = image.split(",")[1]
103
+ content.append({
104
+ "type": "image",
105
+ "source": {
106
+ "type": "base64",
107
+ "media_type": media_type_i,
108
+ "data": media_data_i
109
+ }
110
+ })
111
+
112
+
113
+ message = {
114
+ "role": "user",
115
+ "content": content,
116
+ }
117
+
118
+ #Finally call the llm
119
+ response = llm.invoke([message])
120
+ print(response.text())
121
+ ```
85
122
 
86
123
  ## Usage
87
124
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "attachments"
7
- version = "0.2.3"
7
+ version = "0.2.4"
8
8
  authors = [
9
9
  { name="Maxim Rivest", email="mrive052@gmail.com" },
10
10
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: attachments
3
- Version: 0.2.3
3
+ Version: 0.2.4
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
@@ -121,6 +121,43 @@ message = anthropic.Anthropic().messages.create(
121
121
  print(message.content)
122
122
  ```
123
123
 
124
+ ## How to give a word document (with tables and images) to langchain?
125
+
126
+ I am not a fan of the object that langchain and anthropic make you create, but hey!, I don't make the rules...
127
+
128
+ ```python
129
+ from langchain.chat_models import init_chat_model
130
+ from attachments import Attachments
131
+
132
+ docx_file = Attachments("https://github.com/microsoft/markitdown/raw/refs/heads/main/packages/markitdown/tests/test_files/test.docx")
133
+
134
+ llm = init_chat_model("anthropic:claude-3-5-sonnet-latest")
135
+
136
+ # Creation of a list of object as expected by langchain/anthropic
137
+ content = [{"type": "text", "text": f"Analyze the following documents: {docx_file}"}]
138
+
139
+ for image in docx_file.images
140
+ media_type_i = image.split(";")[0].split(":")[1]
141
+ media_data_i = image.split(",")[1]
142
+ content.append({
143
+ "type": "image",
144
+ "source": {
145
+ "type": "base64",
146
+ "media_type": media_type_i,
147
+ "data": media_data_i
148
+ }
149
+ })
150
+
151
+
152
+ message = {
153
+ "role": "user",
154
+ "content": content,
155
+ }
156
+
157
+ #Finally call the llm
158
+ response = llm.invoke([message])
159
+ print(response.text())
160
+ ```
124
161
 
125
162
  ## Usage
126
163
 
File without changes
File without changes