facehugger92 commited on
Commit
009f54b
·
1 Parent(s): 8b7cec2

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -4,19 +4,18 @@ import gradio as gr
4
  import sys
5
  import os
6
 
 
 
 
 
7
 
8
  def construct_index():
9
  max_input_size = 4096
10
  num_outputs = 512
11
  max_chunk_overlap = 20
12
  chunk_size_limit = 600
13
-
14
  prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
15
-
16
  llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0.7, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
17
-
18
- # documents = SimpleDirectoryReader(directory_path).load_data()
19
-
20
  index = GPTSimpleVectorIndex.load_from_disk('index.json', llm_predictor=llm_predictor, prompt_helper=prompt_helper)
21
 
22
  return index
@@ -29,7 +28,7 @@ def chatbot(input_text):
29
  iface = gr.Interface(fn=chatbot,
30
  inputs=gr.components.Textbox(lines=7, label="Enter your text"),
31
  outputs="text",
32
- title="AI Chatbot for DWW Audio resources")
33
 
34
  # index = construct_index()
35
  iface.launch(share=False)
 
4
  import sys
5
  import os
6
 
7
+ """
8
+ Code from Beebom article: "How to Train an AI Chatbot With Custom Knowledge Base Using ChatGPT API" by Arjun Sha
9
+ https://beebom.com/how-train-ai-chatbot-custom-knowledge-base-chatgpt-api/
10
+ """
11
 
12
  def construct_index():
13
  max_input_size = 4096
14
  num_outputs = 512
15
  max_chunk_overlap = 20
16
  chunk_size_limit = 600
 
17
  prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
 
18
  llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0.7, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
 
 
 
19
  index = GPTSimpleVectorIndex.load_from_disk('index.json', llm_predictor=llm_predictor, prompt_helper=prompt_helper)
20
 
21
  return index
 
28
  iface = gr.Interface(fn=chatbot,
29
  inputs=gr.components.Textbox(lines=7, label="Enter your text"),
30
  outputs="text",
31
+ title="AI Chatbot for the Doing What Works Library")
32
 
33
  # index = construct_index()
34
  iface.launch(share=False)