forked from quarkiverse/quarkus-langchain4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to the JsonSchemaElement API
Closes quarkiverse#1054
- Loading branch information
Showing
11 changed files
with
88 additions
and
267 deletions.
There are no files selected for viewing
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
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
26 changes: 9 additions & 17 deletions
26
...ain/java/io/quarkiverse/langchain4j/runtime/tool/JsonBooleanSchemaObjectSubstitution.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 |
---|---|---|
@@ -1,34 +1,26 @@ | ||
package io.quarkiverse.langchain4j.runtime.tool; | ||
|
||
import dev.langchain4j.model.chat.request.json.JsonBooleanSchema; | ||
import dev.langchain4j.model.chat.request.json.JsonSchemaElement; | ||
import io.quarkus.runtime.ObjectSubstitution; | ||
import io.quarkus.runtime.annotations.RecordableConstructor; | ||
|
||
public final class JsonBooleanSchemaObjectSubstitution extends JsonSchemaElementObjectSubstitution { | ||
public class JsonBooleanSchemaObjectSubstitution | ||
implements ObjectSubstitution<JsonBooleanSchema, JsonBooleanSchemaObjectSubstitution.Serialized> { | ||
@Override | ||
public JsonBooleanSchemaObjectSubstitution.Serialized serialize(JsonSchemaElement obj) { | ||
var b = (JsonBooleanSchema) obj; | ||
return new Serialized(b.description()); | ||
public Serialized serialize(JsonBooleanSchema obj) { | ||
return new Serialized(obj.description()); | ||
} | ||
|
||
@Override | ||
public JsonBooleanSchema deserialize(JsonSchemaElementObjectSubstitution.Serialized obj) { | ||
var b = (JsonBooleanSchemaObjectSubstitution.Serialized) obj; | ||
public JsonBooleanSchema deserialize(Serialized obj) { | ||
return JsonBooleanSchema.builder() | ||
.description(b.description) | ||
.description(obj.description) | ||
.build(); | ||
} | ||
|
||
public static final class Serialized extends JsonSchemaElementObjectSubstitution.Serialized { | ||
private final String description; | ||
|
||
public record Serialized(String description) { | ||
@RecordableConstructor | ||
public Serialized(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
public Serialized { | ||
} | ||
} | ||
} |
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
26 changes: 9 additions & 17 deletions
26
...ain/java/io/quarkiverse/langchain4j/runtime/tool/JsonIntegerSchemaObjectSubstitution.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 |
---|---|---|
@@ -1,34 +1,26 @@ | ||
package io.quarkiverse.langchain4j.runtime.tool; | ||
|
||
import dev.langchain4j.model.chat.request.json.JsonIntegerSchema; | ||
import dev.langchain4j.model.chat.request.json.JsonSchemaElement; | ||
import io.quarkus.runtime.ObjectSubstitution; | ||
import io.quarkus.runtime.annotations.RecordableConstructor; | ||
|
||
public final class JsonIntegerSchemaObjectSubstitution extends JsonSchemaElementObjectSubstitution { | ||
public final class JsonIntegerSchemaObjectSubstitution | ||
implements ObjectSubstitution<JsonIntegerSchema, JsonIntegerSchemaObjectSubstitution.Serialized> { | ||
@Override | ||
public JsonIntegerSchemaObjectSubstitution.Serialized serialize(JsonSchemaElement obj) { | ||
var i = (JsonIntegerSchema) obj; | ||
return new Serialized(i.description()); | ||
public Serialized serialize(JsonIntegerSchema obj) { | ||
return new Serialized(obj.description()); | ||
} | ||
|
||
@Override | ||
public JsonIntegerSchema deserialize(JsonSchemaElementObjectSubstitution.Serialized obj) { | ||
var i = (JsonIntegerSchemaObjectSubstitution.Serialized) obj; | ||
public JsonIntegerSchema deserialize(Serialized obj) { | ||
return JsonIntegerSchema.builder() | ||
.description(i.description) | ||
.description(obj.description) | ||
.build(); | ||
} | ||
|
||
public static final class Serialized extends JsonSchemaElementObjectSubstitution.Serialized { | ||
private final String description; | ||
|
||
public record Serialized(String description) { | ||
@RecordableConstructor | ||
public Serialized(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
public Serialized { | ||
} | ||
} | ||
} |
26 changes: 9 additions & 17 deletions
26
...main/java/io/quarkiverse/langchain4j/runtime/tool/JsonNumberSchemaObjectSubstitution.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 |
---|---|---|
@@ -1,34 +1,26 @@ | ||
package io.quarkiverse.langchain4j.runtime.tool; | ||
|
||
import dev.langchain4j.model.chat.request.json.JsonNumberSchema; | ||
import dev.langchain4j.model.chat.request.json.JsonSchemaElement; | ||
import io.quarkus.runtime.ObjectSubstitution; | ||
import io.quarkus.runtime.annotations.RecordableConstructor; | ||
|
||
public final class JsonNumberSchemaObjectSubstitution extends JsonSchemaElementObjectSubstitution { | ||
public class JsonNumberSchemaObjectSubstitution | ||
implements ObjectSubstitution<JsonNumberSchema, JsonNumberSchemaObjectSubstitution.Serialized> { | ||
@Override | ||
public JsonNumberSchemaObjectSubstitution.Serialized serialize(JsonSchemaElement obj) { | ||
var n = (JsonNumberSchema) obj; | ||
return new Serialized(n.description()); | ||
public Serialized serialize(JsonNumberSchema obj) { | ||
return new Serialized(obj.description()); | ||
} | ||
|
||
@Override | ||
public JsonNumberSchema deserialize(JsonSchemaElementObjectSubstitution.Serialized obj) { | ||
var n = (JsonNumberSchemaObjectSubstitution.Serialized) obj; | ||
public JsonNumberSchema deserialize(Serialized obj) { | ||
return JsonNumberSchema.builder() | ||
.description(n.description) | ||
.description(obj.description) | ||
.build(); | ||
} | ||
|
||
public static final class Serialized extends JsonSchemaElementObjectSubstitution.Serialized { | ||
private final String description; | ||
|
||
public record Serialized(String description) { | ||
@RecordableConstructor | ||
public Serialized(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
public Serialized { | ||
} | ||
} | ||
} |
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
26 changes: 9 additions & 17 deletions
26
...n/java/io/quarkiverse/langchain4j/runtime/tool/JsonReferenceSchemaObjectSubstitution.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 |
---|---|---|
@@ -1,32 +1,24 @@ | ||
package io.quarkiverse.langchain4j.runtime.tool; | ||
|
||
import dev.langchain4j.model.chat.request.json.JsonReferenceSchema; | ||
import dev.langchain4j.model.chat.request.json.JsonSchemaElement; | ||
import io.quarkus.runtime.ObjectSubstitution; | ||
import io.quarkus.runtime.annotations.RecordableConstructor; | ||
|
||
public final class JsonReferenceSchemaObjectSubstitution extends JsonSchemaElementObjectSubstitution { | ||
public JsonReferenceSchemaObjectSubstitution.Serialized serialize(JsonSchemaElement obj) { | ||
var r = (JsonReferenceSchema) obj; | ||
return new Serialized(r.reference()); | ||
public class JsonReferenceSchemaObjectSubstitution | ||
implements ObjectSubstitution<JsonReferenceSchema, JsonReferenceSchemaObjectSubstitution.Serialized> { | ||
public Serialized serialize(JsonReferenceSchema obj) { | ||
return new Serialized(obj.reference()); | ||
} | ||
|
||
public JsonReferenceSchema deserialize(JsonSchemaElementObjectSubstitution.Serialized obj) { | ||
var r = (JsonReferenceSchemaObjectSubstitution.Serialized) obj; | ||
public JsonReferenceSchema deserialize(Serialized obj) { | ||
return JsonReferenceSchema.builder() | ||
.reference(r.reference) | ||
.reference(obj.reference) | ||
.build(); | ||
} | ||
|
||
public static final class Serialized extends JsonSchemaElementObjectSubstitution.Serialized { | ||
private final String reference; | ||
|
||
public record Serialized(String reference) { | ||
@RecordableConstructor | ||
public Serialized(String reference) { | ||
this.reference = reference; | ||
} | ||
|
||
public String getReference() { | ||
return reference; | ||
public Serialized { | ||
} | ||
} | ||
} |
Oops, something went wrong.