Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1 +1,17 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gpt_index import SimpleDirectoryReader, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
|
2 |
+
from langchain.chat_models import ChatOpenAI
|
3 |
+
import gradio as gr
|
4 |
+
import os
|
5 |
+
|
6 |
+
os.environ["OPENAI_API_KEY"] = "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"
|
7 |
+
|
8 |
+
def chatbot(input_text):
|
9 |
+
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
10 |
+
response = index.query(input_text)
|
11 |
+
return response.response
|
12 |
+
|
13 |
+
demo = gr.Interface(fn=chatbot,
|
14 |
+
inputs=gr.components.Textbox(lines=7, label="Enter your question"),
|
15 |
+
outputs=gr.components.Textbox(lines=7, label="Enter your question"),
|
16 |
+
title="Gamecraft AI Chatbot")
|
17 |
+
demo.launch()
|