[Docs] Streaming example diff logic for reasoning_details doesn't match actual API behavior

Abierto
#95 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

Open the linked OpenAI-compatible streaming example in the API documentation and inspect how it processes reasoning_details[].text and updates reasoning_buffer. Check whether the example's diff logic matches the reported incremental chunks; the documentation is done when it handles the reported behavior correctly and clarifies any difference between the two API endpoints if confirmed.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem

In the OpenAI-compatible API streaming example, reasoning_details is processed with a diff approach:

reasoning_text = detail["text"]
new_reasoning = reasoning_text[len(reasoning_buffer):]
reasoning_buffer = reasoning_text

This assumes reasoning_details[].text is cumulative (full text so far), requiring a diff against the buffer to extract the new portion.

Actual Behavior

Testing against api.minimaxi.com/v1 with MiniMax-M2.7, reasoning_details[].text returns incremental text, not cumulative:

chunk1: text="The user"
chunk2: text=" is asking how I am, which is a simple greeting."

chunk2 does not contain chunk1's "The user" — it's already just the new part.

Bug

Applying diff logic to incremental text truncates the beginning of each chunk:

chunk1: buf="", text="The user", text[0:] = "The user"       ✅ happens to work
chunk2: buf="The user"(len=8), text=" is asking...", text[8:] = "king..."  ❌ truncated

Reproduction

from openai import OpenAI

client = OpenAI(
    api_key="sk-xxx",
    base_url="https://api.minimaxi.com/v1",
)

stream = client.chat.completions.create(
    model="MiniMax-M2.7",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hi, how are you?"},
    ],
    extra_body={"reasoning_split": True},
    stream=True,
)

for chunk in stream:
    if (
        hasattr(chunk.choices[0].delta, "reasoning_details")
        and chunk.choices[0].delta.reasoning_details
    ):
        for detail in chunk.choices[0].delta.reasoning_details:
            if "text" in detail:
                text = detail["text"]
                print(f"len={len(text)} text={repr(text)}")

Suggested Fix

If reasoning_details[].text is incremental, the example should simply concatenate:

for detail in chunk.choices[0].delta.reasoning_details:
    if "text" in detail:
        text = detail["text"]
        print(text, end="", flush=True)
        reasoning_buffer += text

Also, if api.minimax.io (international) and api.minimaxi.com (China mainland) behave differently for this field, it would be helpful to note that in the docs.

Lenguaje dominante
Sin datos de lenguaje
Estrellas
2.6k
Forks
216
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MiniMax-AI/MiniMax-M2

Todos los issues de MiniMax-AI/MiniMax-M2

Issues similares

Más issues de Documentation

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.