Update app.py
Browse files
app.py
CHANGED
@@ -61,7 +61,6 @@ def convert_file_to_json(file_path: str, file_type: str) -> str:
|
|
61 |
if os.path.exists(cache_path):
|
62 |
with open(cache_path, "r", encoding="utf-8") as f:
|
63 |
return f.read()
|
64 |
-
|
65 |
if file_type == "pdf":
|
66 |
text = extract_all_pages(file_path)
|
67 |
result = json.dumps({"filename": os.path.basename(file_path), "content": text, "status": "initial"})
|
@@ -150,6 +149,7 @@ def init_agent():
|
|
150 |
force_finish=True,
|
151 |
enable_checker=False,
|
152 |
enable_rag=False,
|
|
|
153 |
tool_files_dict=None,
|
154 |
step_rag_num=0,
|
155 |
seed=100,
|
@@ -185,7 +185,7 @@ def create_ui(agent):
|
|
185 |
chunk_size = 800
|
186 |
chunks = [extracted[i:i + chunk_size] for i in range(0, len(extracted), chunk_size)]
|
187 |
chunk_responses = []
|
188 |
-
batch_size =
|
189 |
total_chunks = len(chunks)
|
190 |
|
191 |
prompt_template = """
|
@@ -204,6 +204,7 @@ Records:
|
|
204 |
for i in range(0, len(chunks), batch_size):
|
205 |
batch = chunks[i:i + batch_size]
|
206 |
batch_responses = []
|
|
|
207 |
for j, chunk in enumerate(batch):
|
208 |
prompt = prompt_template.format(chunk=chunk)
|
209 |
chunk_response = ""
|
@@ -211,7 +212,7 @@ Records:
|
|
211 |
message=prompt,
|
212 |
history=[],
|
213 |
temperature=0.1,
|
214 |
-
max_new_tokens=
|
215 |
max_token=4096,
|
216 |
call_agent=False,
|
217 |
conversation=[],
|
|
|
61 |
if os.path.exists(cache_path):
|
62 |
with open(cache_path, "r", encoding="utf-8") as f:
|
63 |
return f.read()
|
|
|
64 |
if file_type == "pdf":
|
65 |
text = extract_all_pages(file_path)
|
66 |
result = json.dumps({"filename": os.path.basename(file_path), "content": text, "status": "initial"})
|
|
|
149 |
force_finish=True,
|
150 |
enable_checker=False,
|
151 |
enable_rag=False,
|
152 |
+
enable_finish=False, # MODIFIED: Disable Finish tool
|
153 |
tool_files_dict=None,
|
154 |
step_rag_num=0,
|
155 |
seed=100,
|
|
|
185 |
chunk_size = 800
|
186 |
chunks = [extracted[i:i + chunk_size] for i in range(0, len(extracted), chunk_size)]
|
187 |
chunk_responses = []
|
188 |
+
batch_size = 8 # MODIFIED: Increase for parallelism
|
189 |
total_chunks = len(chunks)
|
190 |
|
191 |
prompt_template = """
|
|
|
204 |
for i in range(0, len(chunks), batch_size):
|
205 |
batch = chunks[i:i + batch_size]
|
206 |
batch_responses = []
|
207 |
+
log_system_usage(f"Batch {i//batch_size + 1}") # MODIFIED: Log VRAM
|
208 |
for j, chunk in enumerate(batch):
|
209 |
prompt = prompt_template.format(chunk=chunk)
|
210 |
chunk_response = ""
|
|
|
212 |
message=prompt,
|
213 |
history=[],
|
214 |
temperature=0.1,
|
215 |
+
max_new_tokens=64, # MODIFIED: Reduce for speed
|
216 |
max_token=4096,
|
217 |
call_agent=False,
|
218 |
conversation=[],
|