-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add Content serialization support
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...runtime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/jackson/ContentMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.quarkiverse.langchain4j.openai.runtime.jackson; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
|
||
import dev.ai4j.openai4j.chat.Content; | ||
import io.quarkus.jackson.JacksonMixin; | ||
|
||
@JacksonMixin(Content.class) | ||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE) | ||
public abstract class ContentMixin { | ||
} |
11 changes: 11 additions & 0 deletions
11
...ime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/jackson/ContentTypeMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.quarkiverse.langchain4j.openai.runtime.jackson; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
|
||
import dev.ai4j.openai4j.chat.ContentType; | ||
import io.quarkus.jackson.JacksonMixin; | ||
|
||
@JacksonMixin(ContentType.class) | ||
@JsonSerialize(using = ContentTypeSerializer.class) | ||
public abstract class ContentTypeMixin { | ||
} |
21 changes: 21 additions & 0 deletions
21
...rc/main/java/io/quarkiverse/langchain4j/openai/runtime/jackson/ContentTypeSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkiverse.langchain4j.openai.runtime.jackson; | ||
|
||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
|
||
import dev.ai4j.openai4j.chat.ContentType; | ||
|
||
public class ContentTypeSerializer extends StdSerializer<ContentType> { | ||
public ContentTypeSerializer() { | ||
super(ContentType.class); | ||
} | ||
|
||
@Override | ||
public void serialize(ContentType value, JsonGenerator gen, SerializerProvider provider) throws IOException { | ||
gen.writeString(value.toString().toLowerCase(Locale.ROOT)); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...untime/src/main/java/io/quarkiverse/langchain4j/openai/runtime/jackson/ImageUrlMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.quarkiverse.langchain4j.openai.runtime.jackson; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
|
||
import dev.ai4j.openai4j.chat.ImageUrl; | ||
import io.quarkus.jackson.JacksonMixin; | ||
|
||
@JacksonMixin(ImageUrl.class) | ||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE) | ||
public abstract class ImageUrlMixin { | ||
} |