{ "cells": [ { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'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'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import os\n", "from dotenv import load_dotenv\n", "\n", "load_dotenv()\n", "os.environ['OPENAI_API_KEY']" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Dejé mi bandeja entre America y Finch, pero Travis no ocupó su lugar ',\n", " 'habitual delante de mí. En lugar de eso, se sentó algo más lejos. En ese momento ',\n", " 'me di cuenta de que no había dicho mucho durante nuestro paseo hacia la ',\n", " 'cafetería.',\n", " '—¿Estás bien, Trav? —le pregunté.']" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def load_context(file_path):\n", " with open(file_path, 'r') as file:\n", " return file.read()\n", " \n", "CONTEXT = load_context('texto-de-novelas.txt')\n", "novel_context = CONTEXT.split('\\n')[:5] # Tomar solo las primeras 5 líneas como referencia general\n", "\n", "novel_context \n" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7867\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "Upload a .PDF from your computer, click the \"Load PDF to LangChain\" button,
\n",
" when everything is ready, you can start asking questions about the pdf ;)
\n",
" This version is set to store chat history, and uses OpenAI as LLM, don't forget to copy/paste your OpenAI API key