File size: 576 Bytes
503882a
e8745d2
 
 
24c97b5
e8745d2
 
 
 
 
 
 
 
4c78ccc
e8745d2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from gpt_index import GPTSimpleVectorIndex
import gradio as gr
import os

os.environ["OPENAI_API_KEY"] = "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"

def chatbot(input_text):
    index = GPTSimpleVectorIndex.load_from_disk('index.json')
    response = index.query(input_text)
    return response.response

demo = gr.Interface(fn=chatbot,
                    inputs=gr.components.Textbox(lines=7, label="Enter your question"),
                    outputs=gr.components.Textbox(lines=7, label="Answer"),
                    title="Gamecraft AI Chatbot")
demo.launch()