Updates to the ChatGenerator protocol

Abierto
#10,992 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
20/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python

Línea de trabajo

Comienza localizando el protocolo ChatGenerator y sus implementaciones; después, revisa cómo se utilizan los valores de retorno de run y los métodos run_async en todo el código. Consulta las issues #8858 y #1379 para conocer el trabajo asíncrono existente. Se consideraría terminado cuando exista un diseño de protocolo acordado y se hayan abordado sus implicaciones de tipado y asincronía, aunque la issue indica que este trabajo se gestiona internamente.

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

Descripción

P2

Two ideas for updating the ChatGenerator protocol:

  1. Update the return type of the run method to at least require replies: list[ChatMessage] since we rely on that key being present when we use the protocol in the codebase. This should be possible through using TypedDict, total=False and Required (still needs to be tested). So something like
from typing import Protocol
from typing_extensions import Required, TypedDict
from haystack.dataclasses import ChatMessage


class ChatGeneratorOutput(TypedDict, total=False):
    """
    Return type for Chat Generators.

    ``replies`` is always required. Implementations may include additional keys.
    """
    replies: Required[list[ChatMessage]]


class ChatGenerator(Protocol):
    def run(self, messages: list[ChatMessage]) -> ChatGeneratorOutput:
  1. Consider adding a run_async to the protocol since we have finished adding run_async to all of our chat generators in core and in core-integrations https://github.com/deepset-ai/haystack/issues/8858 and https://github.com/deepset-ai/haystack-core-integrations/issues/1379. Only a consideration since it's not guaranteed that community made components follow the protocol, but we are starting to add run_async methods to components that use the ChatGenerator protocol so I wonder if creating a second protocol (e.g. ChatGeneratorWithAsync) would be an alternative.

👋 Hello there! This issue will be handled internally and isn't open for external contributions. If you'd like to contribute, please take a look at issues labeled contributions welcome or good first issue. We'd really appreciate it!

Lenguaje dominante
Python
Estrellas
27.2k
Forks
3.5k
Merge medio
1 d 18 h
PR fusionados (30 d)
254

Preparar el entorno

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 deepset-ai/haystack

Todos los issues de deepset-ai/haystack

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.