File size: 973 Bytes
137ca1e
de170a6
358293d
137ca1e
de170a6
99505b0
 
137ca1e
710fa58
7c59f10
710fa58
feb7a10
 
 
358293d
 
1d43e05
feb7a10
1d43e05
 
137ca1e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio
import os
from llama_index import SimpleDirectoryReader, GPTListIndex, readers, GPTSimpleVectorIndex, LLMPredictor, PromptHelper, ServiceContext

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

def gradio_ask_ai(user_input):
    index = GPTSimpleVectorIndex.load_from_disk('index.json')
    query = user_input
    # f=open("https://huggingface.co/spaces/Shubham89/Meshwork-chatbot/blob/main/yo.txt","a")
    # f.write("file created")
    # f.close()
    response = index.query(query)
    return response.response
#a = gradio.File()

demo = gradio.Interface(fn=gradio_ask_ai, inputs = "text", outputs = "text", title = "Meshworks bot")
#demo = gradio.Interface(fn=gradio_ask_ai, inputs = "text", outputs = [a], title = "Meshworks bot")

demo.launch(inline=False)