diff --git a/docs/modules/llms/integrations/openaichat.ipynb b/docs/modules/llms/integrations/openaichat.ipynb index 784ce068428..d4287c18d92 100644 --- a/docs/modules/llms/integrations/openaichat.ipynb +++ b/docs/modules/llms/integrations/openaichat.ipynb @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 2, "id": "62e0dbc3", "metadata": {}, "outputs": [], @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 3, "id": "fbb043e6", "metadata": {}, "outputs": [], @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 4, "id": "3f945b76", "metadata": {}, "outputs": [], @@ -57,7 +57,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 5, "id": "25260808", "metadata": {}, "outputs": [ @@ -67,7 +67,7 @@ "'\\n\\nJustin Bieber was born on March 1, 1994. \\n\\nThe Super Bowl is played in February of each year. \\n\\nTherefore, the Super Bowl that was played in the year Justin Bieber was born was Super Bowl XXVIII, which was played on January 30, 1994. \\n\\nThe Dallas Cowboys won Super Bowl XXVIII by defeating the Buffalo Bills with a score of 30-13.'" ] }, - "execution_count": 11, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -90,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 6, "id": "c27a1501", "metadata": {}, "outputs": [], @@ -100,7 +100,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 7, "id": "e46a914e", "metadata": {}, "outputs": [], @@ -110,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 8, "id": "d683d9f2", "metadata": {}, "outputs": [], @@ -120,17 +120,17 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 9, "id": "6f5b8e78", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'Step 1: Justin Bieber was born on March 1, 1994.\\nStep 2: The Super Bowl is played in February of each year.\\nStep 3: Therefore, the Super Bowl that was played in the year Justin Bieber was born was Super Bowl XXVIII, which was played on January 30, 1994.\\nStep 4: The Dallas Cowboys won Super Bowl XXVIII by defeating the Buffalo Bills with a score of 30-13.\\nStep 5: Therefore, the Dallas Cowboys were the NFL team that won the Super Bowl in the year Justin Bieber was born.'" + "'Step 1: Justin Bieber was born on March 1, 1994.\\nStep 2: The Super Bowl is played in February of each year.\\nStep 3: Therefore, the Super Bowl that was played in the year Justin Bieber was born was Super Bowl XXVIII, which was played on January 30, 1994.\\nStep 4: The team that won Super Bowl XXVIII was the Dallas Cowboys.'" ] }, - "execution_count": 22, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -141,10 +141,81 @@ "llm_chain.run(question)" ] }, + { + "cell_type": "markdown", + "id": "f6d5dda8", + "metadata": {}, + "source": [ + "## Async" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "1973b9bb", + "metadata": {}, + "outputs": [], + "source": [ + "result = await llm_chain.arun(question)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "5815178f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Step 1: Justin Bieber was born on March 1, 1994.\\nStep 2: The Super Bowl is played in February of each year.\\nStep 3: Therefore, the Super Bowl that was played in the year Justin Bieber was born was Super Bowl XXVIII, which was played on January 30, 1994.\\nStep 4: The team that won Super Bowl XXVIII was the Dallas Cowboys.'" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result" + ] + }, + { + "cell_type": "markdown", + "id": "eb779f3f", + "metadata": {}, + "source": [ + "## Streaming" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "509181be", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Justin Bieber was born on March 1, 1994. The NFL team that won the Super Bowl in the same year was the Dallas Cowboys. They defeated the Buffalo Bills 30-13 in Super Bowl XXVIII on January 30, 1994." + ] + } + ], + "source": [ + "\n", + "from langchain.callbacks.base import CallbackManager\n", + "from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler\n", + "llm = OpenAIChat(streaming=True, callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]), verbose=True, temperature=0)\n", + "resp = llm(question)" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "44c0330d", + "id": "c095285d", "metadata": {}, "outputs": [], "source": [] diff --git a/pyproject.toml b/pyproject.toml index 292a0702a7a..e32e2830f84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain" -version = "0.0.98" +version = "0.0.99" description = "Building applications with LLMs through composability" authors = [] license = "MIT"