khoj 1.16.1.dev15__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 (242) hide show
  1. khoj/__init__.py +0 -0
  2. khoj/app/README.md +94 -0
  3. khoj/app/__init__.py +0 -0
  4. khoj/app/asgi.py +16 -0
  5. khoj/app/settings.py +192 -0
  6. khoj/app/urls.py +25 -0
  7. khoj/configure.py +424 -0
  8. khoj/database/__init__.py +0 -0
  9. khoj/database/adapters/__init__.py +1234 -0
  10. khoj/database/admin.py +290 -0
  11. khoj/database/apps.py +6 -0
  12. khoj/database/management/__init__.py +0 -0
  13. khoj/database/management/commands/__init__.py +0 -0
  14. khoj/database/management/commands/change_generated_images_url.py +61 -0
  15. khoj/database/management/commands/convert_images_png_to_webp.py +99 -0
  16. khoj/database/migrations/0001_khojuser.py +98 -0
  17. khoj/database/migrations/0002_googleuser.py +32 -0
  18. khoj/database/migrations/0003_vector_extension.py +10 -0
  19. khoj/database/migrations/0004_content_types_and_more.py +181 -0
  20. khoj/database/migrations/0005_embeddings_corpus_id.py +19 -0
  21. khoj/database/migrations/0006_embeddingsdates.py +33 -0
  22. khoj/database/migrations/0007_add_conversation.py +27 -0
  23. khoj/database/migrations/0008_alter_conversation_conversation_log.py +17 -0
  24. khoj/database/migrations/0009_khojapiuser.py +24 -0
  25. khoj/database/migrations/0010_chatmodeloptions_and_more.py +83 -0
  26. khoj/database/migrations/0010_rename_embeddings_entry_and_more.py +30 -0
  27. khoj/database/migrations/0011_merge_20231102_0138.py +14 -0
  28. khoj/database/migrations/0012_entry_file_source.py +21 -0
  29. khoj/database/migrations/0013_subscription.py +37 -0
  30. khoj/database/migrations/0014_alter_googleuser_picture.py +17 -0
  31. khoj/database/migrations/0015_alter_subscription_user.py +21 -0
  32. khoj/database/migrations/0016_alter_subscription_renewal_date.py +17 -0
  33. khoj/database/migrations/0017_searchmodel.py +32 -0
  34. khoj/database/migrations/0018_searchmodelconfig_delete_searchmodel.py +30 -0
  35. khoj/database/migrations/0019_alter_googleuser_family_name_and_more.py +27 -0
  36. khoj/database/migrations/0020_reflectivequestion.py +36 -0
  37. khoj/database/migrations/0021_speechtotextmodeloptions_and_more.py +42 -0
  38. khoj/database/migrations/0022_texttoimagemodelconfig.py +25 -0
  39. khoj/database/migrations/0023_usersearchmodelconfig.py +33 -0
  40. khoj/database/migrations/0024_alter_entry_embeddings.py +18 -0
  41. khoj/database/migrations/0025_clientapplication_khojuser_phone_number_and_more.py +46 -0
  42. khoj/database/migrations/0025_searchmodelconfig_embeddings_inference_endpoint_and_more.py +22 -0
  43. khoj/database/migrations/0026_searchmodelconfig_cross_encoder_inference_endpoint_and_more.py +22 -0
  44. khoj/database/migrations/0027_merge_20240118_1324.py +13 -0
  45. khoj/database/migrations/0028_khojuser_verified_phone_number.py +17 -0
  46. khoj/database/migrations/0029_userrequests.py +27 -0
  47. khoj/database/migrations/0030_conversation_slug_and_title.py +38 -0
  48. khoj/database/migrations/0031_agent_conversation_agent.py +53 -0
  49. khoj/database/migrations/0031_alter_googleuser_locale.py +30 -0
  50. khoj/database/migrations/0032_merge_20240322_0427.py +14 -0
  51. khoj/database/migrations/0033_rename_tuning_agent_personality.py +17 -0
  52. khoj/database/migrations/0034_alter_chatmodeloptions_chat_model.py +32 -0
  53. khoj/database/migrations/0035_processlock.py +26 -0
  54. khoj/database/migrations/0036_alter_processlock_name.py +19 -0
  55. khoj/database/migrations/0036_delete_offlinechatprocessorconversationconfig.py +15 -0
  56. khoj/database/migrations/0036_publicconversation.py +42 -0
  57. khoj/database/migrations/0037_chatmodeloptions_openai_config_and_more.py +51 -0
  58. khoj/database/migrations/0037_searchmodelconfig_bi_encoder_docs_encode_config_and_more.py +32 -0
  59. khoj/database/migrations/0038_merge_20240425_0857.py +14 -0
  60. khoj/database/migrations/0038_merge_20240426_1640.py +12 -0
  61. khoj/database/migrations/0039_merge_20240501_0301.py +12 -0
  62. khoj/database/migrations/0040_alter_processlock_name.py +26 -0
  63. khoj/database/migrations/0040_merge_20240504_1010.py +14 -0
  64. khoj/database/migrations/0041_merge_20240505_1234.py +14 -0
  65. khoj/database/migrations/0042_serverchatsettings.py +46 -0
  66. khoj/database/migrations/0043_alter_chatmodeloptions_model_type.py +21 -0
  67. khoj/database/migrations/0044_conversation_file_filters.py +17 -0
  68. khoj/database/migrations/0045_fileobject.py +37 -0
  69. khoj/database/migrations/0046_khojuser_email_verification_code_and_more.py +22 -0
  70. khoj/database/migrations/0047_alter_entry_file_type.py +31 -0
  71. khoj/database/migrations/0048_voicemodeloption_uservoicemodelconfig.py +52 -0
  72. khoj/database/migrations/0049_datastore.py +38 -0
  73. khoj/database/migrations/0049_texttoimagemodelconfig_api_key_and_more.py +58 -0
  74. khoj/database/migrations/0050_alter_processlock_name.py +25 -0
  75. khoj/database/migrations/0051_merge_20240702_1220.py +14 -0
  76. khoj/database/migrations/0052_alter_searchmodelconfig_bi_encoder_docs_encode_config_and_more.py +27 -0
  77. khoj/database/migrations/__init__.py +0 -0
  78. khoj/database/models/__init__.py +402 -0
  79. khoj/database/tests.py +3 -0
  80. khoj/interface/email/feedback.html +34 -0
  81. khoj/interface/email/magic_link.html +17 -0
  82. khoj/interface/email/task.html +40 -0
  83. khoj/interface/email/welcome.html +61 -0
  84. khoj/interface/web/404.html +56 -0
  85. khoj/interface/web/agent.html +312 -0
  86. khoj/interface/web/agents.html +276 -0
  87. khoj/interface/web/assets/icons/agents.svg +6 -0
  88. khoj/interface/web/assets/icons/automation.svg +37 -0
  89. khoj/interface/web/assets/icons/cancel.svg +3 -0
  90. khoj/interface/web/assets/icons/chat.svg +24 -0
  91. khoj/interface/web/assets/icons/collapse.svg +17 -0
  92. khoj/interface/web/assets/icons/computer.png +0 -0
  93. khoj/interface/web/assets/icons/confirm-icon.svg +1 -0
  94. khoj/interface/web/assets/icons/copy-button-success.svg +6 -0
  95. khoj/interface/web/assets/icons/copy-button.svg +5 -0
  96. khoj/interface/web/assets/icons/credit-card.png +0 -0
  97. khoj/interface/web/assets/icons/delete.svg +26 -0
  98. khoj/interface/web/assets/icons/docx.svg +7 -0
  99. khoj/interface/web/assets/icons/edit.svg +4 -0
  100. khoj/interface/web/assets/icons/favicon-128x128.ico +0 -0
  101. khoj/interface/web/assets/icons/favicon-128x128.png +0 -0
  102. khoj/interface/web/assets/icons/favicon-256x256.png +0 -0
  103. khoj/interface/web/assets/icons/favicon.icns +0 -0
  104. khoj/interface/web/assets/icons/github.svg +1 -0
  105. khoj/interface/web/assets/icons/key.svg +4 -0
  106. khoj/interface/web/assets/icons/khoj-logo-sideways-200.png +0 -0
  107. khoj/interface/web/assets/icons/khoj-logo-sideways-500.png +0 -0
  108. khoj/interface/web/assets/icons/khoj-logo-sideways.svg +5385 -0
  109. khoj/interface/web/assets/icons/logotype.svg +1 -0
  110. khoj/interface/web/assets/icons/markdown.svg +1 -0
  111. khoj/interface/web/assets/icons/new.svg +23 -0
  112. khoj/interface/web/assets/icons/notion.svg +4 -0
  113. khoj/interface/web/assets/icons/openai-logomark.svg +1 -0
  114. khoj/interface/web/assets/icons/org.svg +1 -0
  115. khoj/interface/web/assets/icons/pdf.svg +23 -0
  116. khoj/interface/web/assets/icons/pencil-edit.svg +5 -0
  117. khoj/interface/web/assets/icons/plaintext.svg +1 -0
  118. khoj/interface/web/assets/icons/question-mark-icon.svg +1 -0
  119. khoj/interface/web/assets/icons/search.svg +25 -0
  120. khoj/interface/web/assets/icons/send.svg +1 -0
  121. khoj/interface/web/assets/icons/share.svg +8 -0
  122. khoj/interface/web/assets/icons/speaker.svg +4 -0
  123. khoj/interface/web/assets/icons/stop-solid.svg +37 -0
  124. khoj/interface/web/assets/icons/sync.svg +4 -0
  125. khoj/interface/web/assets/icons/thumbs-down-svgrepo-com.svg +6 -0
  126. khoj/interface/web/assets/icons/thumbs-up-svgrepo-com.svg +6 -0
  127. khoj/interface/web/assets/icons/user-silhouette.svg +4 -0
  128. khoj/interface/web/assets/icons/voice.svg +8 -0
  129. khoj/interface/web/assets/icons/web.svg +2 -0
  130. khoj/interface/web/assets/icons/whatsapp.svg +17 -0
  131. khoj/interface/web/assets/khoj.css +237 -0
  132. khoj/interface/web/assets/markdown-it.min.js +8476 -0
  133. khoj/interface/web/assets/natural-cron.min.js +1 -0
  134. khoj/interface/web/assets/org.min.js +1823 -0
  135. khoj/interface/web/assets/pico.min.css +5 -0
  136. khoj/interface/web/assets/purify.min.js +3 -0
  137. khoj/interface/web/assets/samples/desktop-browse-draw-sample.png +0 -0
  138. khoj/interface/web/assets/samples/desktop-plain-chat-sample.png +0 -0
  139. khoj/interface/web/assets/samples/desktop-remember-plan-sample.png +0 -0
  140. khoj/interface/web/assets/samples/phone-browse-draw-sample.png +0 -0
  141. khoj/interface/web/assets/samples/phone-plain-chat-sample.png +0 -0
  142. khoj/interface/web/assets/samples/phone-remember-plan-sample.png +0 -0
  143. khoj/interface/web/assets/utils.js +33 -0
  144. khoj/interface/web/base_config.html +445 -0
  145. khoj/interface/web/chat.html +3546 -0
  146. khoj/interface/web/config.html +1011 -0
  147. khoj/interface/web/config_automation.html +1103 -0
  148. khoj/interface/web/content_source_computer_input.html +139 -0
  149. khoj/interface/web/content_source_github_input.html +216 -0
  150. khoj/interface/web/content_source_notion_input.html +94 -0
  151. khoj/interface/web/khoj.webmanifest +51 -0
  152. khoj/interface/web/login.html +219 -0
  153. khoj/interface/web/public_conversation.html +2006 -0
  154. khoj/interface/web/search.html +470 -0
  155. khoj/interface/web/utils.html +48 -0
  156. khoj/main.py +241 -0
  157. khoj/manage.py +22 -0
  158. khoj/migrations/__init__.py +0 -0
  159. khoj/migrations/migrate_offline_chat_default_model.py +69 -0
  160. khoj/migrations/migrate_offline_chat_default_model_2.py +71 -0
  161. khoj/migrations/migrate_offline_chat_schema.py +83 -0
  162. khoj/migrations/migrate_offline_model.py +29 -0
  163. khoj/migrations/migrate_processor_config_openai.py +67 -0
  164. khoj/migrations/migrate_server_pg.py +138 -0
  165. khoj/migrations/migrate_version.py +17 -0
  166. khoj/processor/__init__.py +0 -0
  167. khoj/processor/content/__init__.py +0 -0
  168. khoj/processor/content/docx/__init__.py +0 -0
  169. khoj/processor/content/docx/docx_to_entries.py +110 -0
  170. khoj/processor/content/github/__init__.py +0 -0
  171. khoj/processor/content/github/github_to_entries.py +224 -0
  172. khoj/processor/content/images/__init__.py +0 -0
  173. khoj/processor/content/images/image_to_entries.py +118 -0
  174. khoj/processor/content/markdown/__init__.py +0 -0
  175. khoj/processor/content/markdown/markdown_to_entries.py +165 -0
  176. khoj/processor/content/notion/notion_to_entries.py +260 -0
  177. khoj/processor/content/org_mode/__init__.py +0 -0
  178. khoj/processor/content/org_mode/org_to_entries.py +231 -0
  179. khoj/processor/content/org_mode/orgnode.py +532 -0
  180. khoj/processor/content/pdf/__init__.py +0 -0
  181. khoj/processor/content/pdf/pdf_to_entries.py +116 -0
  182. khoj/processor/content/plaintext/__init__.py +0 -0
  183. khoj/processor/content/plaintext/plaintext_to_entries.py +122 -0
  184. khoj/processor/content/text_to_entries.py +297 -0
  185. khoj/processor/conversation/__init__.py +0 -0
  186. khoj/processor/conversation/anthropic/__init__.py +0 -0
  187. khoj/processor/conversation/anthropic/anthropic_chat.py +206 -0
  188. khoj/processor/conversation/anthropic/utils.py +114 -0
  189. khoj/processor/conversation/offline/__init__.py +0 -0
  190. khoj/processor/conversation/offline/chat_model.py +231 -0
  191. khoj/processor/conversation/offline/utils.py +78 -0
  192. khoj/processor/conversation/offline/whisper.py +15 -0
  193. khoj/processor/conversation/openai/__init__.py +0 -0
  194. khoj/processor/conversation/openai/gpt.py +187 -0
  195. khoj/processor/conversation/openai/utils.py +129 -0
  196. khoj/processor/conversation/openai/whisper.py +13 -0
  197. khoj/processor/conversation/prompts.py +758 -0
  198. khoj/processor/conversation/utils.py +262 -0
  199. khoj/processor/embeddings.py +117 -0
  200. khoj/processor/speech/__init__.py +0 -0
  201. khoj/processor/speech/text_to_speech.py +51 -0
  202. khoj/processor/tools/__init__.py +0 -0
  203. khoj/processor/tools/online_search.py +225 -0
  204. khoj/routers/__init__.py +0 -0
  205. khoj/routers/api.py +626 -0
  206. khoj/routers/api_agents.py +43 -0
  207. khoj/routers/api_chat.py +1180 -0
  208. khoj/routers/api_config.py +434 -0
  209. khoj/routers/api_phone.py +86 -0
  210. khoj/routers/auth.py +181 -0
  211. khoj/routers/email.py +133 -0
  212. khoj/routers/helpers.py +1188 -0
  213. khoj/routers/indexer.py +349 -0
  214. khoj/routers/notion.py +91 -0
  215. khoj/routers/storage.py +35 -0
  216. khoj/routers/subscription.py +104 -0
  217. khoj/routers/twilio.py +36 -0
  218. khoj/routers/web_client.py +471 -0
  219. khoj/search_filter/__init__.py +0 -0
  220. khoj/search_filter/base_filter.py +15 -0
  221. khoj/search_filter/date_filter.py +217 -0
  222. khoj/search_filter/file_filter.py +30 -0
  223. khoj/search_filter/word_filter.py +29 -0
  224. khoj/search_type/__init__.py +0 -0
  225. khoj/search_type/text_search.py +241 -0
  226. khoj/utils/__init__.py +0 -0
  227. khoj/utils/cli.py +93 -0
  228. khoj/utils/config.py +81 -0
  229. khoj/utils/constants.py +24 -0
  230. khoj/utils/fs_syncer.py +249 -0
  231. khoj/utils/helpers.py +418 -0
  232. khoj/utils/initialization.py +146 -0
  233. khoj/utils/jsonl.py +43 -0
  234. khoj/utils/models.py +47 -0
  235. khoj/utils/rawconfig.py +160 -0
  236. khoj/utils/state.py +46 -0
  237. khoj/utils/yaml.py +43 -0
  238. khoj-1.16.1.dev15.dist-info/METADATA +178 -0
  239. khoj-1.16.1.dev15.dist-info/RECORD +242 -0
  240. khoj-1.16.1.dev15.dist-info/WHEEL +4 -0
  241. khoj-1.16.1.dev15.dist-info/entry_points.txt +2 -0
  242. khoj-1.16.1.dev15.dist-info/licenses/LICENSE +661 -0
@@ -0,0 +1,139 @@
1
+ {% extends "base_config.html" %}
2
+ {% block content %}
3
+ <div class="page">
4
+ <div class="section">
5
+ <h2 class="section-title">
6
+ <img class="card-icon" src="/static/assets/icons/computer.png?v={{ khoj_version }}" alt="files">
7
+ <span class="card-title-text">Files</span>
8
+ <div class="instructions">
9
+ <p class="card-description">Manage files from your computer</p>
10
+ <p id="get-desktop-client" class="card-description">Get the Khoj <a href="https://khoj.dev/downloads">Desktop</a>, <a href="https://docs.khoj.dev/#/obsidian?id=setup">Obsidian</a> or <a href="https://docs.khoj.dev/#/emacs?id=setup">Emacs</a> app to sync documents from your computer</p>
11
+ </div>
12
+ </h2>
13
+ <div class="section-manage-files">
14
+ <div id="delete-all-files" class="delete-all-files">
15
+ <button id="delete-all-files-button" type="submit" title="Remove all computer files from Khoj">🗑️ Delete all</button>
16
+ </div>
17
+ <div class="indexed-files">
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ <style>
23
+ #desktop-client {
24
+ font-weight: normal;
25
+ }
26
+ .indexed-files {
27
+ width: 100%;
28
+ }
29
+ .content-name {
30
+ font-size: smaller;
31
+ }
32
+ </style>
33
+ <script>
34
+ function removeFile(path) {
35
+ fetch('/api/config/data/file?filename=' + path, {
36
+ method: 'DELETE',
37
+ headers: {
38
+ 'Content-Type': 'application/json',
39
+ }
40
+ })
41
+ .then(response => response.ok ? response.json() : Promise.reject(response))
42
+ .then(data => {
43
+ if (data.status == "ok") {
44
+ getAllComputerFilenames();
45
+ }
46
+ })
47
+ }
48
+
49
+ // Get all currently indexed files
50
+ function getAllComputerFilenames() {
51
+ fetch('/api/config/data/computer')
52
+ .then(response => response.json())
53
+ .then(data => {
54
+ var indexedFiles = document.getElementsByClassName("indexed-files")[0];
55
+ indexedFiles.innerHTML = "";
56
+
57
+ if (data.length == 0) {
58
+ document.getElementById("delete-all-files").style.display = "none";
59
+ let noFilesElement = document.createElement("div");
60
+ noFilesElement.classList.add("card-description");
61
+ noFilesElement.textContent = "No documents synced with Khoj";
62
+ indexedFiles.appendChild(noFilesElement);
63
+ } else {
64
+ document.getElementById("get-desktop-client").style.display = "none";
65
+ document.getElementById("delete-all-files").style.display = "block";
66
+ }
67
+
68
+ for (var filename of data) {
69
+ let fileElement = document.createElement("div");
70
+ fileElement.classList.add("file-element");
71
+
72
+ let fileExtension = filename.split('.').pop();
73
+ if (fileExtension === "org")
74
+ image_name = "org.svg"
75
+ else if (fileExtension === "pdf")
76
+ image_name = "pdf.svg"
77
+ else if (fileExtension === "markdown" || fileExtension === "md")
78
+ image_name = "markdown.svg"
79
+ else if (fileExtension === "docx")
80
+ image_name = "docx.svg"
81
+ else
82
+ image_name = "plaintext.svg"
83
+
84
+ let fileIconElement = document.createElement("img");
85
+ fileIconElement.classList.add("card-icon");
86
+ fileIconElement.src = `/static/assets/icons/${image_name}`;
87
+ fileIconElement.alt = "File";
88
+ fileElement.appendChild(fileIconElement);
89
+
90
+ let fileNameElement = document.createElement("div");
91
+ fileNameElement.classList.add("content-name");
92
+ fileNameElement.textContent = filename;
93
+ fileElement.appendChild(fileNameElement);
94
+
95
+ let buttonContainer = document.createElement("div");
96
+ buttonContainer.classList.add("remove-button-container");
97
+ let removeFileButton = document.createElement("button");
98
+ removeFileButton.classList.add("remove-file-button");
99
+ removeFileButton.textContent = "🗑️";
100
+ removeFileButton.addEventListener("click", ((filename) => {
101
+ return () => {
102
+ removeFile(filename);
103
+ };
104
+ })(filename));
105
+ buttonContainer.appendChild(removeFileButton);
106
+ fileElement.appendChild(buttonContainer);
107
+ indexedFiles.appendChild(fileElement);
108
+ }
109
+ })
110
+ .catch((error) => {
111
+ console.error('Error:', error);
112
+ });
113
+ }
114
+
115
+ // Get all currently indexed files on page load
116
+ getAllComputerFilenames();
117
+
118
+ let deleteAllComputerFilesButton = document.getElementById("delete-all-files-button");
119
+ deleteAllComputerFilesButton.addEventListener("click", function(event) {
120
+ event.preventDefault();
121
+ originalDeleteAllComputerFilesButtonText = deleteAllComputerFilesButton.textContent;
122
+ deleteAllComputerFilesButton.textContent = "🗑️ Deleting...";
123
+ deleteAllComputerFilesButton.disabled = true;
124
+
125
+ fetch('/api/config/data/content-source/computer', {
126
+ method: 'DELETE',
127
+ headers: {
128
+ 'Content-Type': 'application/json',
129
+ }
130
+ })
131
+ .then(response => response.json())
132
+ .finally(() => {
133
+ getAllComputerFilenames();
134
+ deleteAllComputerFilesButton.textContent = originalDeleteAllComputerFilesButtonText;
135
+ deleteAllComputerFilesButton.disabled = false;
136
+ });
137
+ });
138
+ </script>
139
+ {% endblock %}
@@ -0,0 +1,216 @@
1
+ {% extends "base_config.html" %}
2
+ {% block content %}
3
+ <div class="page">
4
+ <div class="section">
5
+ <h2 class="section-title">
6
+ <img class="card-icon" src="/static/assets/icons/github.svg?v={{ khoj_version }}" alt="Github">
7
+ <span class="card-title-text">Github</span>
8
+ <div class="instructions">
9
+ <a href="https://docs.khoj.dev/data-sources/github_integration">ⓘ Help</a>
10
+ </div>
11
+ </h2>
12
+ <form>
13
+ <table>
14
+ <tr>
15
+ <td>
16
+ <label for="pat-token">Personal Access Token</label>
17
+ </td>
18
+ <td>
19
+ <input type="text" id="pat-token" name="pat" value="{{ current_config['pat_token'] }}">
20
+ </td>
21
+ </tr>
22
+ </table>
23
+ <h4>Repositories</h4>
24
+ <div id="repositories" class="section-cards">
25
+ {% for repo in current_config['repos'] %}
26
+ <div class="card repo" id="repo-card-{{loop.index}}">
27
+ <label for="repo-owner">Repository Owner</label>
28
+ <input type="text" id="repo-owner-{{loop.index}}" name="repo_owner" value="{{ repo.owner }}">
29
+ <label for="repo-name">Repository Name</label>
30
+ <input type="text" id="repo-name-{{loop.index}}" name="repo_name" value="{{ repo.name}}">
31
+ <label for="repo-branch">Repository Branch</label>
32
+ <input type="text" id="repo-branch-{{loop.index}}" name="repo_branch" value="{{ repo.branch }}">
33
+ <button type="button"
34
+ class="remove-repo-button"
35
+ onclick="remove_repo({{loop.index}})"
36
+ id="remove-repo-button-{{loop.index}}">Remove Repository</button>
37
+ </div>
38
+ {% endfor %}
39
+ </div>
40
+ <button type="button" id="add-repository-button">Add Repository</button>
41
+ <div class="section">
42
+ <div id="success" style="display: none;"></div>
43
+ <button id="submit" type="submit">Save</button>
44
+ </div>
45
+ </form>
46
+ </div>
47
+ </div>
48
+ <style>
49
+ td {
50
+ padding: 10px 0;
51
+ }
52
+ div.repo {
53
+ width: 100%;
54
+ height: 100%;
55
+ grid-template-rows: none;
56
+ }
57
+ div#repositories {
58
+ margin-bottom: 12px;
59
+ }
60
+ button.remove-repo-button {
61
+ background-color: gainsboro;
62
+ }
63
+ </style>
64
+ <script>
65
+ const add_repo_button = document.getElementById("add-repository-button");
66
+ add_repo_button.addEventListener("click", function(event) {
67
+ event.preventDefault();
68
+ var repo = document.createElement("div");
69
+ repo.classList.add("card");
70
+ repo.classList.add("repo");
71
+ const id = Date.now();
72
+ repo.id = "repo-card-" + id;
73
+
74
+ // Create repo owner, name, branch elements
75
+ let repoOwnerLabel = document.createElement("label");
76
+ repoOwnerLabel.textContent = "Repository Owner";
77
+ repoOwnerLabel.for = "repo-owner";
78
+
79
+ let repoOwner = document.createElement("input");
80
+ repoOwner.type = "text";
81
+ repoOwner.id = "repo-owner-" + id;
82
+ repoOwner.name = "repo_owner";
83
+
84
+ let repoNameLabel = document.createElement("label");
85
+ repoNameLabel.textContent = "Repository Name";
86
+ repoNameLabel.for = "repo-name";
87
+
88
+ let repoName = document.createElement("input");
89
+ repoName.type = "text";
90
+ repoName.id = "repo-name-" + id;
91
+ repoName.name = "repo_name";
92
+
93
+ let repoBranchLabel = document.createElement("label");
94
+ repoBranchLabel.textContent = "Repository Branch";
95
+ repoBranchLabel.for = "repo-branch";
96
+
97
+ let repoBranch = document.createElement("input");
98
+ repoBranch.type = "text";
99
+ repoBranch.id = "repo-branch-" + id;
100
+ repoBranch.name = "repo_branch";
101
+
102
+ let removeRepoButton = document.createElement("button");
103
+ removeRepoButton.type = "button";
104
+ removeRepoButton.classList.add("remove-repo-button");
105
+ removeRepoButton.onclick = function() { remove_repo(id); };
106
+ removeRepoButton.id = "remove-repo-button-" + id;
107
+ removeRepoButton.textContent = "Remove Repository";
108
+
109
+ // Append elements to repo card
110
+ repo.append(
111
+ repoOwnerLabel, repoOwner,
112
+ repoNameLabel, repoName,
113
+ repoBranchLabel, repoBranch,
114
+ removeRepoButton
115
+ );
116
+
117
+ document.getElementById("repositories").appendChild(repo);
118
+ })
119
+
120
+ function remove_repo(index) {
121
+ document.getElementById("repo-card-" + index).remove();
122
+ }
123
+
124
+ submit.addEventListener("click", function(event) {
125
+ event.preventDefault();
126
+
127
+ const pat_token = document.getElementById("pat-token").value;
128
+
129
+ if (pat_token == "") {
130
+ document.getElementById("success").textContent = "❌ Please enter a Personal Access Token.";
131
+ document.getElementById("success").style.display = "block";
132
+ return;
133
+ }
134
+
135
+
136
+ var cards = document.getElementById("repositories").getElementsByClassName("repo");
137
+ var repos = [];
138
+
139
+ for (var i = 0; i < cards.length; i++) {
140
+ var card = cards[i];
141
+ var owner = card.getElementsByTagName("input")[0].value;
142
+ var name = card.getElementsByTagName("input")[1].value;
143
+ var branch = card.getElementsByTagName("input")[2].value;
144
+
145
+ if (owner == "" || name == "" || branch == "") {
146
+ continue;
147
+ }
148
+
149
+ repos.push({
150
+ "owner": owner,
151
+ "name": name,
152
+ "branch": branch,
153
+ });
154
+ }
155
+
156
+ if (repos.length == 0) {
157
+ document.getElementById("success").textContent = "❌ Please add at least one repository.";
158
+ document.getElementById("success").style.display = "block";
159
+ return;
160
+ }
161
+
162
+ const submitButton = document.getElementById("submit");
163
+ submitButton.disabled = true;
164
+ submitButton.textContent = "Saving...";
165
+
166
+ // Save Github config on server
167
+ const csrfToken = document.cookie.split('; ').find(row => row.startsWith('csrftoken'))?.split('=')[1];
168
+ fetch('/api/config/data/content-source/github', {
169
+ method: 'POST',
170
+ headers: {
171
+ 'Content-Type': 'application/json',
172
+ 'X-CSRFToken': csrfToken,
173
+ },
174
+ body: JSON.stringify({
175
+ "pat_token": pat_token,
176
+ "repos": repos,
177
+ })
178
+ })
179
+ .then(response => response.json())
180
+ .then(data => { data["status"] === "ok" ? data : Promise.reject(data) })
181
+ .catch(error => {
182
+ document.getElementById("success").textContent = "⚠️ Failed to save Github settings.";
183
+ document.getElementById("success").style.display = "block";
184
+ submitButton.textContent = "⚠️ Failed to save settings";
185
+ setTimeout(function() {
186
+ submitButton.textContent = "Save";
187
+ submitButton.disabled = false;
188
+ }, 2000);
189
+ return;
190
+ });
191
+
192
+ // Index Github content on server
193
+ fetch('/api/update?t=github')
194
+ .then(response => response.json())
195
+ .then(data => { data["status"] == "ok" ? data : Promise.reject(data) })
196
+ .then(data => {
197
+ document.getElementById("success").style.display = "none";
198
+ submitButton.textContent = "✅ Successfully updated";
199
+ setTimeout(function() {
200
+ submitButton.textContent = "Save";
201
+ submitButton.disabled = false;
202
+ }, 2000);
203
+ })
204
+ .catch(error => {
205
+ document.getElementById("success").textContent = "⚠️ Failed to save Github content.";
206
+ document.getElementById("success").style.display = "block";
207
+ submitButton.textContent = "⚠️ Failed to save content";
208
+ setTimeout(function() {
209
+ submitButton.textContent = "Save";
210
+ submitButton.disabled = false;
211
+ }, 2000);
212
+ });
213
+
214
+ });
215
+ </script>
216
+ {% endblock %}
@@ -0,0 +1,94 @@
1
+ {% extends "base_config.html" %}
2
+ {% block content %}
3
+ <div class="page">
4
+ <div class="section">
5
+ <h2 class="section-title">
6
+ <img class="card-icon" src="/static/assets/icons/notion.svg?v={{ khoj_version }}" alt="Notion">
7
+ <span class="card-title-text">Notion</span>
8
+ <div class="instructions">
9
+ <a href="https://docs.khoj.dev/data-sources/notion_integration">ⓘ Help</a>
10
+ </div>
11
+ <table>
12
+ <tr>
13
+ <td>
14
+ <label for="token">Token</label>
15
+ </td>
16
+ <td>
17
+ <input type="text" id="token" name="pat" value="{{ current_config['token'] }}">
18
+ </td>
19
+ </tr>
20
+ </table>
21
+ <div class="section">
22
+ <div id="success" style="display: none;"></div>
23
+ <button id="submit" type="submit">Sync to Update</button>
24
+ </div>
25
+ </form>
26
+ </div>
27
+ </div>
28
+ <script>
29
+ const submit = document.getElementById("submit");
30
+
31
+ submit.addEventListener("click", function(event) {
32
+ event.preventDefault();
33
+
34
+ const token = document.getElementById("token").value;
35
+
36
+ if (token == "") {
37
+ document.getElementById("success").textContent = "❌ Please enter a Notion Token.";
38
+ document.getElementById("success").style.display = "block";
39
+ return;
40
+ }
41
+
42
+ const submitButton = document.getElementById("submit");
43
+ submitButton.disabled = true;
44
+ submitButton.textContent = "Syncing...";
45
+
46
+ // Save Notion config on server
47
+ const csrfToken = document.cookie.split('; ').find(row => row.startsWith('csrftoken'))?.split('=')[1];
48
+ fetch('/api/config/data/content-source/notion', {
49
+ method: 'POST',
50
+ headers: {
51
+ 'Content-Type': 'application/json',
52
+ 'X-CSRFToken': csrfToken,
53
+ },
54
+ body: JSON.stringify({
55
+ "token": token,
56
+ })
57
+ })
58
+ .then(response => response.json())
59
+ .then(data => { data["status"] === "ok" ? data : Promise.reject(data) })
60
+ .catch(error => {
61
+ document.getElementById("success").textContent = "⚠️ Failed to save Notion settings.";
62
+ document.getElementById("success").style.display = "block";
63
+ submitButton.textContent = "⚠️ Failed to save settings";
64
+ setTimeout(function() {
65
+ submitButton.textContent = "Save";
66
+ submitButton.disabled = false;
67
+ }, 2000);
68
+ return;
69
+ });
70
+
71
+ // Index Notion content on server
72
+ fetch('/api/update?t=notion')
73
+ .then(response => response.json())
74
+ .then(data => { data["status"] == "ok" ? data : Promise.reject(data) })
75
+ .then(data => {
76
+ document.getElementById("success").style.display = "none";
77
+ submitButton.textContent = "✅ Successfully updated";
78
+ setTimeout(function() {
79
+ submitButton.textContent = "Save";
80
+ submitButton.disabled = false;
81
+ }, 2000);
82
+ })
83
+ .catch(error => {
84
+ document.getElementById("success").textContent = "⚠️ Failed to save Notion content.";
85
+ document.getElementById("success").style.display = "block";
86
+ submitButton.textContent = "⚠️ Failed to save content";
87
+ setTimeout(function() {
88
+ submitButton.textContent = "Save";
89
+ submitButton.disabled = false;
90
+ }, 2000);
91
+ });
92
+ });
93
+ </script>
94
+ {% endblock %}
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "Khoj",
3
+ "short_name": "Khoj",
4
+ "display": "standalone",
5
+ "start_url": "/",
6
+ "description": "The open, personal AI for your digital brain. You can ask Khoj to draft a message, paint your imagination, find information on the internet and even answer questions from your documents.",
7
+ "theme_color": "#ffffff",
8
+ "background_color": "#ffffff",
9
+ "icons": [
10
+ {
11
+ "src": "/static/assets/icons/favicon-128x128.png",
12
+ "sizes": "128x128",
13
+ "type": "image/png"
14
+ },
15
+ {
16
+ "src": "/static/assets/icons/favicon-256x256.png",
17
+ "sizes": "256x256",
18
+ "type": "image/png"
19
+ }
20
+ ],
21
+ "screenshots": [
22
+ {
23
+ "src": "/static/assets/samples/phone-remember-plan-sample.png",
24
+ "sizes": "419x900",
25
+ "type": "image/png",
26
+ "form_factor": "narrow",
27
+ "label": "Remember and Plan"
28
+ },
29
+ {
30
+ "src": "/static/assets/samples/phone-browse-draw-sample.png",
31
+ "sizes": "419x900",
32
+ "type": "image/png",
33
+ "form_factor": "narrow",
34
+ "label": "Browse and Draw"
35
+ },
36
+ {
37
+ "src": "/static/assets/samples/desktop-remember-plan-sample.png",
38
+ "sizes": "1260x742",
39
+ "type": "image/png",
40
+ "form_factor": "wide",
41
+ "label": "Remember and Plan"
42
+ },
43
+ {
44
+ "src": "/static/assets/samples/desktop-browse-draw-sample.png",
45
+ "sizes": "1260x742",
46
+ "type": "image/png",
47
+ "form_factor": "wide",
48
+ "label": "Browse and Draw"
49
+ }
50
+ ]
51
+ }