类 OpenAIResponseParser

java.lang.Object
io.agentscope.core.formatter.openai.OpenAIResponseParser

public class OpenAIResponseParser extends Object
Parses OpenAI HTTP API responses to AgentScope ChatResponse. Handles both non-streaming and streaming (chunk) responses using DTO classes.
  • 字段详细资料

    • FRAGMENT_PLACEHOLDER

      protected static final String FRAGMENT_PLACEHOLDER
      Placeholder name for tool call argument fragments in streaming responses.
      另请参阅:
  • 构造器详细资料

    • OpenAIResponseParser

      public OpenAIResponseParser()
  • 方法详细资料

    • parseResponse

      public ChatResponse parseResponse(OpenAIResponse response, Instant startTime)
      Parse OpenAI response DTO to AgentScope ChatResponse.
      参数:
      response - OpenAI response DTO
      startTime - Request start time for calculating duration
      返回:
      AgentScope ChatResponse
    • parseCompletionResponse

      protected ChatResponse parseCompletionResponse(OpenAIResponse response, Instant startTime)
      Parse OpenAI non-streaming response.
      参数:
      response - OpenAI response DTO
      startTime - Request start time
      返回:
      AgentScope ChatResponse
    • parseChunkResponse

      protected ChatResponse parseChunkResponse(OpenAIResponse response, Instant startTime)
      Parse OpenAI streaming response chunk.
      参数:
      response - OpenAI chunk response DTO
      startTime - Request start time
      返回:
      AgentScope ChatResponse (or null for malformed chunks)