7575class DocToolsLLM_class :
7676 "This docstring is dynamically replaced by the content of DocToolsLLM/docs/USAGE.md"
7777
78- VERSION : str = "0.49 "
78+ VERSION : str = "0.52 "
7979
8080 #@optional_typecheck
8181 @typechecked
@@ -84,7 +84,8 @@ def __init__(
8484 task : str ,
8585 filetype : str = "infer" ,
8686
87- modelname : str = "openai/gpt-4o" ,
87+ modelname : str = "openrouter/anthropic/claude-3.5-sonnet" ,
88+ # modelname: str = "openai/gpt-4o",
8889 # modelname: str = "openai/gpt-3.5-turbo-0125",
8990 # modelname: str = "mistral/mistral-large-latest",
9091
@@ -102,10 +103,11 @@ def __init__(
102103
103104 query : Optional [str ] = None ,
104105 query_retrievers : str = "default" ,
105- query_eval_modelname : Optional [str ] = "openai/gpt-3.5-turbo" ,
106+ query_eval_modelname : Optional [str ] = "openrouter/anthropic/claude-3.5-sonnet" ,
107+ # query_eval_modelname: Optional[str] = "openai/gpt-3.5-turbo",
106108 # query_eval_modelname: str = "mistral/open-mixtral-8x7b",
107109 # query_eval_modelname: str = "mistral/open-small",
108- query_eval_check_number : int = 3 ,
110+ query_eval_check_number : int = 1 ,
109111 query_relevancy : float = 0.1 ,
110112 query_condense_question : Union [bool , int ] = True ,
111113
@@ -402,45 +404,6 @@ def ntfy(text: str) -> str:
402404 task = self .task ,
403405 backend = self .file_loader_parallel_backend ,
404406 ** self .cli_kwargs )
405-
406- # check that the hash are unique
407- if len (self .loaded_docs ) > 1 :
408- ids = [id (d .metadata ) for d in self .loaded_docs ]
409- assert len (ids ) == len (set (ids )), (
410- "Same metadata object is used to store information on "
411- "multiple documents!" )
412-
413- hashes = [d .metadata ["hash" ] for d in self .loaded_docs ]
414- uniq_hashes = list (set (hashes ))
415- removed_paths = []
416- removed_docs = []
417- counter = {h : hashes .count (h ) for h in uniq_hashes }
418- if len (hashes ) != len (uniq_hashes ):
419- red ("Found duplicate hashes after loading documents:" )
420-
421- for i , doc in enumerate (tqdm (self .loaded_docs , desc = "Looking for duplicates" )):
422- h = doc .metadata ['hash' ]
423- n = counter [h ]
424- if n > 1 :
425- removed_docs .append (self .loaded_docs [i ])
426- self .loaded_docs [i ] = None
427- counter [h ] -= 1
428- assert counter [h ] > 0
429- red (f"Removed { len (removed_docs )} /{ len (hashes )} documents because they had the same hash" )
430-
431- # check if deduplication likely amputated documents
432- self .loaded_docs = [d for d in self .loaded_docs if d is not None ]
433- present_path = [d .metadata ["path" ] for d in self .loaded_docs ]
434-
435- intersect = set (removed_paths ).intersection (set (present_path ))
436- if intersect :
437- red (f"Found { len (intersect )} documents that were only partially removed, this results in incomplete documents." )
438- for i , inte in enumerate (intersect ):
439- red (f" * #{ i + 1 } : { inte } " )
440- raise Exception ()
441- else :
442- red (f"Removed { len (removed_paths )} /{ len (hashes )} documents because they had the same hash" )
443-
444407 else :
445408 self .loaded_docs = None # will be loaded when embeddings are loaded
446409
@@ -1128,7 +1091,7 @@ def query_task(self, query: Optional[str]) -> Optional[str]:
11281091 base_compressor = pipeline , base_retriever = retriever
11291092 )
11301093
1131- if " >>>> " in query :
1094+ if ">>>>" in query :
11321095 sp = query .split (">>>>" )
11331096 assert len (sp ) == 2 , "The query must contain a maximum of 1 occurence of '>>>>'"
11341097 query_fe = sp [0 ].strip ()
@@ -1208,7 +1171,7 @@ def evaluate_doc_chain(
12081171 reasons = [gen .generation_info ["finish_reason" ] for gen in out .generations ]
12091172 outputs = [gen .text for gen in out .generations ]
12101173 # don't crash if finish_reason is not stop, because it can sometimes still be parsed.
1211- if not all (r in ["stop" , "lenghth " ] for r in reasons ):
1174+ if not all (r in ["stop" , "length " ] for r in reasons ):
12121175 red (f"Unexpected generation finish_reason: '{ reasons } ' for generations: '{ outputs } '" )
12131176 assert outputs , "No generations found by query eval llm"
12141177 outputs = [parse_eval_output (o ) for o in outputs ]
@@ -1254,7 +1217,7 @@ async def do_eval(inputs):
12541217 return outputs
12551218
12561219 # uses in most places to increase concurrency limit
1257- multi = {"max_concurrency" : 50 if not self .debug else 1 }
1220+ multi = {"max_concurrency" : 10 if not self .debug else 1 }
12581221
12591222 if self .task == "search" :
12601223 if self .query_eval_modelname :
0 commit comments