wesleybiochat commited on
Commit
2bc66e0
·
1 Parent(s): 4926683

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -41
app.py DELETED
@@ -1,41 +0,0 @@
1
- def construct_index(directory_path):
2
- max_input_size = 4096
3
- num_outputs = 512
4
- max_chunk_overlap = 20
5
- chunk_size_limit = 600
6
-
7
- prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
8
-
9
- llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0.7, model_name="gpt-4", max_tokens=num_outputs))
10
-
11
- documents = SimpleDirectoryReader(directory_path).load_data()
12
-
13
- index = GPTSimpleVectorIndex(documents, llm_predictor=llm_predictor, prompt_helper=prompt_helper)
14
-
15
- index.save_to_disk('index.json')
16
-
17
- return index
18
-
19
- def chatbot(input_text):
20
- index = GPTSimpleVectorIndex.load_from_disk('index.json')
21
- response = index.query(input_text, response_mode="compact")
22
- return response.response
23
-
24
- from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
25
- from langchain.chat_models import ChatOpenAI
26
- import gradio as gr
27
- import sys
28
- import os
29
-
30
- iface = gr.Interface(fn=chatbot,
31
- inputs=gr.components.Textbox(lines=7, label="Enter your text"),
32
- outputs="text",
33
- title="Custom-trained AI Chatbot")
34
-
35
- index = construct_index("docs")
36
- iface.launch(share=True)
37
-
38
-
39
-
40
- os.environ["OPENAI_API_KEY"] = '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'
41
-