HamaWhiteGG / langchain-java

Java version of LangChain, while empowering LLM for Big Data.
Apache License 2.0
545 stars 106 forks source link

hold "warning" filed when test in deprecated model like "text-davinci-003" #66

Closed wangmiao-1981 closed 1 year ago

wangmiao-1981 commented 1 year ago

the default completion model "text-davinci-003" is deprecated, a warning field appeared unexpected when run LLMChainTest.testLLMChainWithOneInputVariables.

resp looks like: { "warning": "This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations", "id": "cmpl-7jTUpXmJZSjbeWtljF6NykqeQMIYo", "object": "text_completion", "created": 1691072499, "model": "text-davinci-003", ... }

the crash report looks like: java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "warning" (class com.hw.openai.entity.completions.CompletionResp), not marked as ignorable (6 known properties: "usage", "choices", "created", "model", "id", "object"])

HamaWhiteGG commented 1 year ago

Thank you for your contribution. The description was very detailed.

Next time, could you remember to merge it into the 'dev' branch, Thanks.

mcheung610 commented 1 year ago

Can we fix the object mapper so it will ignore unknown fields by default?

HamaWhiteGG commented 1 year ago

Can we fix the object mapper so it will ignore unknown fields by default?

Good idea. I add objectMapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false) for OpenAiClient to ignore unknown fields, for example the warning field.