Skip to content

Unable to fetch OpenAI Log Probs when enabled in ChatOptions #2737

@ndoe049

Description

@ndoe049

Bug description
When requesting logprobs generation from OpenAI via OpenAiChatOptions the logprobs are generated, but never returned as part of the ChatResponse.

OpenAiChatOptions.builder().logprobs(true).build()

Environment
Spring AI: 1.0.0-M7
Java: 21

Steps to reproduce

  1. Configure ChatClient with logprobs enabled in the ChatOptions
  2. Make Call to model

Expected behavior
Similar to other metadata, logprobs should be returned as part of the metadata.

i.e.

chatClient.call()
				.chatResponse()
				.getMetadata()
				.get("logprobs");

Minimal Complete Reproducible example

@Bean
	ApplicationRunner applicationRunner(ChatClient.Builder builder) {
		return args -> System.out.println(builder
				.defaultAdvisors(new PromptChatMemoryAdvisor(new InMemoryChatMemory()))
				.defaultOptions(OpenAiChatOptions.builder().logprobs(true).build())
				.build().prompt().system("You are a friendly assistant helping answer questions about pets")
				.user("What is the best pet?")
				.call()
				.chatResponse()
				.getMetadata()
				.keySet());
	}

Example Output:

[system-fingerprint, created]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions