{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/aakashbhatnagar/Documents/masters/ophthal_llm/myenv/lib/python3.10/site-packages/pinecone/index.py:4: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from tqdm.autonotebook import tqdm\n" ] } ], "source": [ "from langchain.document_loaders import TextLoader\n", "import pinecone\n", "from langchain.vectorstores import Pinecone\n", "import os\n", "from transformers import AutoTokenizer, AutoModel\n", "from langchain.agents.agent_toolkits import create_conversational_retrieval_agent\n", "from langchain.agents.agent_toolkits import create_retriever_tool\n", "from langchain.chat_models import ChatOpenAI\n", "import torch\n", "from langchain.agents.openai_functions_agent.agent_token_buffer_memory import (AgentTokenBufferMemory)\n", "from langchain.agents.openai_functions_agent.base import OpenAIFunctionsAgent\n", "from langchain.schema.messages import SystemMessage\n", "from langchain.prompts import MessagesPlaceholder\n", "import gradio as gr\n", "import time\n", "\n", "# loader = TextLoader(\"../../../../../docs/docs/modules/state_of_the_union.txt\")" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/aakashbhatnagar/Documents/masters/ophthal_llm/myenv/lib/python3.10/site-packages/langchain/vectorstores/pinecone.py:59: UserWarning: Passing in `embedding` as a Callable is deprecated. Please pass in an Embeddings object instead.\n", " warnings.warn(\n" ] } ], "source": [ "import gradio as gr\n", "from conversation import make_conversation, auth_function\n", "import random" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "demo = gr.ChatInterface(make_conversation).queue()" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7863\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n", "To disable this warning, you can either:\n", "\t- Avoid using `tokenizers` before the fork if possible\n", "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Running on public URL: https://36c80e8ac1f1026dec.gradio.live\n", "\n", "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co./spaces)\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "