Commit 285b9ff
committed
Make Document support single text or media content
The Document class previously allowed multiple media entries while also having a
text field, leading to ambiguity in content handling. This change enforces a
clear separation between text and media documents to prevent content type
confusion and simplify document processing.
A Document now must contain either text content or a single media entry, but
never both. This aligns with the class's primary use in ETL pipelines where
clear content type boundaries are essential for proper embedding generation and
vector database storage.
Additional architectural changes:
- Document now implements a cleaner API by removing deprecated methods
- Removed MediaContent interface implementation from Document class
- Document.getMedia() now returns a single Media object instead of Collection
- Removed EMPTY_TEXT constant in favor of proper null handling
- Constructor signatures simplified and streamlined
- Builder pattern improved to enforce single content type constraint
The breaking changes include:
- Media is now a single entry instead of a collection
- Content field renamed to text for clarity
- Removed support for mixed content types
- Simplified builder API to prevent ambiguous construction
We prefer using text-related methods over deprecated content methods to
better reflect the actual content type being handled and improve API clarity.1 parent e01fd11 commit 285b9ff
File tree
186 files changed
+974
-829
lines changed- document-readers/markdown-reader/src/main/java/org/springframework/ai/reader/markdown
- models
- spring-ai-anthropic/src
- main/java/org/springframework/ai/anthropic
- test/java/org/springframework/ai/anthropic
- client
- spring-ai-azure-openai/src
- main/java/org/springframework/ai/azure/openai
- test/java/org/springframework/ai/azure/openai
- function
- metadata
- spring-ai-bedrock-converse/src
- main/java/org/springframework/ai/bedrock/converse
- test/java/org/springframework/ai/bedrock/converse
- spring-ai-bedrock/src
- main/java/org/springframework/ai/bedrock
- anthropic3
- test/java/org/springframework/ai/bedrock
- anthropic3
- anthropic
- cohere
- jurassic2
- llama
- titan
- spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/client
- spring-ai-minimax/src
- main/java/org/springframework/ai/minimax
- test/java/org/springframework/ai/minimax
- api
- chat
- spring-ai-mistral-ai/src
- main/java/org/springframework/ai/mistralai
- test/java/org/springframework/ai/mistralai
- spring-ai-moonshot/src
- main/java/org/springframework/ai/moonshot
- test/java/org/springframework/ai/moonshot
- chat
- spring-ai-oci-genai/src
- main/java/org/springframework/ai/oci/cohere
- test/java/org/springframework/ai/oci/cohere
- spring-ai-ollama/src
- main/java/org/springframework/ai/ollama
- test/java/org/springframework/ai/ollama
- spring-ai-openai/src
- main/java/org/springframework/ai/openai
- test/java/org/springframework/ai/openai
- chat
- client
- proxy
- testutils
- spring-ai-qianfan/src
- main/java/org/springframework/ai/qianfan
- test/java/org/springframework/ai/qianfan
- api
- chat
- spring-ai-vertex-ai-embedding/src
- main/java/org/springframework/ai/vertexai/embedding/multimodal
- test/java/org/springframework/ai/vertexai/embedding/multimodal
- spring-ai-vertex-ai-gemini/src
- main/java/org/springframework/ai/vertexai/gemini
- test/java/org/springframework/ai/vertexai/gemini
- function
- spring-ai-watsonx-ai/src/main/java/org/springframework/ai/watsonx/utils
- spring-ai-zhipuai/src
- main/java/org/springframework/ai/zhipuai
- test/java/org/springframework/ai/zhipuai
- api
- chat
- spring-ai-core/src
- main/java/org/springframework/ai
- chat
- client
- advisor
- messages
- model
- observation
- prompt
- document
- evaluation
- model
- tokenizer
- transformer
- vectorstore
- test/java/org/springframework/ai
- chat
- client
- advisor
- model
- document
- prompt
- vectorstore
- spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests
- client/advisor
- vectorstore
- spring-ai-spring-boot-autoconfigure/src/test
- java/org/springframework/ai/autoconfigure
- anthropic
- tool
- azure
- tool
- bedrock
- anthropic3
- anthropic
- cohere
- converse
- tool
- jurassic2
- llama
- titan
- chat/memory/cassandra
- huggingface
- minimax
- mistralai
- tool
- moonshot
- tool
- ollama
- tool
- openai
- tool
- qianfan
- vertexai/gemini
- tool
- zhipuai
- tool
- kotlin/org/springframework/ai/autoconfigure/ollama/tool
- spring-ai-test/src/main/java/org/springframework/ai/evaluation
- vector-stores
- spring-ai-azure-cosmos-db-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-azure-store/src/main/java/org/springframework/ai/vectorstore/azure
- spring-ai-cassandra-store/src/main/java/org/springframework/ai
- chat/memory
- vectorstore
- spring-ai-chroma-store/src
- main/java/org/springframework/ai/chroma/vectorstore
- test/java/org/springframework/ai/chroma/vectorstore
- spring-ai-coherence-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-gemfire-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-hanadb-store/src/test/java/org/springframework/ai/vectorstore
- spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-mongodb-atlas-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-oracle-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-pgvector-store/src
- main/java/org/springframework/ai/vectorstore
- test/java/org/springframework/ai/vectorstore
- spring-ai-pinecone-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant
- spring-ai-redis-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-typesense-store/src/main/java/org/springframework/ai/vectorstore
- spring-ai-weaviate-store/src/main/java/org/springframework/ai/vectorstore
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
186 files changed
+974
-829
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
399 | | - | |
| 398 | + | |
| 399 | + | |
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| |||
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
248 | | - | |
| 247 | + | |
| 248 | + | |
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
| 320 | + | |
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
| 405 | + | |
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
| 416 | + | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
| 428 | + | |
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
| 105 | + | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
0 commit comments