Skip to content

Commit

Permalink
used path.join instead of adding strings
Browse files Browse the repository at this point in the history
  • Loading branch information
kedarchandrayan committed Mar 13, 2024
1 parent 08ddb3b commit 9c5b8ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion needlehaystack/llm_needle_haystack_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ def get_context_length_in_tokens(self, context):
def read_context_files(self):
context = ""
max_context_length = max(self.context_lengths)
base_dir = os.path.abspath(os.path.dirname(__file__)) # Package directory

while self.get_context_length_in_tokens(context) < max_context_length:
for file in glob.glob(f"{self.haystack_dir}/*.txt"):
for file in glob.glob(os.path.join(base_dir, self.haystack_dir, "*.txt")):
with open(file, 'r') as f:
context += f.read()
return context
Expand Down
2 changes: 1 addition & 1 deletion needlehaystack/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CommandArgs():
model_name: str = "gpt-3.5-turbo-0125"
evaluator_model_name: Optional[str] = "gpt-3.5-turbo-0125"
needle: Optional[str] = "\nThe best thing to do in San Francisco is eat a sandwich and sit in Dolores Park on a sunny day.\n"
haystack_dir: Optional[str] = "needlehaystack/PaulGrahamEssays"
haystack_dir: Optional[str] = "PaulGrahamEssays"
retrieval_question: Optional[str] = "What is the best thing to do in San Francisco?"
results_version: Optional[int] = 1
context_lengths_min: Optional[int] = 1000
Expand Down

0 comments on commit 9c5b8ea

Please sign in to comment.