khoj 1.29.2.dev26__py3-none-any.whl → 1.30.1__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 (38) hide show
  1. khoj/configure.py +25 -0
  2. khoj/database/adapters/__init__.py +2 -0
  3. khoj/interface/compiled/404/index.html +1 -1
  4. khoj/interface/compiled/_next/static/chunks/5538-b87b60ecc0c27ceb.js +1 -0
  5. khoj/interface/compiled/_next/static/chunks/796-68f9e87f9cdfda1d.js +3 -0
  6. khoj/interface/compiled/_next/static/chunks/app/chat/{page-1a23760147c678ba.js → page-2790303dee566590.js} +1 -1
  7. khoj/interface/compiled/_next/static/chunks/app/share/chat/{page-a0a8dd453394b651.js → page-07e1a8a345e768de.js} +1 -1
  8. khoj/interface/compiled/_next/static/chunks/{webpack-63a7b969d34e6698.js → webpack-ff5eae43b8dba1d2.js} +1 -1
  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 +1 -1
  14. khoj/interface/compiled/chat/index.txt +2 -2
  15. khoj/interface/compiled/index.html +1 -1
  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 +1 -1
  22. khoj/interface/compiled/share/chat/index.txt +2 -2
  23. khoj/processor/conversation/prompts.py +24 -78
  24. khoj/processor/conversation/utils.py +22 -7
  25. khoj/routers/api.py +1 -1
  26. khoj/routers/api_chat.py +24 -15
  27. khoj/routers/helpers.py +55 -98
  28. khoj/utils/constants.py +2 -1
  29. khoj/utils/helpers.py +5 -6
  30. {khoj-1.29.2.dev26.dist-info → khoj-1.30.1.dist-info}/METADATA +1 -1
  31. {khoj-1.29.2.dev26.dist-info → khoj-1.30.1.dist-info}/RECORD +36 -36
  32. khoj/interface/compiled/_next/static/chunks/5538-32bd787d106700dc.js +0 -1
  33. khoj/interface/compiled/_next/static/chunks/5961-3c104d9736b7902b.js +0 -3
  34. /khoj/interface/compiled/_next/static/{8GHdsBD3CrRSB--Guybv_ → SIep1wbq3DV05tttuBdtF}/_buildManifest.js +0 -0
  35. /khoj/interface/compiled/_next/static/{8GHdsBD3CrRSB--Guybv_ → SIep1wbq3DV05tttuBdtF}/_ssgManifest.js +0 -0
  36. {khoj-1.29.2.dev26.dist-info → khoj-1.30.1.dist-info}/WHEEL +0 -0
  37. {khoj-1.29.2.dev26.dist-info → khoj-1.30.1.dist-info}/entry_points.txt +0 -0
  38. {khoj-1.29.2.dev26.dist-info → khoj-1.30.1.dist-info}/licenses/LICENSE +0 -0
khoj/routers/helpers.py CHANGED
@@ -336,7 +336,7 @@ async def acheck_if_safe_prompt(system_prompt: str, user: KhojUser = None, lax:
336
336
  return is_safe, reason
337
337
 
338
338
 
339
- async def aget_relevant_information_sources(
339
+ async def aget_data_sources_and_output_format(
340
340
  query: str,
341
341
  conversation_history: dict,
342
342
  is_task: bool,
@@ -345,20 +345,33 @@ async def aget_relevant_information_sources(
345
345
  agent: Agent = None,
346
346
  query_files: str = None,
347
347
  tracer: dict = {},
348
- ):
348
+ ) -> Dict[str, Any]:
349
349
  """
350
- Given a query, determine which of the available tools the agent should use in order to answer appropriately.
350
+ Given a query, determine which of the available data sources and output modes the agent should use to answer appropriately.
351
351
  """
352
352
 
353
- tool_options = dict()
354
- tool_options_str = ""
353
+ source_options = dict()
354
+ source_options_str = ""
355
+
356
+ agent_sources = agent.input_tools if agent else []
357
+
358
+ for source, description in tool_descriptions_for_llm.items():
359
+ source_options[source.value] = description
360
+ if len(agent_sources) == 0 or source.value in agent_sources:
361
+ source_options_str += f'- "{source.value}": "{description}"\n'
362
+
363
+ output_options = dict()
364
+ output_options_str = ""
355
365
 
356
- agent_tools = agent.input_tools if agent else []
366
+ agent_outputs = agent.output_modes if agent else []
357
367
 
358
- for tool, description in tool_descriptions_for_llm.items():
359
- tool_options[tool.value] = description
360
- if len(agent_tools) == 0 or tool.value in agent_tools:
361
- tool_options_str += f'- "{tool.value}": "{description}"\n'
368
+ for output, description in mode_descriptions_for_llm.items():
369
+ # Do not allow tasks to schedule another task
370
+ if is_task and output == ConversationCommand.Automation:
371
+ continue
372
+ output_options[output.value] = description
373
+ if len(agent_outputs) == 0 or output.value in agent_outputs:
374
+ output_options_str += f'- "{output.value}": "{description}"\n'
362
375
 
363
376
  chat_history = construct_chat_history(conversation_history)
364
377
 
@@ -369,9 +382,10 @@ async def aget_relevant_information_sources(
369
382
  prompts.personality_context.format(personality=agent.personality) if agent and agent.personality else ""
370
383
  )
371
384
 
372
- relevant_tools_prompt = prompts.pick_relevant_information_collection_tools.format(
385
+ relevant_tools_prompt = prompts.pick_relevant_tools.format(
373
386
  query=query,
374
- tools=tool_options_str,
387
+ sources=source_options_str,
388
+ outputs=output_options_str,
375
389
  chat_history=chat_history,
376
390
  personality_context=personality_context,
377
391
  )
@@ -388,100 +402,43 @@ async def aget_relevant_information_sources(
388
402
  try:
389
403
  response = clean_json(response)
390
404
  response = json.loads(response)
391
- response = [q.strip() for q in response["source"] if q.strip()]
392
- if not isinstance(response, list) or not response or len(response) == 0:
393
- logger.error(f"Invalid response for determining relevant tools: {response}")
394
- return tool_options
395
405
 
396
- final_response = [] if not is_task else [ConversationCommand.AutomatedTask]
397
- for llm_suggested_tool in response:
406
+ selected_sources = [q.strip() for q in response.get("source", []) if q.strip()]
407
+ selected_output = response.get("output", "text").strip() # Default to text output
408
+
409
+ if not isinstance(selected_sources, list) or not selected_sources or len(selected_sources) == 0:
410
+ raise ValueError(
411
+ f"Invalid response for determining relevant tools: {selected_sources}. Raw Response: {response}"
412
+ )
413
+
414
+ result: Dict = {"sources": [], "output": None} if not is_task else {"output": ConversationCommand.AutomatedTask}
415
+ for selected_source in selected_sources:
398
416
  # Add a double check to verify it's in the agent list, because the LLM sometimes gets confused by the tool options.
399
- if llm_suggested_tool in tool_options.keys() and (
400
- len(agent_tools) == 0 or llm_suggested_tool in agent_tools
417
+ if (
418
+ selected_source in source_options.keys()
419
+ and isinstance(result["sources"], list)
420
+ and (len(agent_sources) == 0 or selected_source in agent_sources)
401
421
  ):
402
422
  # Check whether the tool exists as a valid ConversationCommand
403
- final_response.append(ConversationCommand(llm_suggested_tool))
404
-
405
- if is_none_or_empty(final_response):
406
- if len(agent_tools) == 0:
407
- final_response = [ConversationCommand.Default]
408
- else:
409
- final_response = [ConversationCommand.General]
410
- except Exception:
411
- logger.error(f"Invalid response for determining relevant tools: {response}")
412
- if len(agent_tools) == 0:
413
- final_response = [ConversationCommand.Default]
414
- else:
415
- final_response = agent_tools
416
- return final_response
417
-
418
-
419
- async def aget_relevant_output_modes(
420
- query: str,
421
- conversation_history: dict,
422
- is_task: bool = False,
423
- user: KhojUser = None,
424
- query_images: List[str] = None,
425
- agent: Agent = None,
426
- tracer: dict = {},
427
- ):
428
- """
429
- Given a query, determine which of the available tools the agent should use in order to answer appropriately.
430
- """
431
-
432
- mode_options = dict()
433
- mode_options_str = ""
434
-
435
- output_modes = agent.output_modes if agent else []
436
-
437
- for mode, description in mode_descriptions_for_llm.items():
438
- # Do not allow tasks to schedule another task
439
- if is_task and mode == ConversationCommand.Automation:
440
- continue
441
- mode_options[mode.value] = description
442
- if len(output_modes) == 0 or mode.value in output_modes:
443
- mode_options_str += f'- "{mode.value}": "{description}"\n'
444
-
445
- chat_history = construct_chat_history(conversation_history)
446
-
447
- if query_images:
448
- query = f"[placeholder for {len(query_images)} user attached images]\n{query}"
449
-
450
- personality_context = (
451
- prompts.personality_context.format(personality=agent.personality) if agent and agent.personality else ""
452
- )
453
-
454
- relevant_mode_prompt = prompts.pick_relevant_output_mode.format(
455
- query=query,
456
- modes=mode_options_str,
457
- chat_history=chat_history,
458
- personality_context=personality_context,
459
- )
460
-
461
- with timer("Chat actor: Infer output mode for chat response", logger):
462
- response = await send_message_to_model_wrapper(
463
- relevant_mode_prompt, response_type="json_object", user=user, tracer=tracer
464
- )
465
-
466
- try:
467
- response = clean_json(response)
468
- response = json.loads(response)
469
-
470
- if is_none_or_empty(response):
471
- return ConversationCommand.Text
472
-
473
- output_mode = response["output"]
423
+ result["sources"].append(ConversationCommand(selected_source))
474
424
 
475
425
  # Add a double check to verify it's in the agent list, because the LLM sometimes gets confused by the tool options.
476
- if output_mode in mode_options.keys() and (len(output_modes) == 0 or output_mode in output_modes):
426
+ if selected_output in output_options.keys() and (len(agent_outputs) == 0 or selected_output in agent_outputs):
477
427
  # Check whether the tool exists as a valid ConversationCommand
478
- return ConversationCommand(output_mode)
428
+ result["output"] = ConversationCommand(selected_output)
479
429
 
480
- logger.error(f"Invalid output mode selected: {output_mode}. Defaulting to text.")
481
- return ConversationCommand.Text
482
- except Exception:
483
- logger.error(f"Invalid response for determining output mode: {response}")
484
- return ConversationCommand.Text
430
+ if is_none_or_empty(result):
431
+ if len(agent_sources) == 0:
432
+ result = {"sources": [ConversationCommand.Default], "output": ConversationCommand.Text}
433
+ else:
434
+ result = {"sources": [ConversationCommand.General], "output": ConversationCommand.Text}
435
+ except Exception as e:
436
+ logger.error(f"Invalid response for determining relevant tools: {response}. Error: {e}", exc_info=True)
437
+ sources = agent_sources if len(agent_sources) > 0 else [ConversationCommand.Default]
438
+ output = agent_outputs[0] if len(agent_outputs) > 0 else ConversationCommand.Text
439
+ result = {"sources": sources, "output": output}
440
+
441
+ return result
485
442
 
486
443
 
487
444
  async def infer_webpage_urls(
khoj/utils/constants.py CHANGED
@@ -10,9 +10,10 @@ telemetry_server = "https://khoj.beta.haletic.com/v1/telemetry"
10
10
  content_directory = "~/.khoj/content/"
11
11
  default_offline_chat_models = [
12
12
  "bartowski/Meta-Llama-3.1-8B-Instruct-GGUF",
13
+ "bartowski/Llama-3.2-3B-Instruct-GGUF",
13
14
  "bartowski/gemma-2-9b-it-GGUF",
14
15
  "bartowski/gemma-2-2b-it-GGUF",
15
- "bartowski/Phi-3.5-mini-instruct-GGUF",
16
+ "Qwen/Qwen2.5-14B-Instruct-GGUF",
16
17
  ]
17
18
  default_openai_chat_models = ["gpt-4o-mini", "gpt-4o"]
18
19
  default_gemini_chat_models = ["gemini-1.5-flash", "gemini-1.5-pro"]
khoj/utils/helpers.py CHANGED
@@ -365,7 +365,7 @@ tool_descriptions_for_llm = {
365
365
  ConversationCommand.Notes: "To search the user's personal knowledge base. Especially helpful if the question expects context from the user's notes or documents.",
366
366
  ConversationCommand.Online: "To search for the latest, up-to-date information from the internet. Note: **Questions about Khoj should always use this data source**",
367
367
  ConversationCommand.Webpage: "To use if the user has directly provided the webpage urls or you are certain of the webpage urls to read.",
368
- ConversationCommand.Code: "To run Python code in a Pyodide sandbox with no network access. Helpful when need to parse information, run complex calculations, create documents and charts for user. Matplotlib, bs4, pandas, numpy, etc. are available.",
368
+ ConversationCommand.Code: "To run Python code in a Pyodide sandbox with no network access. Helpful when need to parse information, run complex calculations, create plaintext documents, and create charts with quantitative data. Matplotlib, bs4, pandas, numpy, etc. are available.",
369
369
  ConversationCommand.Summarize: "To retrieve an answer that depends on the entire document or a large text.",
370
370
  }
371
371
 
@@ -373,14 +373,13 @@ function_calling_description_for_llm = {
373
373
  ConversationCommand.Notes: "To search the user's personal knowledge base. Especially helpful if the question expects context from the user's notes or documents.",
374
374
  ConversationCommand.Online: "To search the internet for information. Useful to get a quick, broad overview from the internet. Provide all relevant context to ensure new searches, not in previous iterations, are performed.",
375
375
  ConversationCommand.Webpage: "To extract information from webpages. Useful for more detailed research from the internet. Usually used when you know the webpage links to refer to. Share the webpage links and information to extract in your query.",
376
- ConversationCommand.Code: "To run Python code in a Pyodide sandbox with no network access. Helpful when need to parse information, run complex calculations, create charts for user. Matplotlib, bs4, pandas, numpy, etc. are available.",
376
+ ConversationCommand.Code: "To run Python code in a Pyodide sandbox with no network access. Helpful when need to parse information, run complex calculations, create plaintext documents, and create charts with quantitative data. Matplotlib, bs4, pandas, numpy, etc. are available.",
377
377
  }
378
378
 
379
379
  mode_descriptions_for_llm = {
380
- ConversationCommand.Image: "Use this if you are confident the user is requesting you to create a new picture based on their description. This does not support generating charts or graphs.",
381
- ConversationCommand.Automation: "Use this if you are confident the user is requesting a response at a scheduled date, time and frequency",
382
- ConversationCommand.Text: "Use this if a normal text response would be sufficient for accurately responding to the query.",
383
- ConversationCommand.Diagram: "Use this if the user is requesting a diagram or visual representation that requires primitives like lines, rectangles, and text.",
380
+ ConversationCommand.Image: "Use this if you are confident the user is requesting you to create a new picture based on their description. This DOES NOT support generating charts or graphs. It is for creative images.",
381
+ ConversationCommand.Text: "Use this if a normal text response would be sufficient for accurately responding to the query or you don't feel strongly about the other modes.",
382
+ ConversationCommand.Diagram: "Use this if the user is requesting a diagram or visual representation that requires primitives like lines, rectangles, and text. This does not work for charts, graphs, or quantitative data. It is for mind mapping, flowcharts, etc.",
384
383
  }
385
384
 
386
385
  mode_descriptions_for_agent = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: khoj
3
- Version: 1.29.2.dev26
3
+ Version: 1.30.1
4
4
  Summary: Your Second Brain
5
5
  Project-URL: Homepage, https://khoj.dev
6
6
  Project-URL: Documentation, https://docs.khoj.dev
@@ -1,5 +1,5 @@
1
1
  khoj/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- khoj/configure.py,sha256=JKqLxXFVe2Xm3MUWYA-3E45SJj_xo0THiLB2YKPb9dU,17312
2
+ khoj/configure.py,sha256=gJmEdBIXNje3tlCYgWG_t6KLv_fw2BxNSB7Aebao-Ck,17962
3
3
  khoj/main.py,sha256=WaV3muJXT-2MOBOm80kwvx76beUv2njJKRlbxs7jYvA,8300
4
4
  khoj/manage.py,sha256=njo6uLxGaMamTPesHjFEOIBJbpIUrz39e1V59zKj544,664
5
5
  khoj/app/README.md,sha256=PSQjKCdpU2hgszLVF8yEhV7TWhbEEb-1aYLTRuuAsKI,2832
@@ -11,7 +11,7 @@ khoj/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  khoj/database/admin.py,sha256=9xVVQ91gjLW4_ZpN1Ojp6zHynZBjMpJ_F_mEd1eyDA0,10718
12
12
  khoj/database/apps.py,sha256=pM4tkX5Odw4YW_hLLKK8Nd5kqGddf1en0oMCea44RZw,153
13
13
  khoj/database/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
14
- khoj/database/adapters/__init__.py,sha256=gv2SNrTpJvW1cPzFwSSY7qF7DYYXY1bWWxi-A141nkM,69020
14
+ khoj/database/adapters/__init__.py,sha256=KxGzqtDpbDPJdy-CZFXOM7sLqogzJXYyp_NDHgXttEg,69084
15
15
  khoj/database/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  khoj/database/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  khoj/database/management/commands/change_default_model.py,sha256=HkFQOI-2rFjlu7YiulyRcTrITzSzXmY4WiV2hBmml0w,5209
@@ -111,17 +111,17 @@ khoj/interface/compiled/chat.svg,sha256=l2JoYRRgk201adTTdvJ-buKUrc0WGfsudix5xEvt
111
111
  khoj/interface/compiled/close.svg,sha256=hQ2iFLkNzHk0_iyTrSbwnWAeXYlgA-c2Eof2Iqh76n4,417
112
112
  khoj/interface/compiled/copy-button-success.svg,sha256=byqWAYD3Pn9IOXRjOKudJ-TJbP2UESbQGvtLWazNGjY,829
113
113
  khoj/interface/compiled/copy-button.svg,sha256=05bKM2eRxksfBlAPT7yMaoNJEk85bZCxQg67EVrPeHo,669
114
- khoj/interface/compiled/index.html,sha256=YZfqiQij0BSok50L93feI8gv8HnRMA1F4-_r5xnsy1I,12156
115
- khoj/interface/compiled/index.txt,sha256=EIV_r21d5yD7dx6L3K1b5-uWFvRZTnTEr82Gfb6eIbM,5611
114
+ khoj/interface/compiled/index.html,sha256=lv3iHgmhV9vhY_0cWss4iAIw_8TTACwvwRm_Pb3BleA,12156
115
+ khoj/interface/compiled/index.txt,sha256=QtyVMjnM6ofyHarSQ8DtunZAImvPtQUO1JGSIJHcQrU,5611
116
116
  khoj/interface/compiled/khoj.webmanifest,sha256=lsknYkvEdMbRTOUYKXPM_8krN2gamJmM4u3qj8u9lrU,1682
117
117
  khoj/interface/compiled/logo.svg,sha256=_QCKVYM4WT2Qhcf7aVFImjq_s5CwjynGXYAOgI7yf8w,8059
118
118
  khoj/interface/compiled/send.svg,sha256=VdavOWkVddcwcGcld6pdfmwfz7S91M-9O28cfeiKJkM,635
119
119
  khoj/interface/compiled/share.svg,sha256=91lwo75PvMDrgocuZQab6EQ62CxRbubh9Bhw7CWMKbg,1221
120
120
  khoj/interface/compiled/thumbs-down.svg,sha256=JGNl-DwoRmH2XFMPWwFFklmoYtKxaQbkLE3nuYKe8ZY,1019
121
121
  khoj/interface/compiled/thumbs-up.svg,sha256=yS1wxTRtiztkN-6nZciLoYQUB_KTYNPV8xFRwH2TQFw,1036
122
- khoj/interface/compiled/404/index.html,sha256=1GIrezJGh8KE2Ype4oIfdL4u3wuZMCL0lkTdy2s3690,12023
123
- khoj/interface/compiled/_next/static/8GHdsBD3CrRSB--Guybv_/_buildManifest.js,sha256=6I9QUstNpJnhe3leR2Daw0pSXwzcbBscv6h2jmmPpms,224
124
- khoj/interface/compiled/_next/static/8GHdsBD3CrRSB--Guybv_/_ssgManifest.js,sha256=Z49s4suAsf5y_GfnQSvm4qtq2ggxEbZPfEDTXjy6XgA,80
122
+ khoj/interface/compiled/404/index.html,sha256=qmHBIN9hZ_J8iLwzIrit1M2FMtSqFnenQZLkmB9E5Kw,12023
123
+ khoj/interface/compiled/_next/static/SIep1wbq3DV05tttuBdtF/_buildManifest.js,sha256=6I9QUstNpJnhe3leR2Daw0pSXwzcbBscv6h2jmmPpms,224
124
+ khoj/interface/compiled/_next/static/SIep1wbq3DV05tttuBdtF/_ssgManifest.js,sha256=Z49s4suAsf5y_GfnQSvm4qtq2ggxEbZPfEDTXjy6XgA,80
125
125
  khoj/interface/compiled/_next/static/chunks/1210.132a7e1910006bbb.js,sha256=2dJueIfOg5qlQdanOM9HrgwcfrUXCD57bfd8Iv7iJcU,2104
126
126
  khoj/interface/compiled/_next/static/chunks/1279-f37ee4a388ebf544.js,sha256=U_1WaocOdgJ4HZB8tRx_izzYGD1EZlCohC1uLCffCWc,45582
127
127
  khoj/interface/compiled/_next/static/chunks/1459.690bf20e7d7b7090.js,sha256=z-ruZPxF_Z3ef_WOThd9Ox36AMhxaW3znizVivNnA34,34239
@@ -134,11 +134,11 @@ khoj/interface/compiled/_next/static/chunks/3803-d74118a2d0182c52.js,sha256=Elqf
134
134
  khoj/interface/compiled/_next/static/chunks/4504-1629487c8bc82203.js,sha256=z6NvJ2KOjYPbMNsYQKyX9PV4DeURUoP6LKoNb4kZXg0,11637
135
135
  khoj/interface/compiled/_next/static/chunks/4602-8eeb4b76385ad159.js,sha256=pz2lEr0JOrMdrddv2R2vej4e9uxpOr5KFX966ClLbOU,29928
136
136
  khoj/interface/compiled/_next/static/chunks/5512-94c7c2bbcf58c19d.js,sha256=ySpWRBlOMbttpBPr-j6_y9FmVrWfeRdardPkVnYAXzw,103730
137
- khoj/interface/compiled/_next/static/chunks/5538-32bd787d106700dc.js,sha256=aZZKwp3YRs4ff6gzG5PGSlyeCPvrzYB9Rw5dsdfdZpU,34191
138
- khoj/interface/compiled/_next/static/chunks/5961-3c104d9736b7902b.js,sha256=qss4GGVTNo_Rp3x8bU1I_l-SZCa-XAoVaxbLYOOcDTU,1089568
137
+ khoj/interface/compiled/_next/static/chunks/5538-b87b60ecc0c27ceb.js,sha256=_gYTfk_4_QokG8JC41SvGJmxgCjViwHflNNTX2rlzXI,34236
139
138
  khoj/interface/compiled/_next/static/chunks/6297-d1c842ed3f714ab0.js,sha256=4nzZ2umR-q6wQ-8L4RSivWXKV_SE1dWoN9qA1I9lCRI,25675
140
139
  khoj/interface/compiled/_next/static/chunks/7023-a5bf5744d19b3bd3.js,sha256=TBJA7dTnI8nymtbljKuZzo2hbStXWR-P8Qkl57k2Tw8,123898
141
140
  khoj/interface/compiled/_next/static/chunks/7883-b1305ec254213afe.js,sha256=dDbERTNiKRIIdC7idybjZq03gnxQtudMawrekye0zH8,241134
141
+ khoj/interface/compiled/_next/static/chunks/796-68f9e87f9cdfda1d.js,sha256=sGuaWffm4HXr8jrS3_HpLzmiGSrZ9TJV1l0btptfPLA,1092974
142
142
  khoj/interface/compiled/_next/static/chunks/8423-c0123d454681e03a.js,sha256=ZMV9-K9UbK23ldDrwnYVox4UU9vqxvbcwSgAPlqoeR8,15303
143
143
  khoj/interface/compiled/_next/static/chunks/9001-3b27af6d5f21df44.js,sha256=ran2mMGTO2kiAJebRGMyfyAu4Sdjw-WobS_m6g-qjz8,34223
144
144
  khoj/interface/compiled/_next/static/chunks/9417-32c4db52ca42e681.js,sha256=9r3lV-DxmhmQnYjroVbjAXPyX6rvSmhZKfUguE0dENw,15039
@@ -150,7 +150,7 @@ khoj/interface/compiled/_next/static/chunks/framework-8e0e0f4a6b83a956.js,sha256
150
150
  khoj/interface/compiled/_next/static/chunks/main-1ea5c2e0fdef4626.js,sha256=8_u87PGI3PahFbDfGWGvpD-a18J7X7ChUqWIeqxVq7g,111061
151
151
  khoj/interface/compiled/_next/static/chunks/main-app-6d6ee3495efe03d4.js,sha256=i52E7sWOcSq1G8eYZL3mtTxbUbwRNxcAbSWQ6uWpMsY,475
152
152
  khoj/interface/compiled/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js,sha256=6QPOwdWeAVe8x-SsiDrm-Ga6u2DkqgG5SFqglrlyIgA,91381
153
- khoj/interface/compiled/_next/static/chunks/webpack-63a7b969d34e6698.js,sha256=YXsRBGMWN01ciOv4OadI11jh51dox7cDDgR34p6NGfs,4054
153
+ khoj/interface/compiled/_next/static/chunks/webpack-ff5eae43b8dba1d2.js,sha256=t3K_SS6Kj9kQoGYNnDJBshxPPWwjoIR2nVsp2OhvVN4,4054
154
154
  khoj/interface/compiled/_next/static/chunks/app/layout-86561d2fac35a91a.js,sha256=2EWsyKE2kcC5uDvsOtgG5OP0hHCX8sCph4NqhUU2rCg,442
155
155
  khoj/interface/compiled/_next/static/chunks/app/page-e83f8a77f5c3caef.js,sha256=u72hDk0g6SFJNe-2B0yCF5BaI5PJa9Yr4aG9ZfseQW0,33220
156
156
  khoj/interface/compiled/_next/static/chunks/app/_not-found/page-07ff4ab42b07845e.js,sha256=3mCUnxfMxyK44eqk21TVBrC6u--WSbvx31fTmQuOvMQ,1755
@@ -159,13 +159,13 @@ khoj/interface/compiled/_next/static/chunks/app/agents/page-4353b1a532795ad1.js,
159
159
  khoj/interface/compiled/_next/static/chunks/app/automations/layout-27c28e923c9b1ff0.js,sha256=d2vJ_lVB0pfeFXNUPzHAe1ca5NzdNowHPh___SPqugM,5143
160
160
  khoj/interface/compiled/_next/static/chunks/app/automations/page-c9f13c865e739607.js,sha256=hkZk61Vrde0LIL4KPqnm_u2pd_LPzvt-f6Z0hkq8FCs,35344
161
161
  khoj/interface/compiled/_next/static/chunks/app/chat/layout-b0e7ff4baa3b5265.js,sha256=a-Qv2nHUrCa1gIs4Qo5txnOlhhQessAdcnAhhjaN3ag,374
162
- khoj/interface/compiled/_next/static/chunks/app/chat/page-1a23760147c678ba.js,sha256=Tf7_jIOE97TnfJmZyLXkBZfqWYTYqZMt4kPpbPprMEo,7071
162
+ khoj/interface/compiled/_next/static/chunks/app/chat/page-2790303dee566590.js,sha256=RGDpsMYas9FcQtQt4QWQbl_kKN2Ax0aWma1qpzJKl7c,7070
163
163
  khoj/interface/compiled/_next/static/chunks/app/search/layout-ea6b73fdaf9b24ca.js,sha256=mBgNUjaTBNgIKOpZj722mh1ojg1CNIYRBPiupStSS6s,165
164
164
  khoj/interface/compiled/_next/static/chunks/app/search/page-8e28deacb61f75aa.js,sha256=A3klMSdb4sxIAuHZ8NdbYgzc_WXhzIPFACF-D4CRino,6958
165
165
  khoj/interface/compiled/_next/static/chunks/app/settings/layout-254eaaf916449a60.js,sha256=kHAKleDbNFfhNM3e1WLJm3OFw6PDtGcjyj5toO24vps,5347
166
166
  khoj/interface/compiled/_next/static/chunks/app/settings/page-610d33158b233b34.js,sha256=gvcwqYV9CrC5M3KBpyn0b88m8u34brimEEYC0Z8ExiI,32149
167
167
  khoj/interface/compiled/_next/static/chunks/app/share/chat/layout-cf7445cf0326bda3.js,sha256=W3axh1K4y-pLSXcXogLl4qLKXr5BZLY1uA7JfSWp5TU,373
168
- khoj/interface/compiled/_next/static/chunks/app/share/chat/page-a0a8dd453394b651.js,sha256=HknoLJgT71zQp4OivbU6CDtl3Yk4PABbu39aHmK8hYE,4376
168
+ khoj/interface/compiled/_next/static/chunks/app/share/chat/page-07e1a8a345e768de.js,sha256=7-9xLo6k4faJWJmBltlUfVbZD7wbrFdld5WvE1yXVcM,4375
169
169
  khoj/interface/compiled/_next/static/chunks/pages/_app-f870474a17b7f2fd.js,sha256=eqdFPAN_XFyMUzZ9qwFk-_rhMWZrU7lgNVt1foVUANo,286
170
170
  khoj/interface/compiled/_next/static/chunks/pages/_error-c66a4e8afc46f17b.js,sha256=vjERjtMAbVk-19LyPf1Jc-H6TMcrSznSz6brzNqbqf8,253
171
171
  khoj/interface/compiled/_next/static/css/0e9d53dcd7f11342.css,sha256=52_LSJ59Vwm1p2UpcDXEvq99pTjz2sW4EjF5iKf-dzs,2622
@@ -248,8 +248,8 @@ khoj/interface/compiled/_next/static/media/flags.3afdda2f.webp,sha256=M2AW_HLpBn
248
248
  khoj/interface/compiled/_next/static/media/flags@2x.5fbe9fc1.webp,sha256=BBeRPBZkxY3-aKkMnYv5TSkxmbeMbyUH4VRIPfrWg1E,137406
249
249
  khoj/interface/compiled/_next/static/media/globe.98e105ca.webp,sha256=g3ofb8-W9GM75zIhlvQhaS8I2py9TtrovOKR3_7Jf04,514
250
250
  khoj/interface/compiled/_next/static/media/globe@2x.974df6f8.webp,sha256=I_N7Yke3IOoS-0CC6XD8o0IUWG8PdPbrHmf6lpgWlZY,1380
251
- khoj/interface/compiled/agents/index.html,sha256=cmQnbvmxvnHHkQG5caNV2z94JZn9zxJLoh9sZuOFFxA,12966
252
- khoj/interface/compiled/agents/index.txt,sha256=WvqmqLlwhMAf_2DFiemHQBjVG11miTkwjrj0_pGZQLc,6178
251
+ khoj/interface/compiled/agents/index.html,sha256=_ofQcxjw5Xg57VhEzwQ4J2cRamrmakOluJbb-PNgipA,12966
252
+ khoj/interface/compiled/agents/index.txt,sha256=dbMk7Fq6G_chDsdXUbv81evDwIJUr7ldytLs1NCV67w,6178
253
253
  khoj/interface/compiled/assets/icons/khoj_lantern.ico,sha256=eggu-B_v3z1R53EjOFhIqqPnICBGdoaw1xnc0NrzHck,174144
254
254
  khoj/interface/compiled/assets/icons/khoj_lantern_128x128.png,sha256=aTxivDb3CYyThkVZWz8A19xl_dNut5DbkXhODWF3A9Q,5640
255
255
  khoj/interface/compiled/assets/icons/khoj_lantern_256x256.png,sha256=xPCMLHiaL7lYOdQLZrKwWE-Qjn5ZaysSZB0ScYv4UZU,12312
@@ -260,16 +260,16 @@ khoj/interface/compiled/assets/samples/desktop-remember-plan-sample.png,sha256=i
260
260
  khoj/interface/compiled/assets/samples/phone-browse-draw-sample.png,sha256=Dd4fPwtFl6BWqnHjeb1mCK_ND0hhHsWtx8sNE7EiMuE,406179
261
261
  khoj/interface/compiled/assets/samples/phone-plain-chat-sample.png,sha256=DEDaNRCkfEWUeh3kYZWIQDTVK1a6KKnYdwj5ZWisN_Q,82985
262
262
  khoj/interface/compiled/assets/samples/phone-remember-plan-sample.png,sha256=Ma3blirRmq3X4oYSsDbbT7MDn29rymDrjwmUfA9BMuM,236285
263
- khoj/interface/compiled/automations/index.html,sha256=RvafdSO_4Zpp-_siLFSmF8bcuHXyDI55ZJ5ENxCWf5c,30633
264
- khoj/interface/compiled/automations/index.txt,sha256=1tPRf8Y853eHdr_nXMuLzQc7qVHqvmloDX05q86WGVE,5500
265
- khoj/interface/compiled/chat/index.html,sha256=qR8fCiGjN5v7D2NlG0GAKqp94quuDcH7Qb7DZRE1MK8,13860
266
- khoj/interface/compiled/chat/index.txt,sha256=8SNIBP-cpYA4CstG12Yc4bVMLxh11AQiH9lzHKFvknw,6590
267
- khoj/interface/compiled/search/index.html,sha256=3kyNgJg1ShDj1xj4O9mBg06_kKrsrBb0pIDZ7WO_oEI,30161
268
- khoj/interface/compiled/search/index.txt,sha256=kiLomYPGDB_BKVPg5ZfYSdlaAWPuboDSD3Kl8y9A2_w,5256
269
- khoj/interface/compiled/settings/index.html,sha256=bU3bfjkxsXLWUAwFbmceQcLOgw-tf9J4yNgrAustW8M,12831
270
- khoj/interface/compiled/settings/index.txt,sha256=APYcaOD6Mh6HAWAeaEvW7_7RlzxAq8MGlGAco4OwBWg,6078
271
- khoj/interface/compiled/share/chat/index.html,sha256=_X_nH0uwB-PVlR0hj249KFxY4MwO3fARHgj_qw51Yqg,15157
272
- khoj/interface/compiled/share/chat/index.txt,sha256=zdJIpdAWh9-6dVrlZFiUg297uYWVWuvPLaWNmI90-RE,7387
263
+ khoj/interface/compiled/automations/index.html,sha256=P6voj6-yLeUukIrOgCTZgxoM8bn7hCytgPyQiSfUQmU,30633
264
+ khoj/interface/compiled/automations/index.txt,sha256=h72QfJLzrVsXJnXxz126nSiXg4C5goMQp1knjFm34s4,5500
265
+ khoj/interface/compiled/chat/index.html,sha256=MCvrPcogu9DYEirloCRDowjVw8FtGUZ6A-lhwJ94pLA,13857
266
+ khoj/interface/compiled/chat/index.txt,sha256=vlfFf-IQeYsWHdygg9CUy8AY5Z2tbmBCHuIG5YdZF30,6588
267
+ khoj/interface/compiled/search/index.html,sha256=jzZkiijjoR98DFZHXOUirYQDvD0YnUgjJFVcshi4HCw,30161
268
+ khoj/interface/compiled/search/index.txt,sha256=sDREelFZ6FlbCLTLeoyePKVG4I2BtyStlBCix1N_LWk,5256
269
+ khoj/interface/compiled/settings/index.html,sha256=UrAmaiKmjqoWWEBQ0Fz_FuLVxOTgr8nVwbYp0VswgLo,12831
270
+ khoj/interface/compiled/settings/index.txt,sha256=0Z6dB9hShvUJEOASnMvINxtIZZywguEgKx99a3vsHs4,6078
271
+ khoj/interface/compiled/share/chat/index.html,sha256=mWps7mgxTvGjYEpd_g7Muk-mX0M_v3iitTqryJNCkqg,15154
272
+ khoj/interface/compiled/share/chat/index.txt,sha256=lh_fzBrktXh5mQwLzq_9biZKeVU7DS7dsBBXBjyQMKU,7385
273
273
  khoj/interface/email/feedback.html,sha256=xksuPFamx4hGWyTTxZKRgX_eiYQQEuv-eK9Xmkt-nwU,1216
274
274
  khoj/interface/email/magic_link.html,sha256=EoGKQucfPj3xQrWXhSZAzPFOYCHF_ZX94TWCd1XHl1M,941
275
275
  khoj/interface/email/task.html,sha256=tY7a0gzVeQ2lSQNu7WyXR_s7VYeWTrxWEj1iHVuoVE4,2813
@@ -320,8 +320,8 @@ khoj/processor/content/pdf/pdf_to_entries.py,sha256=GQUvab61okhV9_DK0g2MCrMq8wKp
320
320
  khoj/processor/content/plaintext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
321
321
  khoj/processor/content/plaintext/plaintext_to_entries.py,sha256=wFZwK_zIc7gWbRtO9sOHo9KvfhGAzL9psX_nKWYFduo,4975
322
322
  khoj/processor/conversation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
323
- khoj/processor/conversation/prompts.py,sha256=jXVxeFYHBP6LBSAmdykYH6in297VTgVdEJ5IDsYlQnI,50319
324
- khoj/processor/conversation/utils.py,sha256=2gbglhzKMEuldL0P9Y6miCF8BNooiEgFFNdgc8lvneQ,27870
323
+ khoj/processor/conversation/prompts.py,sha256=WokfQopt1bfaGTi0YYAIxrYDI0aCFYhx05vE0IfGokY,48999
324
+ khoj/processor/conversation/utils.py,sha256=LtkNesyGPavqgJ66Ptdf_UE8u6VAN5KJWpFHf95zO2U,28479
325
325
  khoj/processor/conversation/anthropic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
326
326
  khoj/processor/conversation/anthropic/anthropic_chat.py,sha256=8w7oSTBIxcZa6y03Zo2nuQFa2WMiazwK_qfO2q_O-6c,8618
327
327
  khoj/processor/conversation/anthropic/utils.py,sha256=6_FnsfLRqjkubkfMVmPTEEBzvMUOAccIz5AHV6B9mU8,6623
@@ -343,16 +343,16 @@ khoj/processor/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
343
343
  khoj/processor/tools/online_search.py,sha256=X8D3ClKpg34r_LMol28GdBqZ--YVGGVBPc9lUSgb2mg,17128
344
344
  khoj/processor/tools/run_code.py,sha256=i9ce53dw0y5ZNhPorRNYJieIKw6eyrZQX0ABDrWiW8M,7738
345
345
  khoj/routers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
346
- khoj/routers/api.py,sha256=_AI1pnQMQM75L6WVZSAVfvrk04pLEdLbHA0fkyxnUbo,28489
346
+ khoj/routers/api.py,sha256=Z-0MqhlbhxR-palz_Kl3CqsC8O91n-xmgj8JNqQ8lv0,28495
347
347
  khoj/routers/api_agents.py,sha256=vHPruCjlQxGBdm0lcmymEb9-aAELqbOplqh21WwD0DQ,9699
348
- khoj/routers/api_chat.py,sha256=83jqlGex6K3bry9_Pq4Ti8pEGHhENsjtlW4EgWbL-88,48704
348
+ khoj/routers/api_chat.py,sha256=MsiqhXiWT_c4u3DqqvAwoT-3oeudMQSqzZyHMbmHne0,49280
349
349
  khoj/routers/api_content.py,sha256=WNlB6lVwRW8hHDthO2HypbpPvqrqt9rTU5oMRNknpMU,21070
350
350
  khoj/routers/api_model.py,sha256=KDsxNwHspC94eTcv6l3ehr773EOvgc670UnZLE1WZ4o,3642
351
351
  khoj/routers/api_phone.py,sha256=p9yfc4WeMHDC0hg3aQk60a2VBy8rZPdEnz9wdJ7DzkU,2208
352
352
  khoj/routers/api_subscription.py,sha256=J6xZNZDdOA71vCfethlPfAyfvRBq4HGCBpbsOZ9CWj0,5333
353
353
  khoj/routers/auth.py,sha256=HO54PR-BkWA_iJIktEobUrObcXVYG-00jpnIcEVdR5s,6564
354
354
  khoj/routers/email.py,sha256=SGYNPQvfcvYeHf70F0YqpY0FLMRElF2ZekROXdwGI18,3821
355
- khoj/routers/helpers.py,sha256=v-dnh2AwuXQNCWGHYLacGnq-8bNSluU2Ym8z7JG4ek0,82672
355
+ khoj/routers/helpers.py,sha256=tVnlU6OEc9fWVuj11Acsf_zvPkSTM6fzFCC7mI15GfQ,81658
356
356
  khoj/routers/notion.py,sha256=g53xyYFmjr2JnuIrTW2vytbfkiK_UkoRTxqnnLSmD5o,2802
357
357
  khoj/routers/research.py,sha256=SczFMS9a8_Wxhh3n_Zt9CJ-zZugBDAd_WmiZGFa6RR8,16117
358
358
  khoj/routers/storage.py,sha256=tJrwhFRVWv0MHv7V7huMc1Diwm-putZSwnZXJ3tqT_c,2338
@@ -368,17 +368,17 @@ khoj/search_type/text_search.py,sha256=PZzJVCXpeBM795SIqiAKXAxgnCp1NIRiVikm040r1
368
368
  khoj/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
369
369
  khoj/utils/cli.py,sha256=EA7IvWAInUIll8YFTOpQtqLtCQXwphfHi5rJ2TKAdSQ,3757
370
370
  khoj/utils/config.py,sha256=aiOkH0je8A30DAGYTHMRePrgJonFv_i07_7CdhhhcdA,1805
371
- khoj/utils/constants.py,sha256=DNts_NN4ZL9nRCA9KH3ZD_6PBK9VVggtun79pQxzNnU,1219
371
+ khoj/utils/constants.py,sha256=vjMu-gVRxrTSlxBb1eAXYfRjqf8NchbiWuxDXtQ4G3c,1257
372
372
  khoj/utils/fs_syncer.py,sha256=5nqwAZqRk3Nwhkwd8y4IomTPZQmW32GwAqyMzal5KyY,9996
373
- khoj/utils/helpers.py,sha256=JMCxQKEmz9ktZrSLQQh3cpm97dVsHT5J0rKY3bTrNco,20126
373
+ khoj/utils/helpers.py,sha256=tdwRlkI5IqOr07cxw4zKindR3hSn6cGthPYHSXs2BcU,20239
374
374
  khoj/utils/initialization.py,sha256=nJtqPUv52SPA6sPHn0_vs1uSBdDihX25Dvvagu81Xbs,13490
375
375
  khoj/utils/jsonl.py,sha256=0Ac_COqr8sLCXntzZtquxuCEVRM2c3yKeDRGhgOBRpQ,1192
376
376
  khoj/utils/models.py,sha256=Q5tcC9-z25sCiub048fLnvZ6_IIO1bcPNxt5payekk0,2009
377
377
  khoj/utils/rawconfig.py,sha256=bQ_MGbBzYt6ZUIsHUwZjaHKDLh6GQ7h-sENkv3fyVbQ,5028
378
378
  khoj/utils/state.py,sha256=KtUEIKAZdGGN_Qr58RS1pgcywgSafun8YIXx-YEclAY,1645
379
379
  khoj/utils/yaml.py,sha256=qy1Tkc61rDMesBw_Cyx2vOR6H-Hngcsm5kYfjwQBwkE,1543
380
- khoj-1.29.2.dev26.dist-info/METADATA,sha256=JwsOcDhNsddYesiVpxjmDt0UTF4qF3Xvwh62C_mNs-M,7120
381
- khoj-1.29.2.dev26.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
382
- khoj-1.29.2.dev26.dist-info/entry_points.txt,sha256=KBIcez5N_jCgq_ER4Uxf-e1lxTBMTE_BBjMwwfeZyAg,39
383
- khoj-1.29.2.dev26.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
384
- khoj-1.29.2.dev26.dist-info/RECORD,,
380
+ khoj-1.30.1.dist-info/METADATA,sha256=o4ZMC35ALFUr5PdkJ5Dg0UhGwhPzSKcCKdbh7Qw74rc,7114
381
+ khoj-1.30.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
382
+ khoj-1.30.1.dist-info/entry_points.txt,sha256=KBIcez5N_jCgq_ER4Uxf-e1lxTBMTE_BBjMwwfeZyAg,39
383
+ khoj-1.30.1.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
384
+ khoj-1.30.1.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5538],{55538:function(e,t,a){"use strict";a.d(t,{Z:function(){return eC}});var n=a(57437),s=a(15238),o=a.n(s),l=a(2265),r=a(34531),c=a.n(r),i=a(14944),d=a(39952),u=a.n(d),h=a(34040);a(7395);var m=a(11961),g=a(26100),f=a(36013),p=a(13304),x=a(12218),v=a(74697),j=a(37440);let w=p.fC,b=p.xz;p.x8;let y=p.h_,C=l.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(p.aV,{className:(0,j.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...s,ref:t})});C.displayName=p.aV.displayName;let N=(0,x.j)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),M=l.forwardRef((e,t)=>{let{side:a="right",className:s,children:o,...l}=e;return(0,n.jsxs)(y,{children:[(0,n.jsx)(C,{}),(0,n.jsxs)(p.VY,{ref:t,className:(0,j.cn)(N({side:a}),s),...l,children:[o,(0,n.jsxs)(p.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,n.jsx)(v.Z,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});M.displayName=p.VY.displayName;let k=e=>{let{className:t,...a}=e;return(0,n.jsx)("div",{className:(0,j.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...a})};k.displayName="SheetHeader";let _=l.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(p.Dx,{ref:t,className:(0,j.cn)("text-lg font-semibold text-foreground",a),...s})});_.displayName=p.Dx.displayName;let R=l.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(p.dk,{ref:t,className:(0,j.cn)("text-sm text-muted-foreground",a),...s})});R.displayName=p.dk.displayName;var I=a(19573),T=a(11838),E=a.n(T),F=a(89417);let D=new i.Z({html:!0,linkify:!0,typographer:!0});function S(e){let t=(0,F.Le)(e.title||".txt","w-6 h-6 text-muted-foreground inline-flex mr-2"),a=e.title.split("/").pop()||e.title,s=function(e){let t=["org","md","markdown"].includes(e.title.split(".").pop()||"")?e.content.split("\n").slice(1).join("\n"):e.content;return e.showFullContent?E().sanitize(D.render(t)):E().sanitize(t)}(e),[o,r]=(0,l.useState)(!1);return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(I.J2,{open:o&&!e.showFullContent,onOpenChange:r,children:[(0,n.jsx)(I.xo,{asChild:!0,children:(0,n.jsxs)(f.Zb,{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg border-none p-2 bg-muted"),children:[(0,n.jsxs)("h3",{className:"".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground}"),children:[t,e.showFullContent?e.title:a]}),(0,n.jsx)("p",{className:"text-sm ".concat(e.showFullContent?"overflow-x-auto block":"overflow-hidden line-clamp-2"),dangerouslySetInnerHTML:{__html:s}})]})}),(0,n.jsx)(I.yk,{className:"w-[400px] mx-2",children:(0,n.jsxs)(f.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none p-2",children:[(0,n.jsxs)("h3",{className:"line-clamp-2 text-muted-foreground}",children:[t,e.title]}),(0,n.jsx)("p",{className:"border-t mt-1 pt-1 text-sm overflow-hidden line-clamp-5",dangerouslySetInnerHTML:{__html:s}})]})})]})})}function L(e){var t,a,s,o,r,c;let i=(0,F.Le)(".py","!w-4 h-4 text-muted-foreground flex-shrink-0"),d=E().sanitize(e.code),[u,h]=(0,l.useState)(!1),[g,p]=(0,l.useState)(!1),x=e=>{let t="text/plain",a=e.b64_data;e.filename.match(/\.(png|jpg|jpeg|webp)$/)?(t="image/".concat(e.filename.split(".").pop()),a=atob(e.b64_data)):e.filename.endsWith(".json")?t="application/json":e.filename.endsWith(".csv")&&(t="text/csv");let n=new ArrayBuffer(a.length),s=new Uint8Array(n);for(let e=0;e<a.length;e++)s[e]=a.charCodeAt(e);let o=new Blob([n],{type:t}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download=e.filename,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(l)},v=(t,a)=>(null==t?void 0:t.length)==0?null:(0,n.jsx)("div",{className:"".concat(a||e.showFullContent?"border-t mt-1 pt-1":void 0),children:t.slice(0,e.showFullContent?void 0:1).map((t,s)=>(0,n.jsxs)("div",{children:[(0,n.jsxs)("h4",{className:"text-sm text-muted-foreground flex items-center",children:[(0,n.jsx)("span",{className:"overflow-hidden mr-2 font-bold ".concat(e.showFullContent?void 0:"line-clamp-1"),children:t.filename}),(0,n.jsx)("button",{className:"".concat(a?"hidden":void 0),onClick:e=>{e.preventDefault(),x(t)},onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),title:"Download file: ".concat(t.filename),children:(0,n.jsx)(m.b,{className:"w-4 h-4",weight:g?"fill":"regular"})})]}),t.filename.match(/\.(txt|org|md|csv|json)$/)?(0,n.jsx)("pre",{className:"".concat(e.showFullContent?"block":"line-clamp-2"," text-sm mt-1 p-1 bg-background rounded overflow-x-auto"),children:t.b64_data}):t.filename.match(/\.(png|jpg|jpeg|webp)$/)?(0,n.jsx)("img",{src:"data:image/".concat(t.filename.split(".").pop(),";base64,").concat(t.b64_data),alt:t.filename,className:"mt-1 max-h-32 rounded"}):null]},"".concat(t.filename,"-").concat(s)))});return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(I.J2,{open:u&&!e.showFullContent,onOpenChange:h,children:[(0,n.jsx)(I.xo,{asChild:!0,children:(0,n.jsx)(f.Zb,{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg border-none p-2 bg-muted"),children:(0,n.jsxs)("div",{className:"flex flex-col px-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[i,(0,n.jsxs)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:["code ",(null===(t=e.output_files)||void 0===t?void 0:t.length)>0?"artifacts":""]})]}),(0,n.jsx)("pre",{className:"text-xs pb-2 ".concat(e.showFullContent?"block overflow-x-auto":(null===(a=e.output_files)||void 0===a?void 0:a.length)>0?"hidden":"overflow-hidden line-clamp-3"),children:d}),(null===(s=e.output_files)||void 0===s?void 0:s.length)>0&&v(e.output_files,!1)]})})}),(0,n.jsx)(I.yk,{className:"w-[400px] mx-2",children:(0,n.jsxs)(f.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none p-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[i,(0,n.jsxs)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:["code ",(null===(o=e.output_files)||void 0===o?void 0:o.length)>0?"artifact":""]})]}),(null===(r=e.output_files)||void 0===r?void 0:r.length)>0&&v(null===(c=e.output_files)||void 0===c?void 0:c.slice(0,1),!0)||(0,n.jsx)("pre",{className:"text-xs border-t mt-1 pt-1 verflow-hidden line-clamp-10",children:d})]})})]})})}function O(e){let[t,a]=(0,l.useState)(!1);if(!e.link||e.link.split(" ").length>1)return null;let s="https://www.google.com/s2/favicons?domain=globe",o="unknown";try{o=new URL(e.link).hostname,s="https://www.google.com/s2/favicons?domain=".concat(o)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(I.J2,{open:t&&!e.showFullContent,onOpenChange:a,children:[(0,n.jsx)(I.xo,{asChild:!0,children:(0,n.jsx)(f.Zb,{onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)},className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg border-none p-2 bg-muted"),children:(0,n.jsx)("div",{className:"flex flex-col",children:(0,n.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline px-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("img",{src:s,alt:"",className:"!w-4 h-4 flex-shrink-0"}),(0,n.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:o})]}),(0,n.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," font-bold"),children:e.title}),(0,n.jsx)("p",{className:"overflow-hidden text-sm ".concat(e.showFullContent?"block":"line-clamp-2"),children:e.description})]})})})}),(0,n.jsx)(I.yk,{className:"w-[400px] mx-2",children:(0,n.jsx)(f.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none",children:(0,n.jsx)("div",{className:"flex flex-col",children:(0,n.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline px-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("img",{src:s,alt:"",className:"!w-4 h-4 flex-shrink-0"}),(0,n.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," text-muted-foreground flex-grow"),children:o})]}),(0,n.jsx)("h3",{className:"border-t mt-1 pt-1 overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," font-bold"),children:e.title}),(0,n.jsx)("p",{className:"overflow-hidden text-sm ".concat(e.showFullContent?"block":"line-clamp-5"),children:e.description})]})})})})]})})}function B(e){let[t,a]=(0,l.useState)(3);(0,l.useEffect)(()=>{a(e.isMobileWidth?1:3)},[e.isMobileWidth]);let s=e.codeReferenceCardData.slice(0,t),o=e.notesReferenceCardData.slice(0,t-s.length),r=o.length+s.length<t?e.onlineReferenceCardData.slice(0,t-s.length-o.length):[],c=e.notesReferenceCardData.length>0||e.codeReferenceCardData.length>0||e.onlineReferenceCardData.length>0,i=e.notesReferenceCardData.length+e.codeReferenceCardData.length+e.onlineReferenceCardData.length;return 0===i?null:(0,n.jsxs)("div",{className:"pt-0 px-4 pb-4 md:px-6",children:[(0,n.jsxs)("h3",{className:"inline-flex items-center",children:["References",(0,n.jsxs)("p",{className:"text-gray-400 m-2",children:[i," sources"]})]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[s.map((e,t)=>(0,l.createElement)(L,{showFullContent:!1,...e,key:"code-".concat(t)})),o.map((e,t)=>(0,l.createElement)(S,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),r.map((e,t)=>(0,l.createElement)(O,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),c&&(0,n.jsx)(q,{notesReferenceCardData:e.notesReferenceCardData,onlineReferenceCardData:e.onlineReferenceCardData,codeReferenceCardData:e.codeReferenceCardData})]})]})}function q(e){return e.notesReferenceCardData||e.onlineReferenceCardData?(0,n.jsxs)(w,{children:[(0,n.jsxs)(b,{className:"text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center !m-2 inline-flex",children:["View references",(0,n.jsx)(g.o,{className:"m-1"})]}),(0,n.jsxs)(M,{className:"overflow-y-scroll",children:[(0,n.jsxs)(k,{children:[(0,n.jsx)(_,{children:"References"}),(0,n.jsx)(R,{children:"View all references for this response"})]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[e.codeReferenceCardData.map((e,t)=>(0,l.createElement)(L,{showFullContent:!0,...e,key:"code-".concat(t)})),e.notesReferenceCardData.map((e,t)=>(0,l.createElement)(S,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)})),e.onlineReferenceCardData.map((e,t)=>(0,l.createElement)(O,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)}))]})]})]}):null}var H=a(9557),A=a(34149),W=a(29386),z=a(31784),U=a(60665),Z=a(96006),V=a(18444),$=a(35304),P=a(8589),G=a(13493),J=a(63205),Q=a(56698),Y=a(32970),K=a(84120),X=a(92880),ee=a(48408),et=a(55362),ea=a(67722),en=a(58485),es=a(58575),eo=a(25800);let el=(0,a(57818).default)(()=>Promise.all([a.e(6555),a.e(7293),a.e(1459),a.e(1210)]).then(a.bind(a,51210)).then(e=>e.default),{loadableGenerated:{webpack:()=>[51210]},ssr:!1});function er(e){return(0,n.jsx)(l.Suspense,{fallback:(0,n.jsx)(en.Z,{}),children:(0,n.jsx)(el,{data:e.data})})}var ec=a(90837),ei=a(69591),ed=a(94880);let eu=new i.Z({html:!0,linkify:!0,typographer:!0});function eh(e,t,a){fetch("/api/chat/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uquery:e,kquery:t,sentiment:a})})}function em(e){let{uquery:t,kquery:a}=e,[s,o]=(0,l.useState)(null);return(0,l.useEffect)(()=>{null!==s&&setTimeout(()=>{o(null)},2e3)},[s]),(0,n.jsxs)("div",{className:"".concat(c().feedbackButtons," flex align-middle justify-center items-center"),children:[(0,n.jsx)("button",{title:"Like",className:c().thumbsUpButton,disabled:null!==s,onClick:()=>{eh(t,a,"positive"),o(!0)},children:!0===s?(0,n.jsx)(A.V,{alt:"Liked Message",className:"text-green-500",weight:"fill"}):(0,n.jsx)(A.V,{alt:"Like Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),(0,n.jsx)("button",{title:"Dislike",className:c().thumbsDownButton,disabled:null!==s,onClick:()=>{eh(t,a,"negative"),o(!1)},children:!1===s?(0,n.jsx)(W.L,{alt:"Disliked Message",className:"text-red-500",weight:"fill"}):(0,n.jsx)(W.L,{alt:"Dislike Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})})]})}function eg(e){let t=e.message.match(/\*\*(.*)\*\*/),a=function(e,t){let a=e.toLowerCase(),s="inline mt-1 mr-2 ".concat(t," h-4 w-4");return a.includes("understanding")?(0,n.jsx)(z.a,{className:"".concat(s)}):a.includes("generating")?(0,n.jsx)(U.Z,{className:"".concat(s)}):a.includes("data sources")||a.includes("notes")?(0,n.jsx)(Z.g,{className:"".concat(s)}):a.includes("read")?(0,n.jsx)(V.f,{className:"".concat(s)}):a.includes("search")?(0,n.jsx)($.Y,{className:"".concat(s)}):a.includes("summary")||a.includes("summarize")||a.includes("enhanc")?(0,n.jsx)(P.u,{className:"".concat(s)}):a.includes("diagram")?(0,n.jsx)(G.j,{className:"".concat(s)}):a.includes("paint")?(0,n.jsx)(J.Y,{className:"".concat(s)}):a.includes("code")?(0,n.jsx)(Q.E,{className:"".concat(s)}):(0,n.jsx)(z.a,{className:"".concat(s)})}(t?t[1]:"",e.primary?(0,es.oz)(e.agentColor):"text-gray-500"),s=E().sanitize(eu.render(e.message));return s=s.replace(/<h[1-6].*?<\/h[1-6]>/g,""),(0,n.jsxs)("div",{className:"".concat(c().trainOfThoughtElement," break-words items-center ").concat(e.primary?"text-gray-400":"text-gray-300"," ").concat(c().trainOfThought," ").concat(e.primary?c().primary:""),children:[a,(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:s},className:"break-words"})]})}eu.use(u(),{inline:!0,code:!0});let ef=(0,l.forwardRef)((e,t)=>{var a,s;let o,r,i,d,u;let[m,g]=(0,l.useState)(!1),[f,x]=(0,l.useState)(!1),[v,j]=(0,l.useState)(""),[w,b]=(0,l.useState)(""),[y,C]=(0,l.useState)(!1),[N,M]=(0,l.useState)(!1),[k,_]=(0,l.useState)(""),R=(0,l.useRef)(!1),I=(0,l.useRef)(null);async function T(){let t=e.chatMessage.message.match(/[^.!?]+[.!?]*/g)||[];if(!t||0===t.length||!t[0])return;C(!0);let a=D(t[0]);for(let e=0;e<t.length&&!R.current;e++){let n=a;e<t.length-1&&(a=D(t[e+1]));try{let e=await n,t=URL.createObjectURL(e);await function(e){return new Promise((t,a)=>{let n=new Audio(e);n.onended=t,n.onerror=a,n.play()})}(t)}catch(e){console.error("Error:",e);break}}C(!1),M(!1)}async function D(e){let t=await fetch("/api/chat/speech?text=".concat(encodeURIComponent(e)),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Network response was not ok");return await t.blob()}(0,l.useEffect)(()=>{R.current=N},[N]),(0,l.useEffect)(()=>{let e=new MutationObserver((e,t)=>{if(I.current)for(let t of e)"childList"===t.type&&t.addedNodes.length>0&&(0,eo.Z)(I.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]})});return I.current&&e.observe(I.current,{childList:!0}),()=>e.disconnect()},[I.current]),(0,l.useEffect)(()=>{let t=e.chatMessage.message;e.chatMessage.intent&&"excalidraw"==e.chatMessage.intent.type&&(t=e.chatMessage.intent["inferred-queries"][0],_(e.chatMessage.message)),t=t.replace(/\\\(/g,"LEFTPAREN").replace(/\\\)/g,"RIGHTPAREN").replace(/\\\[/g,"LEFTBRACKET").replace(/\\\]/g,"RIGHTBRACKET");let a={"text-to-image":e=>"![generated image](data:image/png;base64,".concat(e,")"),"text-to-image2":e=>"![generated image](".concat(e,")"),"text-to-image-v3":e=>"![generated image](data:image/webp;base64,".concat(e,")"),excalidraw:e=>e};if(e.chatMessage.intent){let{type:n,"inferred-queries":s}=e.chatMessage.intent;n in a&&(t=a[n](t)),n.includes("text-to-image")&&(null==s?void 0:s.length)>0&&(t+="\n\n".concat(s[0]))}t=(0,H.AQ)(t,e.chatMessage.codeContext),e.chatMessage.codeContext&&Object.entries(e.chatMessage.codeContext).forEach(e=>{var a;let[n,s]=e;null===(a=s.results.output_files)||void 0===a||a.forEach(e=>{(e.filename.endsWith(".png")||e.filename.endsWith(".jpg"))&&!t.includes("![".concat(e.filename,"]("))&&(t+="\n\n![".concat(e.filename,"](data:image/png;base64,").concat(e.b64_data,")"))})});let n=t,s=t;if(e.chatMessage.images&&e.chatMessage.images.length>0){let t=e.chatMessage.images.map(e=>{let t=e.startsWith("data%3Aimage")?decodeURIComponent(e):e;return E().sanitize(t)}),a=t.map((e,t)=>"![uploaded image ".concat(t+1,"](").concat(e,")")).join("\n"),o=t.map((e,t)=>'<div class="'.concat(c().imageWrapper,'"><img src="').concat(e,'" alt="uploaded image ').concat(t+1,'" /></div>')).join(""),l='<div class="'.concat(c().imagesContainer,'">').concat(o,"</div>");n="".concat(a,"\n\n").concat(n),s="".concat(l).concat(s)}j(n);let o=eu.render(s);o=o.replace(/LEFTPAREN/g,"\\(").replace(/RIGHTPAREN/g,"\\)").replace(/LEFTBRACKET/g,"\\[").replace(/RIGHTBRACKET/g,"\\]"),b(E().sanitize(o))},[e.chatMessage.message,e.chatMessage.images,e.chatMessage.intent]),(0,l.useEffect)(()=>{m&&setTimeout(()=>{g(!1)},2e3)},[m]),(0,l.useEffect)(()=>{I.current&&(I.current.querySelectorAll("pre > .hljs").forEach(e=>{if(!e.querySelector("".concat(c().codeCopyButton))){let t=document.createElement("button"),a=(0,n.jsx)(Y.w,{size:24});(0,h.createRoot)(t).render(a),t.className="hljs ".concat(c().codeCopyButton),t.addEventListener("click",()=>{let a=e.textContent||"";a=(a=(a=a.replace(/^\$+/,"")).replace(/^Copy/,"")).trim(),navigator.clipboard.writeText(a);let s=(0,n.jsx)(K.J,{size:24});(0,h.createRoot)(t).render(s)}),e.prepend(t)}}),(0,eo.Z)(I.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]}))},[w,f,I]);let S=async t=>{let a=t.turnId||e.turnId;(await fetch("/api/chat/conversation/message",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversation_id:e.conversationId,turn_id:a})})).ok?e.onDeleteMessage(a):console.error("Failed to delete message")},L=function(e,t,a){let n=[],s=[],o=[];if(a)for(let[e,t]of Object.entries(a))t.results&&o.push({code:t.code,output:t.results.std_out,output_files:t.results.output_files,error:t.results.std_err});if(t){let e=[];for(let[a,n]of Object.entries(t)){if(n.answerBox&&e.push({title:n.answerBox.title,description:n.answerBox.answer,link:n.answerBox.source}),n.knowledgeGraph&&e.push({title:n.knowledgeGraph.title,description:n.knowledgeGraph.description,link:n.knowledgeGraph.descriptionLink}),n.webpages){if(n.webpages instanceof Array){let t=n.webpages.map(e=>({title:e.query,description:e.snippet,link:e.link}));e.push(...t)}else{let t=n.webpages;e.push({title:t.query,description:t.snippet,link:t.link})}}if(n.organic){let t=n.organic.map(e=>({title:e.title,description:e.snippet,link:e.link}));e.push(...t)}}n.push(...e)}if(e){let t=e.map(e=>e.compiled?{title:e.file,content:e.compiled}:{title:e.split("\n")[0],content:e.split("\n").slice(1).join("\n")});s.push(...t)}return{notesReferenceCardData:s,onlineReferenceCardData:n,codeReferenceCardData:o}}(e.chatMessage.context,e.chatMessage.onlineContext,e.chatMessage.codeContext);return(0,n.jsxs)("div",{ref:t,className:(a=e.chatMessage,(o=[c().chatMessageContainer,"shadow-md"]).push(c()[a.by]),a.message||o.push(c().emptyChatMessage),e.customClassName&&o.push(c()["".concat(a.by).concat(e.customClassName)]),o.join(" ")),onMouseLeave:e=>x(!1),onMouseEnter:e=>x(!0),children:[(0,n.jsxs)("div",{className:(s=e.chatMessage,(r=[c().chatMessageWrapper]).push(c()[s.by]),"khoj"===s.by&&r.push("border-l-4 border-opacity-50 ".concat("border-l-"+e.borderLeftColor)),r.join(" ")),children:[e.chatMessage.queryFiles&&e.chatMessage.queryFiles.length>0&&(0,n.jsx)("div",{className:"flex flex-wrap flex-col mb-2 max-w-full",children:e.chatMessage.queryFiles.map((e,t)=>(0,n.jsxs)(ec.Vq,{children:[(0,n.jsx)(ec.hg,{asChild:!0,children:(0,n.jsxs)("div",{className:"flex items-center space-x-2 cursor-pointer bg-gray-500 bg-opacity-25 rounded-lg p-2 w-full ",children:[(0,n.jsx)("div",{className:"flex-shrink-0",children:(0,F.Le)(e.file_type)}),(0,n.jsx)("span",{className:"truncate flex-1 min-w-0 max-w-[200px]",children:e.name}),e.size&&(0,n.jsxs)("span",{className:"text-gray-400 flex-shrink-0",children:["(",(0,ei.xq)(e.size),")"]})]})}),(0,n.jsxs)(ec.cZ,{children:[(0,n.jsx)(ec.fK,{children:(0,n.jsx)(p.$N,{children:(0,n.jsx)("div",{className:"truncate min-w-0 break-words break-all text-wrap max-w-full whitespace-normal",children:e.name})})}),(0,n.jsx)(ec.Be,{children:(0,n.jsx)(ed.x,{className:"h-72 w-full rounded-md break-words break-all text-wrap",children:e.content})})]})]},t))}),(0,n.jsx)("div",{ref:I,className:c().chatMessage,dangerouslySetInnerHTML:{__html:w}}),k&&(0,n.jsx)(er,{data:k})]}),(0,n.jsx)("div",{className:c().teaserReferencesContainer,children:(0,n.jsx)(B,{isMobileWidth:e.isMobileWidth,notesReferenceCardData:L.notesReferenceCardData,onlineReferenceCardData:L.onlineReferenceCardData,codeReferenceCardData:L.codeReferenceCardData})}),(0,n.jsx)("div",{className:c().chatFooter,children:(f||e.isMobileWidth||e.isLastMessage||y)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{title:(d=(i=new Date(e.chatMessage.created+"Z")).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).toUpperCase(),u=i.toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit"}).replaceAll("-"," "),"".concat(d," on ").concat(u)),className:"text-gray-400 relative top-0 left-4",children:function(e){e.endsWith("Z")||(e+="Z");let t=new Date(e),a=new Date().getTime()-t.getTime();return a<6e4?"Just now":a<36e5?"".concat(Math.round(a/6e4),"m ago"):a<864e5?"".concat(Math.round(a/36e5),"h ago"):"".concat(Math.round(a/864e5),"d ago")}(e.chatMessage.created)}),(0,n.jsxs)("div",{className:"".concat(c().chatButtons," shadow-sm"),children:["khoj"===e.chatMessage.by&&(y?N?(0,n.jsx)(en.l,{iconClassName:"p-0",className:"m-0"}):(0,n.jsx)("button",{title:"Pause Speech",onClick:e=>M(!0),children:(0,n.jsx)(X.d,{alt:"Pause Message",className:"hsl(var(--muted-foreground))"})}):(0,n.jsx)("button",{title:"Speak",onClick:e=>T(),children:(0,n.jsx)(ee.j,{alt:"Speak Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})})),e.chatMessage.turnId&&(0,n.jsx)("button",{title:"Delete",className:"".concat(c().deleteButton),onClick:()=>S(e.chatMessage),children:(0,n.jsx)(et.r,{alt:"Delete Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})}),(0,n.jsx)("button",{title:"Copy",className:"".concat(c().copyButton),onClick:()=>{navigator.clipboard.writeText(v),g(!0)},children:m?(0,n.jsx)(ea.C,{alt:"Copied Message",weight:"fill",className:"text-green-500"}):(0,n.jsx)(ea.C,{alt:"Copy Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),"khoj"===e.chatMessage.by&&(e.chatMessage.intent?(0,n.jsx)(em,{uquery:e.chatMessage.intent.query,kquery:e.chatMessage.message}):(0,n.jsx)(em,{uquery:e.chatMessage.rawQuery||e.chatMessage.message,kquery:e.chatMessage.message}))]})]})})]})});ef.displayName="ChatMessage";var ep=a(84511),ex=a(16288),ev=a(20721),ej=a(19666),ew=a(50495),eb=e=>{let{name:t,avatar:a,link:s,description:o}=e;return(0,n.jsx)("div",{className:"relative group flex",children:(0,n.jsx)(ej.pn,{children:(0,n.jsxs)(ej.u,{delayDuration:0,children:[(0,n.jsx)(ej.aJ,{asChild:!0,children:(0,n.jsxs)(ew.z,{variant:"ghost",className:"flex items-center justify-center",children:[a,(0,n.jsx)("div",{children:t})]})}),(0,n.jsx)(ej._v,{children:(0,n.jsxs)("div",{className:"w-80 h-30",children:[(0,n.jsx)("a",{href:s,target:"_blank",rel:"noreferrer",className:"mt-1 ml-2 block no-underline",children:(0,n.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[a,(0,n.jsxs)("div",{className:"mr-2 mt-1 flex justify-center items-center text-sm font-semibold text-gray-800",children:[t,(0,n.jsx)(g.o,{weight:"bold",className:"ml-1"})]})]})}),o&&(0,n.jsx)("p",{className:"mt-2 ml-6 text-sm text-gray-600 line-clamp-2",children:o||"A Khoj agent"})]})})]})})})};function ey(e){let t=e.trainOfThought.length-1,[a,s]=(0,l.useState)(e.completed);return(0,n.jsxs)("div",{className:"".concat(a?"":o().trainOfThought+" shadow-sm"),children:[!e.completed&&(0,n.jsx)(en.l,{className:"float-right"}),e.completed&&(a?(0,n.jsx)(ew.z,{className:"w-fit text-left justify-start content-start text-xs",onClick:()=>s(!1),variant:"ghost",size:"sm",children:"What was my train of thought?"}):(0,n.jsxs)(ew.z,{className:"w-fit text-left justify-start content-start text-xs p-0 h-fit",onClick:()=>s(!0),variant:"ghost",size:"sm",children:[(0,n.jsx)(ep.a,{size:16,className:"mr-1"}),"Close"]})),!a&&e.trainOfThought.map((a,s)=>(0,n.jsx)(eg,{message:a,primary:s===t&&e.lastMessage&&!e.completed,agentColor:e.agentColor},"train-".concat(s)))]},e.keyId)}function eC(e){var t,a,s,r,c,i,d,u,h;let[m,g]=(0,l.useState)(null),[f,p]=(0,l.useState)(0),[x,v]=(0,l.useState)(!0),[j,w]=(0,l.useState)(null),b=(0,l.useRef)(null),y=(0,l.useRef)(null),C=(0,l.useRef)(null),N=(0,l.useRef)(null),[M,k]=(0,l.useState)(null),[_,R]=(0,l.useState)(!1),[I,T]=(0,l.useState)(!0),E=(0,ei.IC)(),D="[data-radix-scroll-area-viewport]";(0,l.useEffect)(()=>{var e;let t=null===(e=y.current)||void 0===e?void 0:e.querySelector(D);if(!t)return;let a=()=>{let{scrollTop:e,scrollHeight:a,clientHeight:n}=t;T(a-(e+n)<=50)};return t.addEventListener("scroll",a),()=>t.removeEventListener("scroll",a)},[]),(0,l.useEffect)(()=>{e.incomingMessages&&e.incomingMessages.length>0&&I&&L()},[e.incomingMessages,I]),(0,l.useEffect)(()=>{m&&m.chat&&m.chat.length>0&&f<2&&requestAnimationFrame(()=>{var e;null===(e=C.current)||void 0===e||e.scrollIntoView({behavior:"auto",block:"start"})})},[m,f]),(0,l.useEffect)(()=>{if(!x||_)return;let t=new IntersectionObserver(t=>{t[0].isIntersecting&&x&&(R(!0),function(t){if(!x||_)return;let a=(t+1)*10,n="";if(e.conversationId)n="/api/chat/history?client=web&conversation_id=".concat(encodeURIComponent(e.conversationId),"&n=").concat(a);else{if(!e.publicConversationSlug)return;n="/api/chat/share/history?client=web&public_conversation_slug=".concat(e.publicConversationSlug,"&n=").concat(a)}fetch(n).then(e=>e.json()).then(a=>{if(e.setTitle(a.response.slug),a&&a.response&&a.response.chat&&a.response.chat.length>0){if(p(Math.ceil(a.response.chat.length/10)),a.response.chat.length===(null==m?void 0:m.chat.length)){v(!1),R(!1);return}e.setAgent(a.response.agent),g(a.response),R(!1),0===t?L(!0):S()}else{if(a.response.agent&&a.response.conversation_id){let t={chat:[],agent:a.response.agent,conversation_id:a.response.conversation_id,slug:a.response.slug};e.setAgent(a.response.agent),g(t)}v(!1),R(!1)}}).catch(e=>{console.error(e),window.location.href="/"})}(f))},{threshold:1});return b.current&&t.observe(b.current),()=>t.disconnect()},[x,f,_]),(0,l.useEffect)(()=>{v(!0),R(!1),p(0),g(null)},[e.conversationId]),(0,l.useEffect)(()=>{if(e.incomingMessages){let t=e.incomingMessages[e.incomingMessages.length-1];t&&!t.completed&&(k(e.incomingMessages.length-1),e.setTitle(t.rawQuery),t.turnId&&w(t.turnId))}},[e.incomingMessages]);let S=()=>{var e;let t=null===(e=y.current)||void 0===e?void 0:e.querySelector(D);requestAnimationFrame(()=>{var e;null===(e=N.current)||void 0===e||e.scrollIntoView({behavior:"auto",block:"start"}),null==t||t.scrollBy({behavior:"smooth",top:-150})})},L=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=null===(e=y.current)||void 0===e?void 0:e.querySelector(D);requestAnimationFrame(()=>{null==a||a.scrollTo({top:a.scrollHeight,behavior:t?"auto":"smooth"})}),T(!0)},O=t=>{t&&(g(e=>e&&t?{...e,chat:e.chat.filter(e=>e.turnId!==t)}:e),e.incomingMessages&&e.setIncomingMessages&&e.setIncomingMessages(e.incomingMessages.filter(e=>e.turnId!==t)))};return e.conversationId||e.publicConversationSlug?(0,n.jsx)(ed.x,{className:"h-[73vh] relative",ref:y,children:(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"".concat(o().chatHistory," ").concat(e.customClassName),children:[(0,n.jsx)("div",{ref:b,style:{height:"1px"},children:_&&(0,n.jsx)(en.l,{className:"opacity-50"})}),m&&m.chat&&m.chat.map((t,a)=>{var s,o,l;return(0,n.jsxs)(n.Fragment,{children:[t.trainOfThought&&"khoj"===t.by&&(0,n.jsx)(ey,{trainOfThought:null===(s=t.trainOfThought)||void 0===s?void 0:s.map(e=>e.data),lastMessage:!1,agentColor:(null==m?void 0:null===(o=m.agent)||void 0===o?void 0:o.color)||"orange",keyId:"".concat(a,"trainOfThought"),completed:!0},"".concat(a,"trainOfThought")),(0,n.jsx)(ef,{ref:a===m.chat.length-2?C:a===m.chat.length-(f-1)*10?N:null,isMobileWidth:E,chatMessage:t,customClassName:"fullHistory",borderLeftColor:"".concat(null==m?void 0:null===(l=m.agent)||void 0===l?void 0:l.color,"-500"),isLastMessage:a===m.chat.length-1,onDeleteMessage:O,conversationId:e.conversationId},"".concat(a,"fullHistory"))]})}),e.incomingMessages&&e.incomingMessages.map((t,a)=>{var s,o,r,c,i;let d=null!==(i=null!==(c=t.turnId)&&void 0!==c?c:j)&&void 0!==i?i:void 0;return(0,n.jsxs)(l.Fragment,{children:[(0,n.jsx)(ef,{isMobileWidth:E,chatMessage:{message:t.rawQuery,context:[],onlineContext:{},codeContext:{},created:t.timestamp,by:"you",automationId:"",images:t.images,conversationId:e.conversationId,turnId:d,queryFiles:t.queryFiles},customClassName:"fullHistory",borderLeftColor:"".concat(null==m?void 0:null===(s=m.agent)||void 0===s?void 0:s.color,"-500"),onDeleteMessage:O,conversationId:e.conversationId,turnId:d},"".concat(a,"outgoing")),t.trainOfThought&&(0,n.jsx)(ey,{trainOfThought:t.trainOfThought,lastMessage:a===M,agentColor:(null==m?void 0:null===(o=m.agent)||void 0===o?void 0:o.color)||"orange",keyId:"".concat(a,"trainOfThought"),completed:t.completed},"".concat(a,"trainOfThought")),(0,n.jsx)(ef,{isMobileWidth:E,chatMessage:{message:t.rawResponse,context:t.context,onlineContext:t.onlineContext,codeContext:t.codeContext,created:t.timestamp,by:"khoj",automationId:"",rawQuery:t.rawQuery,intent:{type:t.intentType||"",query:t.rawQuery,"memory-type":"","inferred-queries":t.inferredQueries||[]},conversationId:e.conversationId,turnId:d},conversationId:e.conversationId,turnId:d,onDeleteMessage:O,customClassName:"fullHistory",borderLeftColor:"".concat(null==m?void 0:null===(r=m.agent)||void 0===r?void 0:r.color,"-500"),isLastMessage:!0},"".concat(a,"incoming"))]},"incomingMessage".concat(a))}),e.pendingMessage&&(0,n.jsx)(ef,{isMobileWidth:E,chatMessage:{message:e.pendingMessage,context:[],onlineContext:{},codeContext:{},created:new Date().getTime().toString(),by:"you",automationId:"",conversationId:e.conversationId,turnId:void 0},conversationId:e.conversationId,onDeleteMessage:O,customClassName:"fullHistory",borderLeftColor:"".concat(null==m?void 0:null===(t=m.agent)||void 0===t?void 0:t.color,"-500"),isLastMessage:!0},"pendingMessage-".concat(e.pendingMessage.length)),m&&(0,n.jsx)("div",{className:"".concat(o().agentIndicator," pb-4"),children:(0,n.jsx)("div",{className:"relative group mx-2 cursor-pointer",children:(0,n.jsx)(eb,{name:m&&m.agent&&(null===(r=m.agent)||void 0===r?void 0:r.name)?null===(c=m.agent)||void 0===c?void 0:c.name:"Agent",link:m&&m.agent&&(null===(i=m.agent)||void 0===i?void 0:i.slug)?"/agents?agent=".concat(null===(d=m.agent)||void 0===d?void 0:d.slug):"/agents",avatar:(0,F.TI)(null===(a=m.agent)||void 0===a?void 0:a.icon,null===(s=m.agent)||void 0===s?void 0:s.color)||(0,n.jsx)(ex.v,{}),description:m&&m.agent&&(null===(u=m.agent)||void 0===u?void 0:u.persona)?null===(h=m.agent)||void 0===h?void 0:h.persona:"Your agent is no longer available. You will be reset to the default agent."})})})]}),(0,n.jsx)("div",{className:"".concat(e.customClassName," fixed bottom-[20%] z-10"),children:!I&&(0,n.jsx)("button",{title:"Scroll to bottom",className:"absolute bottom-0 right-0 bg-white dark:bg-[hsl(var(--background))] text-neutral-500 dark:text-white p-2 rounded-full shadow-xl",onClick:()=>{L(),T(!0)},children:(0,n.jsx)(ev.K,{size:24})})})]})}):null}},15238:function(e){e.exports={chatHistory:"chatHistory_chatHistory__CoaVT",agentIndicator:"chatHistory_agentIndicator__wOU1f",trainOfThought:"chatHistory_trainOfThought__mMWSR"}},34531:function(e){e.exports={chatMessageContainer:"chatMessage_chatMessageContainer__sAivf",chatMessageWrapper:"chatMessage_chatMessageWrapper__u5m8A",khojfullHistory:"chatMessage_khojfullHistory__NPu2l",youfullHistory:"chatMessage_youfullHistory__ioyfH",you:"chatMessage_you__6GUC4",khoj:"chatMessage_khoj__cjWON",khojChatMessage:"chatMessage_khojChatMessage__BabQz",emptyChatMessage:"chatMessage_emptyChatMessage__J9JRn",imagesContainer:"chatMessage_imagesContainer__HTRjT",imageWrapper:"chatMessage_imageWrapper__DF92M",author:"chatMessage_author__muRtC",chatFooter:"chatMessage_chatFooter__0vR8s",chatButtons:"chatMessage_chatButtons__Lbk8T",codeCopyButton:"chatMessage_codeCopyButton__Y_Ujv",feedbackButtons:"chatMessage_feedbackButtons___Brdy",copyButton:"chatMessage_copyButton__jd7q7",trainOfThought:"chatMessage_trainOfThought__mR2Gg",primary:"chatMessage_primary__WYPEb",trainOfThoughtElement:"chatMessage_trainOfThoughtElement__le_bC"}}}]);