File size: 798 Bytes
475dfcc
 
bf72e89
1bf1aed
475dfcc
e0c407f
 
da7c758
475dfcc
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from gpt_index import GPTSimpleVectorIndex
from gpt_index.langchain_helpers.chain_wrapper import OpenAI
import os

os.environ["OPENAI_API_KEY"] = "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"
#openai = OpenAI(openai_api_key='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', temperature=0, model_name="text-davinci-003")
index = GPTSimpleVectorIndex.load_from_disk('./index (4).json')

def my_model_function(input_text):
    response = index.query(input_text, response_mode="compact")
    return response

iface = gr.Interface(
    fn=my_model_function, 
    inputs=gr.inputs.Textbox(label="Enter your question here"),
    outputs="text",
    title="GPT Index Demo",
    description="Type a question and see the matching responses from the index!"
)

iface.launch()