Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ollama Illegal unquoted character #650

Closed
humcqc opened this issue Jun 3, 2024 · 2 comments · Fixed by #651
Closed

Ollama Illegal unquoted character #650

humcqc opened this issue Jun 3, 2024 · 2 comments · Fixed by #651

Comments

@humcqc
Copy link
Contributor

humcqc commented Jun 3, 2024

In some case, Ollama send response containing Illegal unquoted character in a field of a json document:

2024-06-03 14:50:02,861 ERROR [io.qua.lan.run.ais.AiServiceMethodImplementationSupport] (executor-thread-1) Execution of com.cqc.syndifun.celia.ai.CeliaService#chat failed: java.io.UncheckedIOException: com.fasterxml.jackson.databind.JsonMappingException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 2, column: 105] (through reference chain: com.cqc.syndifun.celia.ai.ChatResponse["answer"])

Workaround, configure the object mapper in your application.

@Singleton
@SuppressWarnings("unused")
public class ObjectMapperConfiguration implements ObjectMapperCustomizer {

    public void customize(ObjectMapper mapper) {
        // Avoid Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value
        // Needed for AI
        mapper.configure(
                JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(),
                true
        );
    }
}

Perhaps if this is the way to go, we can integrate this configuration directly in quarkus-langchain4j ?

@geoand
Copy link
Collaborator

geoand commented Jun 3, 2024

How can one reproduce this problem?

In any case, the proposed solution seems reasonable

humcqc added a commit to humcqc/quarkus-langchain4j that referenced this issue Jun 3, 2024
@humcqc
Copy link
Contributor Author

humcqc commented Jun 3, 2024

How can one reproduce this problem?

In any case, the proposed solution seems reasonable

@geoand PR with the test case #651

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants