From d09de9c98ed42822de7cf36f8f400e02bb1bedf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Thu, 28 May 2026 16:52:07 +0000 Subject: [PATCH] Add stream mode example --- main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..f54be7b --- /dev/null +++ b/main.py @@ -0,0 +1,13 @@ +import os +from langchain.chat_models import ChatOpenAI +from langchain.schema import HumanMessage + +# Example of streaming with LangChain +if __name__ == "__main__": + # Use OpenAI API key from env + os.environ.setdefault("OPENAI_API_KEY", "sk-...") + model = ChatOpenAI(temperature=0.7) + # Stream response + for chunk in model.stream([HumanMessage(content="Hello, world!" )]): + print(chunk.content, end="", flush=True) + print("\n[Done]") \ No newline at end of file