|
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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" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |