khoj 2.0.0b14.dev43__py3-none-any.whl → 2.0.0b15.dev22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. khoj/database/adapters/__init__.py +59 -20
  2. khoj/database/admin.py +6 -2
  3. khoj/database/migrations/0094_serverchatsettings_think_free_deep_and_more.py +61 -0
  4. khoj/database/models/__init__.py +18 -2
  5. khoj/interface/compiled/404/index.html +1 -1
  6. khoj/interface/compiled/_next/static/chunks/{9808-c0742b05e1ef29ba.js → 9808-bd5d7361ad026094.js} +1 -1
  7. khoj/interface/compiled/_next/static/chunks/app/chat/page-ac7ed0a1aff1b145.js +1 -0
  8. khoj/interface/compiled/_next/static/css/fb7ea16e60b40ecd.css +1 -0
  9. khoj/interface/compiled/agents/index.html +1 -1
  10. khoj/interface/compiled/agents/index.txt +1 -1
  11. khoj/interface/compiled/automations/index.html +1 -1
  12. khoj/interface/compiled/automations/index.txt +1 -1
  13. khoj/interface/compiled/chat/index.html +2 -2
  14. khoj/interface/compiled/chat/index.txt +2 -2
  15. khoj/interface/compiled/index.html +2 -2
  16. khoj/interface/compiled/index.txt +1 -1
  17. khoj/interface/compiled/search/index.html +1 -1
  18. khoj/interface/compiled/search/index.txt +1 -1
  19. khoj/interface/compiled/settings/index.html +1 -1
  20. khoj/interface/compiled/settings/index.txt +1 -1
  21. khoj/interface/compiled/share/chat/index.html +2 -2
  22. khoj/interface/compiled/share/chat/index.txt +2 -2
  23. khoj/processor/conversation/anthropic/anthropic_chat.py +4 -88
  24. khoj/processor/conversation/anthropic/utils.py +1 -2
  25. khoj/processor/conversation/google/gemini_chat.py +5 -89
  26. khoj/processor/conversation/google/utils.py +8 -9
  27. khoj/processor/conversation/openai/gpt.py +16 -93
  28. khoj/processor/conversation/openai/utils.py +58 -43
  29. khoj/processor/conversation/prompts.py +30 -39
  30. khoj/processor/conversation/utils.py +71 -84
  31. khoj/processor/image/generate.py +69 -15
  32. khoj/processor/tools/run_code.py +3 -2
  33. khoj/routers/api_chat.py +8 -21
  34. khoj/routers/helpers.py +243 -156
  35. khoj/routers/research.py +6 -6
  36. khoj/utils/constants.py +3 -1
  37. khoj/utils/helpers.py +6 -2
  38. {khoj-2.0.0b14.dev43.dist-info → khoj-2.0.0b15.dev22.dist-info}/METADATA +1 -1
  39. {khoj-2.0.0b14.dev43.dist-info → khoj-2.0.0b15.dev22.dist-info}/RECORD +44 -43
  40. khoj/interface/compiled/_next/static/chunks/app/chat/page-1b4893b1a9957220.js +0 -1
  41. khoj/interface/compiled/_next/static/css/cea3bdfe98c144bd.css +0 -1
  42. /khoj/interface/compiled/_next/static/{OKbGpkzD6gHDfr1vAog6p → t8O_8CJ9p3UtV9kEsAAWT}/_buildManifest.js +0 -0
  43. /khoj/interface/compiled/_next/static/{OKbGpkzD6gHDfr1vAog6p → t8O_8CJ9p3UtV9kEsAAWT}/_ssgManifest.js +0 -0
  44. {khoj-2.0.0b14.dev43.dist-info → khoj-2.0.0b15.dev22.dist-info}/WHEEL +0 -0
  45. {khoj-2.0.0b14.dev43.dist-info → khoj-2.0.0b15.dev22.dist-info}/entry_points.txt +0 -0
  46. {khoj-2.0.0b14.dev43.dist-info → khoj-2.0.0b15.dev22.dist-info}/licenses/LICENSE +0 -0
khoj/routers/api_chat.py CHANGED
@@ -90,7 +90,6 @@ from khoj.utils.helpers import (
90
90
  is_operator_enabled,
91
91
  )
92
92
  from khoj.utils.rawconfig import (
93
- FileAttachment,
94
93
  FileFilterRequest,
95
94
  FilesFilterRequest,
96
95
  LocationData,
@@ -732,7 +731,6 @@ async def event_generator(
732
731
  attached_file_context = gather_raw_query_files(query_files)
733
732
 
734
733
  generated_images: List[str] = []
735
- generated_files: List[FileAttachment] = []
736
734
  generated_mermaidjs_diagram: str = None
737
735
  generated_asset_results: Dict = dict()
738
736
  program_execution_context: List[str] = []
@@ -769,7 +767,6 @@ async def event_generator(
769
767
  train_of_thought=train_of_thought,
770
768
  raw_query_files=raw_query_files,
771
769
  generated_images=generated_images,
772
- raw_generated_files=generated_asset_results,
773
770
  generated_mermaidjs_diagram=generated_mermaidjs_diagram,
774
771
  user_message_time=user_message_time,
775
772
  tracer=tracer,
@@ -816,7 +813,6 @@ async def event_generator(
816
813
  train_of_thought=train_of_thought,
817
814
  raw_query_files=raw_query_files,
818
815
  generated_images=generated_images,
819
- raw_generated_files=generated_asset_results,
820
816
  generated_mermaidjs_diagram=generated_mermaidjs_diagram,
821
817
  user_message_time=user_message_time,
822
818
  tracer=tracer,
@@ -927,9 +923,7 @@ async def event_generator(
927
923
 
928
924
  # Automated tasks are handled before to allow mixing them with other conversation commands
929
925
  cmds_to_rate_limit = []
930
- is_automated_task = False
931
926
  if q.startswith("/automated_task"):
932
- is_automated_task = True
933
927
  q = q.replace("/automated_task", "").lstrip()
934
928
  cmds_to_rate_limit += [ConversationCommand.AutomatedTask]
935
929
 
@@ -989,7 +983,6 @@ async def event_generator(
989
983
  chosen_io = await aget_data_sources_and_output_format(
990
984
  q,
991
985
  chat_history,
992
- is_automated_task,
993
986
  user=user,
994
987
  query_images=uploaded_images,
995
988
  agent=agent,
@@ -1021,7 +1014,6 @@ async def event_generator(
1021
1014
  return
1022
1015
 
1023
1016
  defiltered_query = defilter_query(q)
1024
- file_filters = conversation.file_filters if conversation and conversation.file_filters else []
1025
1017
 
1026
1018
  if conversation_commands == [ConversationCommand.Research]:
1027
1019
  async for research_result in research(
@@ -1035,12 +1027,11 @@ async def event_generator(
1035
1027
  send_status_func=partial(send_event, ChatEvent.STATUS),
1036
1028
  user_name=user_name,
1037
1029
  location=location,
1038
- file_filters=file_filters,
1039
1030
  query_files=attached_file_context,
1040
- tracer=tracer,
1041
1031
  cancellation_event=cancellation_event,
1042
1032
  interrupt_queue=child_interrupt_queue,
1043
1033
  abort_message=ChatEvent.END_EVENT.value,
1034
+ tracer=tracer,
1044
1035
  ):
1045
1036
  if isinstance(research_result, ResearchIteration):
1046
1037
  if research_result.summarizedResult:
@@ -1075,8 +1066,8 @@ async def event_generator(
1075
1066
  logger.debug(f"Researched Results: {''.join(r.summarizedResult or '' for r in research_results)}")
1076
1067
 
1077
1068
  # Gather Context
1078
- ## Extract Document References
1079
- if ConversationCommand.Research not in conversation_commands:
1069
+ ## Gather Document References
1070
+ if ConversationCommand.Notes in conversation_commands:
1080
1071
  try:
1081
1072
  async for result in search_documents(
1082
1073
  q,
@@ -1194,7 +1185,7 @@ async def event_generator(
1194
1185
  ):
1195
1186
  yield result
1196
1187
 
1197
- ## Gather Code Results
1188
+ ## Run Code
1198
1189
  if ConversationCommand.Code in conversation_commands:
1199
1190
  try:
1200
1191
  context = f"# Iteration 1:\n#---\nNotes:\n{compiled_references}\n\nOnline Results:{online_results}"
@@ -1220,6 +1211,8 @@ async def event_generator(
1220
1211
  f"Failed to use code tool: {e}. Attempting to respond without code results",
1221
1212
  exc_info=True,
1222
1213
  )
1214
+
1215
+ ## Operate Computer
1223
1216
  if ConversationCommand.Operator in conversation_commands:
1224
1217
  try:
1225
1218
  async for result in operate_environment(
@@ -1300,7 +1293,7 @@ async def event_generator(
1300
1293
  generated_images.append(generated_image)
1301
1294
 
1302
1295
  generated_asset_results["images"] = {
1303
- "query": improved_image_prompt,
1296
+ "description": improved_image_prompt,
1304
1297
  }
1305
1298
 
1306
1299
  async for result in send_event(
@@ -1316,8 +1309,6 @@ async def event_generator(
1316
1309
  yield result
1317
1310
 
1318
1311
  inferred_queries = []
1319
- diagram_description = ""
1320
-
1321
1312
  async for result in generate_mermaidjs_diagram(
1322
1313
  q=defiltered_query,
1323
1314
  chat_history=chat_history,
@@ -1337,9 +1328,7 @@ async def event_generator(
1337
1328
  better_diagram_description_prompt, mermaidjs_diagram_description = result
1338
1329
  if better_diagram_description_prompt and mermaidjs_diagram_description:
1339
1330
  inferred_queries.append(better_diagram_description_prompt)
1340
- diagram_description = mermaidjs_diagram_description
1341
-
1342
- generated_mermaidjs_diagram = diagram_description
1331
+ generated_mermaidjs_diagram = mermaidjs_diagram_description
1343
1332
 
1344
1333
  generated_asset_results["diagrams"] = {
1345
1334
  "query": better_diagram_description_prompt,
@@ -1386,7 +1375,6 @@ async def event_generator(
1386
1375
  user_name,
1387
1376
  uploaded_images,
1388
1377
  attached_file_context,
1389
- generated_files,
1390
1378
  program_execution_context,
1391
1379
  generated_asset_results,
1392
1380
  is_subscribed,
@@ -1447,7 +1435,6 @@ async def event_generator(
1447
1435
  train_of_thought=train_of_thought,
1448
1436
  raw_query_files=raw_query_files,
1449
1437
  generated_images=generated_images,
1450
- raw_generated_files=generated_files,
1451
1438
  generated_mermaidjs_diagram=generated_mermaidjs_diagram,
1452
1439
  tracer=tracer,
1453
1440
  )