Spaces:
Sleeping
Sleeping
Update util.py
Browse files
util.py
CHANGED
@@ -12,7 +12,6 @@ import google.generativeai as genai
|
|
12 |
|
13 |
import git # pip install gitpython
|
14 |
|
15 |
-
os.environ['GOOGLE_API_KEY'] = "AIzaSyCS1bV6_bfizb1tAcQEB9BvCTtqCCLlGFo"
|
16 |
genai.configure(api_key = os.environ['GOOGLE_API_KEY'])
|
17 |
|
18 |
# quantization_config = BitsAndBytesConfig(
|
@@ -55,6 +54,7 @@ def get_folder_paths(directory = "githubCode"):
|
|
55 |
|
56 |
directory_paths = get_folder_paths()
|
57 |
directory_paths.append("Code")
|
|
|
58 |
|
59 |
with open("Code.txt", "w", encoding='utf-8') as output:
|
60 |
for directory_path in directory_paths:
|
@@ -84,7 +84,7 @@ pages = loader.load_and_split()
|
|
84 |
# Split data into chunks
|
85 |
text_splitter = RecursiveCharacterTextSplitter(
|
86 |
chunk_size = 4000,
|
87 |
-
chunk_overlap =
|
88 |
length_function = len,
|
89 |
add_start_index = True,
|
90 |
)
|
@@ -98,7 +98,7 @@ db.persist()
|
|
98 |
vectordb = Chroma(persist_directory="test_index", embedding_function = embeddings)
|
99 |
|
100 |
# Load the retriver
|
101 |
-
retriever = vectordb.as_retriever()
|
102 |
|
103 |
# Function to generate assistant's response using ask function
|
104 |
def generate_assistant_response(question):
|
|
|
12 |
|
13 |
import git # pip install gitpython
|
14 |
|
|
|
15 |
genai.configure(api_key = os.environ['GOOGLE_API_KEY'])
|
16 |
|
17 |
# quantization_config = BitsAndBytesConfig(
|
|
|
54 |
|
55 |
directory_paths = get_folder_paths()
|
56 |
directory_paths.append("Code")
|
57 |
+
print("directory_paths: ", directory_paths)
|
58 |
|
59 |
with open("Code.txt", "w", encoding='utf-8') as output:
|
60 |
for directory_path in directory_paths:
|
|
|
84 |
# Split data into chunks
|
85 |
text_splitter = RecursiveCharacterTextSplitter(
|
86 |
chunk_size = 4000,
|
87 |
+
chunk_overlap = 20,
|
88 |
length_function = len,
|
89 |
add_start_index = True,
|
90 |
)
|
|
|
98 |
vectordb = Chroma(persist_directory="test_index", embedding_function = embeddings)
|
99 |
|
100 |
# Load the retriver
|
101 |
+
retriever = vectordb.as_retriever(search_kwargs = {"k": 3})
|
102 |
|
103 |
# Function to generate assistant's response using ask function
|
104 |
def generate_assistant_response(question):
|