Spaces:
Build error
Build error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,7 @@ import gradio as gr
|
|
| 4 |
import sys
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
|
| 8 |
-
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
|
| 9 |
|
| 10 |
def construct_index(directory_path):
|
| 11 |
max_input_size = 4096
|
|
@@ -25,20 +24,15 @@ def construct_index(directory_path):
|
|
| 25 |
|
| 26 |
return index
|
| 27 |
|
| 28 |
-
|
| 29 |
def chatbot(input_text):
|
| 30 |
-
predetermined_text = "- please only answer using information found in the directory 'docs' and nothing else"
|
| 31 |
-
input_text = input_text + predetermined_text
|
| 32 |
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
| 33 |
response = index.query(input_text, response_mode="compact")
|
| 34 |
return response.response
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
iface = gr.Interface(fn=chatbot,
|
| 39 |
inputs=gr.components.Textbox(lines=7, label="What do you want to know about the project?"),
|
| 40 |
outputs="text",
|
| 41 |
-
title="Project
|
| 42 |
|
| 43 |
index = construct_index("docs")
|
| 44 |
iface.launch()
|
|
|
|
| 4 |
import sys
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
os.environ["OPENAI_API_KEY"] = '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'
|
|
|
|
| 8 |
|
| 9 |
def construct_index(directory_path):
|
| 10 |
max_input_size = 4096
|
|
|
|
| 24 |
|
| 25 |
return index
|
| 26 |
|
|
|
|
| 27 |
def chatbot(input_text):
|
|
|
|
|
|
|
| 28 |
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
| 29 |
response = index.query(input_text, response_mode="compact")
|
| 30 |
return response.response
|
| 31 |
|
|
|
|
|
|
|
| 32 |
iface = gr.Interface(fn=chatbot,
|
| 33 |
inputs=gr.components.Textbox(lines=7, label="What do you want to know about the project?"),
|
| 34 |
outputs="text",
|
| 35 |
+
title="AI Project Guru Bot")
|
| 36 |
|
| 37 |
index = construct_index("docs")
|
| 38 |
iface.launch()
|