Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Не работает потоковый вывод #27

Open
MrBoriska opened this issue Jul 10, 2024 · 0 comments
Open

Не работает потоковый вывод #27

MrBoriska opened this issue Jul 10, 2024 · 0 comments

Comments

@MrBoriska
Copy link

Пытаюсь использовать вот так:

from langchain_core.prompts.loading import load_prompt
from langchain_core.output_parsers import StrOutputParser
from langchain_community.chat_models import GigaChat
from pathlib import Path
import os

ROOT = Path(__file__).parent

llm = GigaChat(
        verify_ssl_certs=False,
        # TODO: set by environ "GIGACHAT_CREDENTIALS"
        # credentials="",
        scope="GIGACHAT_API_CORP",
        model="GigaChat-Pro",
        temperature=0.01,
        streaming=True,
    )

rag_chain_prompt = load_prompt((ROOT / "agents/rag_chain.yaml").absolute())
rag_chain = rag_chain_prompt | llm | StrOutputParser()

Далее вот такой вызов должен возвращать генератор. Он его возвращает, но вываливает все токены разом, а не по мере генерации. Использование ChatOllama или ChatOpenAI классов для обьекта llm работает как задумано и возвращают токены по мере генерации.

generation = rag_chain.stream({"context": documents, "question": question})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant