To improve input/output formatting in Phoenix UI for LangChain traces, ensure you are using the latest version of the OpenInference LangChain instrumentor, which automatically sets the input and output columns to the user query and LLM response. If your input/output appears as a large JSON object, it's likely because the chain is passing a dictionary or complex object as input/output, rather than a simple string. You can customize this by extracting the relevant fields (e.g., user query and LLM response) and setting them as the span's input/output values using the tracer's set_input and set_output methods within your chain or callback logic, or by post-processing the spans DataFrame before logging or displaying it in Phoenix UI. See <https://github.com/Arize-ai/phoenix/blob/main/docs/tracing/how-to-tracing/instrument-python.md|instrument-python.md> and <https://docs.arize.com/phoenix/~/changes/v6Zhm276x8LlKmwqElIA/integrations/langchain|langchain integration docs>.
If you want the UI to render only the user query and LLM response, ensure your chain returns and receives plain text, or manually set the input/output attributes to those values. For more advanced customization, you can post-process the spans DataFrame (using get_spans_dataframe) to overwrite the input/output columns with the desired fields before further analysis or display (<https://arize-ai.slack.com/archives/C04R3GXC8HK/p1722937606.374229|slack reference>). Would you like a code example for customizing the input/output fields?
Sources:
- <https://github.com/Arize-ai/phoenix/blob/main/docs/tracing/how-to-tracing/instrument-python.md|instrument-python.md>
- <https://arize-ai.slack.com/archives/C04R3GXC8HK/p1722937606.374229|Slack: customizing spans DataFrame>
- <https://docs.arize.com/phoenix/~/changes/v6Zhm276x8LlKmwqElIA/integrations/langchain|langchain integration docs>