Skip to content

Commit 33a7241

Browse files
tzolovilayaperumalg
authored andcommitted
Remove deprecated output parser in favour of converter across the project
All output parser functionality has already been migrated to the converter package since milestone M1. Changes: - Replace all instances of 'parser' with 'converter' in variable names and test cases - Delete (pre M1) deprecated parser package and all associated classes - Remove Output Parsers section from README.md - Update Javadoc comments to reference converters instead of parsers
1 parent b66ffb4 commit 33a7241

File tree

16 files changed

+15
-485
lines changed

16 files changed

+15
-485
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ You can find more details in the [Reference Documentation](https://docs.spring.i
4343

4444
Please refer to the [Getting Started Guide](https://docs.spring.io/spring-ai/reference/getting-started.html) for instruction on adding your dependencies.
4545

46-
4746
## Cloning the repo
4847

4948
This repository contains [large model files](https://github.com/spring-projects/spring-ai/tree/main/models/spring-ai-transformers/src/main/resources/onnx/all-MiniLM-L6-v2).

models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiChatModelIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ void beanOutputConverterRecords() {
187187
@Test
188188
void beanStreamOutputConverterRecords() {
189189

190-
BeanOutputConverter<ActorsFilmsRecord> outputParser = new BeanOutputConverter<>(ActorsFilmsRecord.class);
190+
BeanOutputConverter<ActorsFilmsRecord> converter = new BeanOutputConverter<>(ActorsFilmsRecord.class);
191191

192-
String format = outputParser.getFormat();
192+
String format = converter.getFormat();
193193
String template = """
194194
Generate the filmography of 5 movies for Tom Hanks.
195195
{format}
@@ -208,7 +208,7 @@ void beanStreamOutputConverterRecords() {
208208
.filter(Objects::nonNull)
209209
.collect(Collectors.joining());
210210

211-
ActorsFilmsRecord actorsFilms = outputParser.convert(generationTextFromStream);
211+
ActorsFilmsRecord actorsFilms = converter.convert(generationTextFromStream);
212212
logger.info("" + actorsFilms);
213213
assertThat(actorsFilms.actor()).isEqualTo("Tom Hanks");
214214
assertThat(actorsFilms.movies()).hasSize(5);

models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicChatModelIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ void roleTest() {
111111
@Test
112112
void listOutputConverter() {
113113
DefaultConversionService conversionService = new DefaultConversionService();
114-
ListOutputConverter outputParser = new ListOutputConverter(conversionService);
114+
ListOutputConverter converter = new ListOutputConverter(conversionService);
115115

116-
String format = outputParser.getFormat();
116+
String format = converter.getFormat();
117117
String template = """
118118
List five {subject}
119119
{format}
@@ -123,7 +123,7 @@ void listOutputConverter() {
123123
Prompt prompt = new Prompt(promptTemplate.createMessage());
124124
Generation generation = this.chatModel.call(prompt).getResult();
125125

126-
List<String> list = outputParser.convert(generation.getOutput().getContent());
126+
List<String> list = converter.convert(generation.getOutput().getContent());
127127
assertThat(list).hasSize(5);
128128
}
129129

models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanChatModelIT.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ void roleTest() {
103103
assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard");
104104
}
105105

106-
// @Disabled("TODO: Fix the parser instructions to return the correct format")
107106
@Test
108107
void listOutputConverter() {
109108
DefaultConversionService conversionService = new DefaultConversionService();
@@ -123,7 +122,6 @@ void listOutputConverter() {
123122
assertThat(list).hasSize(5);
124123
}
125124

126-
// @Disabled("TODO: Fix the parser instructions to return the correct format")
127125
@Test
128126
void mapOutputConverter() {
129127
MapOutputConverter outputConverter = new MapOutputConverter();
@@ -148,7 +146,7 @@ void mapOutputConverter() {
148146
record ActorsFilmsRecord(String actor, List<String> movies) {
149147
}
150148

151-
@Disabled("TODO: Fix the parser instructions to return the correct format")
149+
@Disabled("TODO: Fix the converter instructions to return the correct format")
152150
@Test
153151
void beanOutputConverterRecords() {
154152

@@ -169,7 +167,7 @@ void beanOutputConverterRecords() {
169167
assertThat(actorsFilms.movies()).hasSize(5);
170168
}
171169

172-
@Disabled("TODO: Fix the parser instructions to return the correct format")
170+
@Disabled("TODO: Fix the converter instructions to return the correct format")
173171
@Test
174172
void beanStreamOutputConverterRecords() {
175173

models/spring-ai-moonshot/src/test/java/org/springframework/ai/moonshot/chat/MoonshotChatModelIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void mapOutputConverter() {
122122
}
123123

124124
@Test
125-
void beanOutputParser() {
125+
void beanOutputConverter() {
126126

127127
BeanOutputConverter<ActorsFilms> outputConverter = new BeanOutputConverter<>(ActorsFilms.class);
128128

@@ -143,7 +143,7 @@ record ActorsFilmsRecord(String actor, List<String> movies) {
143143
}
144144

145145
@Test
146-
void beanOutputParserRecords() {
146+
void beanOutputConverterRecords() {
147147

148148
BeanOutputConverter<ActorsFilmsRecord> outputConverter = new BeanOutputConverter<>(ActorsFilmsRecord.class);
149149

@@ -170,7 +170,7 @@ void beanOutputParserRecords() {
170170
}
171171

172172
@Test
173-
void beanStreamOutputParserRecords() {
173+
void beanStreamOutputConverterRecords() {
174174

175175
BeanOutputConverter<ActorsFilmsRecord> outputConverter = new BeanOutputConverter<>(ActorsFilmsRecord.class);
176176

models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModelIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ private Prompt createPrompt(VertexAiGeminiChatOptions chatOptions) {
105105
@Test
106106
void listOutputConverter() {
107107
DefaultConversionService conversionService = new DefaultConversionService();
108-
ListOutputConverter outputParser = new ListOutputConverter(conversionService);
108+
ListOutputConverter converter = new ListOutputConverter(conversionService);
109109

110-
String format = outputParser.getFormat();
110+
String format = converter.getFormat();
111111
String template = """
112112
List five {subject}
113113
{format}
@@ -117,7 +117,7 @@ void listOutputConverter() {
117117
Prompt prompt = new Prompt(promptTemplate.createMessage());
118118
Generation generation = this.chatModel.call(prompt).getResult();
119119

120-
List<String> list = outputParser.convert(generation.getOutput().getContent());
120+
List<String> list = converter.convert(generation.getOutput().getContent());
121121
assertThat(list).hasSize(5);
122122
}
123123

spring-ai-core/src/main/java/org/springframework/ai/converter/BeanOutputConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
/**
4848
* An implementation of {@link StructuredOutputConverter} that transforms the LLM output
49-
* to a specific object type using JSON schema. This parser works by generating a JSON
49+
* to a specific object type using JSON schema. This converter works by generating a JSON
5050
* schema based on a given Java class or parameterized type reference, which is then used
5151
* to validate and transform the LLM output into the desired type.
5252
*

spring-ai-core/src/main/java/org/springframework/ai/parser/AbstractConversionServiceOutputParser.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

spring-ai-core/src/main/java/org/springframework/ai/parser/AbstractMessageConverterOutputParser.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)