Interrobangarang commited on
Commit
dd03ed5
·
1 Parent(s): 4405a64

Delete PDFminer.py

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