vidhiparikh commited on
Commit
fe4fe9d
1 Parent(s): 746d530

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -74,9 +74,22 @@ callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
74
 
75
  # Function to create a conversational chain
76
  def create_conversational_chain(database):
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  llama_llm = LlamaCpp(
78
  # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system. llama-2-7b-chat.Q8_0.gguf
79
- model_path = AutoModelForCausalLM.from_pretrained("TheBloke/Llama-2-7b-Chat-GGUF", model_file="llama-2-7b-chat.Q8_0.gguf", model_type="llama", gpu_layers=0),
80
  temperature=0.75,
81
  max_tokens=200,
82
  top_p=1,
 
74
 
75
  # Function to create a conversational chain
76
  def create_conversational_chain(database):
77
+ model_name = “llama-7b-hf”
78
+ model_directory = “models”
79
+ #Check if the model file exists in the specified directory
80
+ model_file = os.path.join(model_directory, model_name)
81
+ if os.path.exists(model_file):
82
+ model_path = model_file
83
+ print(“Model file found in the directory. Using the local model file.”)
84
+ else:
85
+ model_path = model_name
86
+ print(“Model file not found in the directory. Downloading the model from the repository.”)
87
+ #Load the model
88
+ model = AutoModelForCausalLM.from_pretrained(model_path)
89
+ print(model_path)
90
  llama_llm = LlamaCpp(
91
  # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system. llama-2-7b-chat.Q8_0.gguf
92
+ model_path = model_path,
93
  temperature=0.75,
94
  max_tokens=200,
95
  top_p=1,