serene-shen commited on
Commit
17e4bcd
·
verified ·
1 Parent(s): 2f30256

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -23,7 +23,7 @@ def build_or_load_db():
23
  loader = DirectoryLoader('./data/', glob="./*.pdf", loader_cls=PyPDFLoader)
24
  docs = loader.load()
25
 
26
- splitter = RecursiveCharacterTextSplitter(chunk_size=600, chunk_overlap=100)
27
  chunks = splitter.split_documents(docs)
28
 
29
  return Chroma.from_documents(chunks, embeddings, persist_directory="./chroma_db")
@@ -67,9 +67,9 @@ def predict(message, history):
67
 
68
  # 3. Generation
69
  # We strip the prompt out of the result so the user only sees the 'Answer'
70
- response = pipe(prompt, max_new_tokens=256)[0]['generated_text'].split("ANSWER:")[-1]
71
 
72
- return f"{response.strip()}\n\n**Sources:**\n{sources}"
73
 
74
  # 5. GRADIO INTERFACE
75
  gr.ChatInterface(predict, title="Radiomics Clinical Assistant").launch()
 
23
  loader = DirectoryLoader('./data/', glob="./*.pdf", loader_cls=PyPDFLoader)
24
  docs = loader.load()
25
 
26
+ splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=100)
27
  chunks = splitter.split_documents(docs)
28
 
29
  return Chroma.from_documents(chunks, embeddings, persist_directory="./chroma_db")
 
67
 
68
  # 3. Generation
69
  # We strip the prompt out of the result so the user only sees the 'Answer'
70
+ response = pipe(prompt, max_new_tokens=150)[0]['generated_text'].split("ANSWER:")[-1]
71
 
72
+ return response.strip()
73
 
74
  # 5. GRADIO INTERFACE
75
  gr.ChatInterface(predict, title="Radiomics Clinical Assistant").launch()