attachments 0.2.2__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.2/src/attachments.egg-info → attachments-0.2.4}/PKG-INFO +72 -1
  2. {attachments-0.2.2 → attachments-0.2.4}/README.md +71 -0
  3. {attachments-0.2.2 → attachments-0.2.4}/pyproject.toml +1 -1
  4. {attachments-0.2.2 → attachments-0.2.4/src/attachments.egg-info}/PKG-INFO +72 -1
  5. {attachments-0.2.2 → attachments-0.2.4}/LICENSE +0 -0
  6. {attachments-0.2.2 → attachments-0.2.4}/setup.cfg +0 -0
  7. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/__init__.py +0 -0
  8. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/audio_processing.py +0 -0
  9. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/config.py +0 -0
  10. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/core.py +0 -0
  11. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/detectors.py +0 -0
  12. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/exceptions.py +0 -0
  13. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/image_processing.py +0 -0
  14. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/office_contact_sheet.py +0 -0
  15. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/parsers.py +0 -0
  16. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/renderers.py +0 -0
  17. {attachments-0.2.2 → attachments-0.2.4}/src/attachments/utils.py +0 -0
  18. {attachments-0.2.2 → attachments-0.2.4}/src/attachments.egg-info/SOURCES.txt +0 -0
  19. {attachments-0.2.2 → attachments-0.2.4}/src/attachments.egg-info/dependency_links.txt +0 -0
  20. {attachments-0.2.2 → attachments-0.2.4}/src/attachments.egg-info/requires.txt +0 -0
  21. {attachments-0.2.2 → attachments-0.2.4}/src/attachments.egg-info/top_level.txt +0 -0
  22. {attachments-0.2.2 → attachments-0.2.4}/tests/test_audio_processing.py +0 -0
  23. {attachments-0.2.2 → attachments-0.2.4}/tests/test_base.py +0 -0
  24. {attachments-0.2.2 → attachments-0.2.4}/tests/test_core_functionality.py +0 -0
  25. {attachments-0.2.2 → attachments-0.2.4}/tests/test_document_parsing.py +0 -0
  26. {attachments-0.2.2 → attachments-0.2.4}/tests/test_html_parsing.py +0 -0
  27. {attachments-0.2.2 → attachments-0.2.4}/tests/test_image_processing.py +0 -0
  28. {attachments-0.2.2 → attachments-0.2.4}/tests/test_indexing_slicing.py +0 -0
  29. {attachments-0.2.2 → attachments-0.2.4}/tests/test_markdown_rendering.py +0 -0
  30. {attachments-0.2.2 → attachments-0.2.4}/tests/test_office_contact_sheet.py +0 -0
  31. {attachments-0.2.2 → attachments-0.2.4}/tests/test_pdf_parsing.py +0 -0
  32. {attachments-0.2.2 → attachments-0.2.4}/tests/test_pptx_parsing.py +0 -0
  33. {attachments-0.2.2 → 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.2
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
@@ -88,6 +88,77 @@ response = OpenAI().responses.create(model="gpt-4.1-nano", input=[{"role": "user
88
88
  response.output_text
89
89
  ```
90
90
 
91
+ ## How to give attachments to anthropic llms?
92
+
93
+ ```python
94
+ import anthropic
95
+ from attachments import Attachments
96
+
97
+ pptx_file = Attachments(
98
+ "https://github.com/microsoft/markitdown/raw/refs/heads/main/packages/markitdown/tests/test_files/test.pptx")
99
+
100
+ prompt = f"""
101
+ Analyze the following documents:
102
+ {pptx_file}
103
+ """
104
+
105
+ content = [
106
+ {
107
+ "type": "image",
108
+ "source": {
109
+ "type": "base64",
110
+ "media_type": image.split(";")[0].split(":")[1], # this is ugly but it works
111
+ "data": image.split(",")[1] # this is ugly but it works
112
+ }
113
+ }
114
+ for image in pptx_file.images
115
+ ] + [{"type": "text", "text": prompt}]
116
+
117
+ message = anthropic.Anthropic().messages.create(
118
+ max_tokens=8192,
119
+ model="claude-3-5-haiku-20241022",
120
+ messages=[{"role": "user", "content": content}])
121
+ print(message.content)
122
+ ```
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
+ ```
161
+
91
162
  ## Usage
92
163
 
93
164
  ### Basic Initialization
@@ -49,6 +49,77 @@ response = OpenAI().responses.create(model="gpt-4.1-nano", input=[{"role": "user
49
49
  response.output_text
50
50
  ```
51
51
 
52
+ ## How to give attachments to anthropic llms?
53
+
54
+ ```python
55
+ import anthropic
56
+ from attachments import Attachments
57
+
58
+ pptx_file = Attachments(
59
+ "https://github.com/microsoft/markitdown/raw/refs/heads/main/packages/markitdown/tests/test_files/test.pptx")
60
+
61
+ prompt = f"""
62
+ Analyze the following documents:
63
+ {pptx_file}
64
+ """
65
+
66
+ content = [
67
+ {
68
+ "type": "image",
69
+ "source": {
70
+ "type": "base64",
71
+ "media_type": image.split(";")[0].split(":")[1], # this is ugly but it works
72
+ "data": image.split(",")[1] # this is ugly but it works
73
+ }
74
+ }
75
+ for image in pptx_file.images
76
+ ] + [{"type": "text", "text": prompt}]
77
+
78
+ message = anthropic.Anthropic().messages.create(
79
+ max_tokens=8192,
80
+ model="claude-3-5-haiku-20241022",
81
+ messages=[{"role": "user", "content": content}])
82
+ print(message.content)
83
+ ```
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
+ ```
122
+
52
123
  ## Usage
53
124
 
54
125
  ### Basic Initialization
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "attachments"
7
- version = "0.2.2"
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.2
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
@@ -88,6 +88,77 @@ response = OpenAI().responses.create(model="gpt-4.1-nano", input=[{"role": "user
88
88
  response.output_text
89
89
  ```
90
90
 
91
+ ## How to give attachments to anthropic llms?
92
+
93
+ ```python
94
+ import anthropic
95
+ from attachments import Attachments
96
+
97
+ pptx_file = Attachments(
98
+ "https://github.com/microsoft/markitdown/raw/refs/heads/main/packages/markitdown/tests/test_files/test.pptx")
99
+
100
+ prompt = f"""
101
+ Analyze the following documents:
102
+ {pptx_file}
103
+ """
104
+
105
+ content = [
106
+ {
107
+ "type": "image",
108
+ "source": {
109
+ "type": "base64",
110
+ "media_type": image.split(";")[0].split(":")[1], # this is ugly but it works
111
+ "data": image.split(",")[1] # this is ugly but it works
112
+ }
113
+ }
114
+ for image in pptx_file.images
115
+ ] + [{"type": "text", "text": prompt}]
116
+
117
+ message = anthropic.Anthropic().messages.create(
118
+ max_tokens=8192,
119
+ model="claude-3-5-haiku-20241022",
120
+ messages=[{"role": "user", "content": content}])
121
+ print(message.content)
122
+ ```
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
+ ```
161
+
91
162
  ## Usage
92
163
 
93
164
  ### Basic Initialization
File without changes
File without changes