{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import gradio as gr\n", "from dotenv import load_dotenv, find_dotenv\n", "_ = load_dotenv(find_dotenv())\n", "\n", "from langchain.chains import ConversationChain\n", "from langchain.chat_models import ChatOpenAI\n", "from langchain.memory import ConversationBufferMemory\n", "\n", "llm = ChatOpenAI(temperature=0.0)\n", "memory = ConversationBufferMemory()\n", "conversion = ConversationChain(\n", " llm=llm,\n", " memory=memory,\n", " verbose=False\n", ")\n", "\n", "def takeinput(input_str):\n", " output_str = conversion.predict(input=input_str)\n", " return output_str\n", "\n", "demo = gr.Interface(\n", " fn=takeinput,\n", " inputs=[\"text\"],\n", " outputs=[\"text\"]\n", ")\n", "\n", "demo.launch(share=True)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "language_info": { "name": "python" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }