praneeth dodedu commited on
Commit
a60a5ea
·
1 Parent(s): 24719ba
Files changed (1) hide show
  1. app.py +0 -46
app.py CHANGED
@@ -30,52 +30,6 @@ txt = gr.Textbox(
30
  placeholder="What would you like to learn today?"
31
  ).style(container=True)
32
 
33
- def main():
34
- # Parse the command line arguments
35
- args = parse_arguments()
36
- embeddings = HuggingFaceEmbeddings(model_name=embeddings_model_name)
37
- db = Chroma(persist_directory=persist_directory, embedding_function=embeddings, client_settings=CHROMA_SETTINGS)
38
- retriever = db.as_retriever()
39
- # activate/deactivate the streaming StdOut callback for LLMs
40
- callbacks = [] if args.mute_stream else [StreamingStdOutCallbackHandler()]
41
- # Prepare the LLM
42
- '''match model_type:
43
- case "LlamaCpp":
44
- llm = LlamaCpp(model_path=model_path, n_ctx=model_n_ctx, callbacks=callbacks, verbose=False)
45
- case "GPT4All":
46
- llm = GPT4All(model=model_path, n_ctx=model_n_ctx, backend='gptj', callbacks=callbacks, verbose=False)
47
- case _default:
48
- print(f"Model {model_type} not supported!")
49
- exit;'''
50
- if model_type == "LlamaCpp":
51
- llm = LlamaCpp(model_path=model_path, n_ctx=model_n_ctx, callbacks=callbacks, verbose=False)
52
- elif model_type == "GPT4All":
53
- llm = GPT4All(model=model_path, n_ctx=model_n_ctx, backend='gptj', callbacks=callbacks, verbose=False)
54
- else:
55
- print(f"Model {model_type} not supported!")
56
- exit;
57
- qa = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=retriever, return_source_documents= not args.hide_source)
58
- # Interactive questions and answers
59
- while True:
60
- query = input("\nEnter a query: ")
61
- if query == "exit":
62
- break
63
-
64
- # Get the answer from the chain
65
- res = qa(query)
66
- answer, docs = res['result'], [] if args.hide_source else res['source_documents']
67
-
68
- # Print the result
69
- print("\n\n> Question:")
70
- print(query)
71
- print("\n> Answer:")
72
- print(answer)
73
-
74
- # Print the relevant sources used for the answer
75
- for document in docs:
76
- print("\n> " + document.metadata["source"] + ":")
77
- print(document.page_content)
78
-
79
  def parse_arguments():
80
  parser = argparse.ArgumentParser(description='privateGPT: Ask questions to your documents without an internet connection, '
81
  'using the power of LLMs.')
 
30
  placeholder="What would you like to learn today?"
31
  ).style(container=True)
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  def parse_arguments():
34
  parser = argparse.ArgumentParser(description='privateGPT: Ask questions to your documents without an internet connection, '
35
  'using the power of LLMs.')