Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ To learn about the Prompt class, refer to the [Prompt API guide](https://docs.sp
Delve into PromptTemplates in our [concept guide](https://docs.spring.io/spring-ai/reference/concepts.html#_prompt_templates).
For a hands-on guide to PromptTemplate, see the [PromptTemplate API guide](https://docs.spring.io/spring-ai/reference/api/prompt-template.html).

**Output Parsers:** AI model outputs often come as raw `java.lang.String` values. Output Parsers restructure these raw strings into more programmer-friendly formats, such as CSV or JSON.

Get insights on Output Parsers in our [concept guide](https://docs.spring.io/spring-ai/reference/concepts.html#_output_parsing)..
For implementation details, visit the [StructuredOutputConverter API guide](https://docs.spring.io/spring-ai/reference/api/output-parser.html).

### Incorporating your data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ void beanOutputConverterRecords() {
@Test
void beanStreamOutputConverterRecords() {

BeanOutputConverter<ActorsFilmsRecord> outputParser = new BeanOutputConverter<>(ActorsFilmsRecord.class);
BeanOutputConverter<ActorsFilmsRecord> converter = new BeanOutputConverter<>(ActorsFilmsRecord.class);

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

ActorsFilmsRecord actorsFilms = outputParser.convert(generationTextFromStream);
ActorsFilmsRecord actorsFilms = converter.convert(generationTextFromStream);
logger.info("" + actorsFilms);
assertThat(actorsFilms.actor()).isEqualTo("Tom Hanks");
assertThat(actorsFilms.movies()).hasSize(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ void roleTest() {
@Test
void listOutputConverter() {
DefaultConversionService conversionService = new DefaultConversionService();
ListOutputConverter outputParser = new ListOutputConverter(conversionService);
ListOutputConverter converter = new ListOutputConverter(conversionService);

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

List<String> list = outputParser.convert(generation.getOutput().getContent());
List<String> list = converter.convert(generation.getOutput().getContent());
assertThat(list).hasSize(5);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ void roleTest() {
assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard");
}

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

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

@Disabled("TODO: Fix the parser instructions to return the correct format")
@Disabled("TODO: Fix the converter instructions to return the correct format")
@Test
void beanOutputConverterRecords() {

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

@Disabled("TODO: Fix the parser instructions to return the correct format")
@Disabled("TODO: Fix the converter instructions to return the correct format")
@Test
void beanStreamOutputConverterRecords() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void mapOutputConverter() {
}

@Test
void beanOutputParser() {
void beanOutputConverter() {

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

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

@Test
void beanOutputParserRecords() {
void beanOutputConverterRecords() {

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

Expand All @@ -170,7 +170,7 @@ void beanOutputParserRecords() {
}

@Test
void beanStreamOutputParserRecords() {
void beanStreamOutputConverterRecords() {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ private Prompt createPrompt(VertexAiGeminiChatOptions chatOptions) {
@Test
void listOutputConverter() {
DefaultConversionService conversionService = new DefaultConversionService();
ListOutputConverter outputParser = new ListOutputConverter(conversionService);
ListOutputConverter converter = new ListOutputConverter(conversionService);

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

List<String> list = outputParser.convert(generation.getOutput().getContent());
List<String> list = converter.convert(generation.getOutput().getContent());
assertThat(list).hasSize(5);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

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

This file was deleted.

This file was deleted.

Loading