pulseDemo / app.py
svummidi's picture
Upload 2 files
478e016
raw
history blame
No virus
1.13 kB
from gpt_index import Document, SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
from langchain import OpenAI
import openai
import gradio as gr
import sys
import os
openai.api_key = "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"
### This is the code for the chatbot interface ###
### INSTRUCTIONS: ###
### 1. Run this file in the terminal: python3 llamaTest.py ###
### 2. Copy the link that appears in the terminal and paste it into your browser
# there will be 2 links - one local and one global, you can use either ###
def chatbot(input_text):
"""
Chatbot function that takes in a prompt and returns a response
"""
index = GPTSimpleVectorIndex.load_from_disk('index.json')
response = index.query(input_text, response_mode="compact")
return response.response
iface = gr.Interface(fn=chatbot,
inputs=gr.inputs.Textbox(lines=7, label="Insert prompt"),
outputs="text",
title="Custom-index GPT-3 model")
index = GPTSimpleVectorIndex.load_from_disk('index.json')
iface.launch(share=True)