Spaces:
Runtime error
Runtime error
File size: 943 Bytes
e113309 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
from langchain.chat_models import ChatOpenAI
import gradio as gr
import sys
import os
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
#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
iface = gr.Interface(fn=chatbot,
inputs=gr.components.Textbox(lines=5, label="Enter your text", show_copy_button=True),
outputs=gr.components.Textbox(lines=5, label="Answer", show_copy_button=True),
examples=["How to perform asset audit?", "What is Cycle count?", "How to print RFID tags?"],
title="OperativeIQ RFID Training AI Chatbot")
iface.launch(share=True) |