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

Default extra_body configuration lost when generating API documentation, use api also have this behavior #698

Open
xiaojinwhu opened this issue Jun 29, 2024 · 1 comment

Comments

@xiaojinwhu
Copy link

Description:

I've encountered an issue where the default value for extra_body in the configurable field is being lost when LangServe generates the API documentation. This results in the API expecting the client to explicitly provide the extra_body value, which should not be necessary as it should have a server-side default.

Steps to Reproduce:

  1. Create a runnable with a default extra_body configuration:

    structured_llm = llm.with_config(
        configurable={
            "extra_body": {"guided_json": QuotedAnswer.schema_json(ensure_ascii=False)}
        }
    )
  2. Add routes using LangServe's add_routes function.

the example value is

{
  "input": "string",
  "config": {
    "configurable": {
      "extra_body: {}
    },
  },
  "kwargs": {},
}

It lost the QuotedAnswer.schema_json(ensure_ascii=False) value

Expected Behavior:
The API documentation should show the default value for extra_body in the configurable field, and the server should use this default value if not provided by the client.
Actual Behavior:
The API documentation shows extra_body as None, and the server expects the client to provide the extra_body value explicitly.
Additional Information:

When debugging, I found that the incoming_config in the _unpack_request_config function already has extra_body set to None:
pythonCopy{'configurable': {'extra_body': None, 'llm': 'vllm', 'llm_temperature': 0.0, 'search_kwargs': {'expr': 'patient_id == "EY1006608"'}}}

The issue seems to occur during the API documentation generation process, as the default value is lost at this stage.

Attempted Solutions:

Checked and confirmed that the runnable's initial configuration correctly includes the extra_body value.
Tried modifying the APIHandler class to set a default value for extra_body if it's None.
Explored using custom ConfigurableField to always provide a default value.
Attempted to modify the add_routes function to include default value handling.

None of these solutions have resolved the issue. The default value is still not being reflected in the API documentation or being used by the server when not provided by the client.
Environment:

LangServe version: 0.2.2
LangChain version: 02.2
Python version: 3.10

@xiaojinwhu
Copy link
Author

xiaojinwhu commented Jun 29, 2024

same as
#809
#377

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

No branches or pull requests

1 participant