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,160 @@
1
+ # System Packages
2
+ import json
3
+ import uuid
4
+ from pathlib import Path
5
+ from typing import Dict, List, Optional
6
+
7
+ from pydantic import BaseModel
8
+
9
+ from khoj.utils.helpers import to_snake_case_from_dash
10
+
11
+
12
+ class ConfigBase(BaseModel):
13
+ class Config:
14
+ alias_generator = to_snake_case_from_dash
15
+ populate_by_name = True
16
+
17
+ def __getitem__(self, item):
18
+ return getattr(self, item)
19
+
20
+ def __setitem__(self, key, value):
21
+ return setattr(self, key, value)
22
+
23
+
24
+ class LocationData(BaseModel):
25
+ city: Optional[str]
26
+ region: Optional[str]
27
+ country: Optional[str]
28
+
29
+
30
+ class FilterRequest(BaseModel):
31
+ filename: str
32
+ conversation_id: str
33
+
34
+
35
+ class TextConfigBase(ConfigBase):
36
+ compressed_jsonl: Path
37
+ embeddings_file: Path
38
+
39
+
40
+ class TextContentConfig(ConfigBase):
41
+ input_files: Optional[List[Path]] = None
42
+ input_filter: Optional[List[str]] = None
43
+ index_heading_entries: Optional[bool] = False
44
+
45
+
46
+ class GithubRepoConfig(ConfigBase):
47
+ name: str
48
+ owner: str
49
+ branch: Optional[str] = "master"
50
+
51
+
52
+ class GithubContentConfig(ConfigBase):
53
+ pat_token: str
54
+ repos: List[GithubRepoConfig]
55
+
56
+
57
+ class NotionContentConfig(ConfigBase):
58
+ token: str
59
+
60
+
61
+ class ContentConfig(ConfigBase):
62
+ org: Optional[TextContentConfig] = None
63
+ markdown: Optional[TextContentConfig] = None
64
+ pdf: Optional[TextContentConfig] = None
65
+ plaintext: Optional[TextContentConfig] = None
66
+ github: Optional[GithubContentConfig] = None
67
+ notion: Optional[NotionContentConfig] = None
68
+ image: Optional[TextContentConfig] = None
69
+ docx: Optional[TextContentConfig] = None
70
+
71
+
72
+ class ImageSearchConfig(ConfigBase):
73
+ encoder: str
74
+ encoder_type: Optional[str] = None
75
+ model_directory: Optional[Path] = None
76
+
77
+ class Config:
78
+ protected_namespaces = ()
79
+
80
+
81
+ class SearchConfig(ConfigBase):
82
+ image: Optional[ImageSearchConfig] = None
83
+
84
+
85
+ class OpenAIProcessorConfig(ConfigBase):
86
+ api_key: str
87
+ chat_model: Optional[str] = "gpt-3.5-turbo"
88
+
89
+
90
+ class OfflineChatProcessorConfig(ConfigBase):
91
+ chat_model: Optional[str] = "NousResearch/Hermes-2-Pro-Mistral-7B-GGUF"
92
+
93
+
94
+ class ConversationProcessorConfig(ConfigBase):
95
+ openai: Optional[OpenAIProcessorConfig] = None
96
+ offline_chat: Optional[OfflineChatProcessorConfig] = None
97
+ max_prompt_size: Optional[int] = None
98
+ tokenizer: Optional[str] = None
99
+
100
+
101
+ class ProcessorConfig(ConfigBase):
102
+ conversation: Optional[ConversationProcessorConfig] = None
103
+
104
+
105
+ class AppConfig(ConfigBase):
106
+ should_log_telemetry: bool = True
107
+
108
+
109
+ class FullConfig(ConfigBase):
110
+ content_type: Optional[ContentConfig] = None
111
+ search_type: Optional[SearchConfig] = None
112
+ processor: Optional[ProcessorConfig] = None
113
+ app: Optional[AppConfig] = AppConfig()
114
+ version: Optional[str] = None
115
+
116
+
117
+ class SearchResponse(ConfigBase):
118
+ entry: str
119
+ score: float
120
+ cross_score: Optional[float] = None
121
+ additional: Optional[dict] = None
122
+ corpus_id: str
123
+
124
+
125
+ class Entry:
126
+ raw: str
127
+ compiled: str
128
+ heading: Optional[str]
129
+ file: Optional[str]
130
+ corpus_id: str
131
+
132
+ def __init__(
133
+ self,
134
+ raw: str = None,
135
+ compiled: str = None,
136
+ heading: Optional[str] = None,
137
+ file: Optional[str] = None,
138
+ corpus_id: uuid.UUID = None,
139
+ ):
140
+ self.raw = raw
141
+ self.compiled = compiled
142
+ self.heading = heading
143
+ self.file = file
144
+ self.corpus_id = str(corpus_id)
145
+
146
+ def to_json(self) -> str:
147
+ return json.dumps(self.__dict__, ensure_ascii=False)
148
+
149
+ def __repr__(self) -> str:
150
+ return self.__dict__.__repr__()
151
+
152
+ @classmethod
153
+ def from_dict(cls, dictionary: dict):
154
+ return cls(
155
+ raw=dictionary["raw"],
156
+ compiled=dictionary["compiled"],
157
+ file=dictionary.get("file", None),
158
+ heading=dictionary.get("heading", None),
159
+ corpus_id=dictionary.get("corpus_id", None),
160
+ )
khoj/utils/state.py ADDED
@@ -0,0 +1,46 @@
1
+ import os
2
+ import threading
3
+ from collections import defaultdict
4
+ from pathlib import Path
5
+ from typing import Any, Dict, List
6
+
7
+ from apscheduler.schedulers.background import BackgroundScheduler
8
+ from openai import OpenAI
9
+ from whisper import Whisper
10
+
11
+ from khoj.database.models import ProcessLock
12
+ from khoj.processor.embeddings import CrossEncoderModel, EmbeddingsModel
13
+ from khoj.utils import config as utils_config
14
+ from khoj.utils.config import OfflineChatProcessorModel, SearchModels
15
+ from khoj.utils.helpers import LRU, get_device
16
+ from khoj.utils.rawconfig import FullConfig
17
+
18
+ # Application Global State
19
+ config = FullConfig()
20
+ search_models = SearchModels()
21
+ embeddings_model: Dict[str, EmbeddingsModel] = None
22
+ cross_encoder_model: Dict[str, CrossEncoderModel] = None
23
+ openai_client: OpenAI = None
24
+ offline_chat_processor_config: OfflineChatProcessorModel = None
25
+ whisper_model: Whisper = None
26
+ config_file: Path = None
27
+ verbose: int = 0
28
+ host: str = None
29
+ port: int = None
30
+ cli_args: List[str] = None
31
+ query_cache: Dict[str, LRU] = defaultdict(LRU)
32
+ chat_lock = threading.Lock()
33
+ SearchType = utils_config.SearchType
34
+ scheduler: BackgroundScheduler = None
35
+ schedule_leader_process_lock: ProcessLock = None
36
+ telemetry: List[Dict[str, str]] = []
37
+ khoj_version: str = None
38
+ device = get_device()
39
+ chat_on_gpu: bool = True
40
+ anonymous_mode: bool = False
41
+ pretrained_tokenizers: Dict[str, Any] = dict()
42
+ billing_enabled: bool = (
43
+ os.getenv("STRIPE_API_KEY") is not None
44
+ and os.getenv("STRIPE_SIGNING_SECRET") is not None
45
+ and os.getenv("KHOJ_CLOUD_SUBSCRIPTION_URL") is not None
46
+ )
khoj/utils/yaml.py ADDED
@@ -0,0 +1,43 @@
1
+ from pathlib import Path
2
+
3
+ import yaml
4
+
5
+ from khoj.utils import state
6
+ from khoj.utils.rawconfig import FullConfig
7
+
8
+ # Do not emit tags when dumping to YAML
9
+ yaml.emitter.Emitter.process_tag = lambda self, *args, **kwargs: None # type: ignore[assignment]
10
+
11
+
12
+ def save_config_to_file_updated_state():
13
+ with open(state.config_file, "w") as outfile:
14
+ yaml.dump(yaml.safe_load(state.config.json(by_alias=True)), outfile)
15
+ outfile.close()
16
+ return state.config
17
+
18
+
19
+ def save_config_to_file(yaml_config: dict, yaml_config_file: Path):
20
+ "Write config to YML file"
21
+ # Create output directory, if it doesn't exist
22
+ yaml_config_file.parent.mkdir(parents=True, exist_ok=True)
23
+
24
+ with open(yaml_config_file, "w", encoding="utf-8") as config_file:
25
+ yaml.safe_dump(yaml_config, config_file, allow_unicode=True)
26
+
27
+
28
+ def load_config_from_file(yaml_config_file: Path) -> dict:
29
+ "Read config from YML file"
30
+ config_from_file = None
31
+ with open(yaml_config_file, "r", encoding="utf-8") as config_file:
32
+ config_from_file = yaml.safe_load(config_file)
33
+ return config_from_file
34
+
35
+
36
+ def parse_config_from_string(yaml_config: dict) -> FullConfig:
37
+ "Parse and validate config in YML string"
38
+ return FullConfig.model_validate(yaml_config)
39
+
40
+
41
+ def parse_config_from_file(yaml_config_file):
42
+ "Parse and validate config in YML file"
43
+ return parse_config_from_string(load_config_from_file(yaml_config_file))
@@ -0,0 +1,178 @@
1
+ Metadata-Version: 2.3
2
+ Name: khoj
3
+ Version: 1.16.1.dev15
4
+ Summary: An AI copilot for your Second Brain
5
+ Project-URL: Homepage, https://khoj.dev
6
+ Project-URL: Documentation, https://docs.khoj.dev
7
+ Project-URL: Code, https://github.com/khoj-ai/khoj
8
+ Author: Debanjum Singh Solanky, Saba Imran
9
+ License-Expression: AGPL-3.0-or-later
10
+ License-File: LICENSE
11
+ Keywords: AI,NLP,images,markdown,org-mode,pdf,productivity,search,semantic-search
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Information Technology
14
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: aiohttp~=3.9.0
25
+ Requires-Dist: anthropic==0.26.1
26
+ Requires-Dist: anyio==3.7.1
27
+ Requires-Dist: apscheduler~=3.10.0
28
+ Requires-Dist: authlib==1.2.1
29
+ Requires-Dist: beautifulsoup4~=4.12.3
30
+ Requires-Dist: cron-descriptor==1.4.3
31
+ Requires-Dist: dateparser>=1.1.1
32
+ Requires-Dist: defusedxml==0.7.1
33
+ Requires-Dist: django-apscheduler==0.6.2
34
+ Requires-Dist: django-phonenumber-field==7.3.0
35
+ Requires-Dist: django==5.0.7
36
+ Requires-Dist: docx2txt==0.8
37
+ Requires-Dist: einops==0.8.0
38
+ Requires-Dist: fastapi>=0.104.1
39
+ Requires-Dist: httpx==0.25.0
40
+ Requires-Dist: huggingface-hub>=0.22.2
41
+ Requires-Dist: itsdangerous==2.1.2
42
+ Requires-Dist: jinja2==3.1.4
43
+ Requires-Dist: langchain-community==0.2.5
44
+ Requires-Dist: langchain-openai==0.1.7
45
+ Requires-Dist: langchain==0.2.5
46
+ Requires-Dist: llama-cpp-python==0.2.76
47
+ Requires-Dist: lxml==4.9.3
48
+ Requires-Dist: magika~=0.5.1
49
+ Requires-Dist: markdown-it-py~=3.0.0
50
+ Requires-Dist: markdownify~=0.11.6
51
+ Requires-Dist: openai-whisper>=20231117
52
+ Requires-Dist: openai>=1.0.0
53
+ Requires-Dist: pgvector==0.2.4
54
+ Requires-Dist: phonenumbers==8.13.27
55
+ Requires-Dist: pillow~=10.0.0
56
+ Requires-Dist: psutil>=5.8.0
57
+ Requires-Dist: psycopg2-binary==2.9.9
58
+ Requires-Dist: pydantic[email]>=2.0.0
59
+ Requires-Dist: pymupdf>=1.23.5
60
+ Requires-Dist: python-multipart>=0.0.7
61
+ Requires-Dist: pytz~=2024.1
62
+ Requires-Dist: pyyaml~=6.0
63
+ Requires-Dist: rapidocr-onnxruntime==1.3.22
64
+ Requires-Dist: requests>=2.26.0
65
+ Requires-Dist: rich>=13.3.1
66
+ Requires-Dist: schedule==1.1.0
67
+ Requires-Dist: sentence-transformers==3.0.1
68
+ Requires-Dist: tenacity==8.3.0
69
+ Requires-Dist: tenacity>=8.2.2
70
+ Requires-Dist: tiktoken>=0.3.2
71
+ Requires-Dist: torch==2.2.2
72
+ Requires-Dist: transformers>=4.28.0
73
+ Requires-Dist: tzdata==2023.3
74
+ Requires-Dist: uvicorn==0.17.6
75
+ Requires-Dist: websockets==12.0
76
+ Provides-Extra: dev
77
+ Requires-Dist: black>=23.1.0; extra == 'dev'
78
+ Requires-Dist: boto3>=1.34.57; extra == 'dev'
79
+ Requires-Dist: factory-boy>=3.2.1; extra == 'dev'
80
+ Requires-Dist: freezegun>=1.2.0; extra == 'dev'
81
+ Requires-Dist: google-auth==2.23.3; extra == 'dev'
82
+ Requires-Dist: gunicorn==22.0.0; extra == 'dev'
83
+ Requires-Dist: mypy>=1.0.1; extra == 'dev'
84
+ Requires-Dist: pre-commit>=3.0.4; extra == 'dev'
85
+ Requires-Dist: pytest-asyncio==0.21.1; extra == 'dev'
86
+ Requires-Dist: pytest-django==4.5.2; extra == 'dev'
87
+ Requires-Dist: pytest-xdist[psutil]; extra == 'dev'
88
+ Requires-Dist: pytest>=7.1.2; extra == 'dev'
89
+ Requires-Dist: resend==1.0.1; extra == 'dev'
90
+ Requires-Dist: stripe==7.3.0; extra == 'dev'
91
+ Requires-Dist: twilio==8.11; extra == 'dev'
92
+ Provides-Extra: prod
93
+ Requires-Dist: boto3>=1.34.57; extra == 'prod'
94
+ Requires-Dist: google-auth==2.23.3; extra == 'prod'
95
+ Requires-Dist: gunicorn==22.0.0; extra == 'prod'
96
+ Requires-Dist: resend==1.0.1; extra == 'prod'
97
+ Requires-Dist: stripe==7.3.0; extra == 'prod'
98
+ Requires-Dist: twilio==8.11; extra == 'prod'
99
+ Description-Content-Type: text/markdown
100
+
101
+ <p align="center"><img src="src/khoj/interface/web/assets/icons/khoj-logo-sideways-500.png" width="230" alt="Khoj Logo"></p>
102
+
103
+ <div align="center">
104
+
105
+ [![test](https://github.com/khoj-ai/khoj/actions/workflows/test.yml/badge.svg)](https://github.com/khoj-ai/khoj/actions/workflows/test.yml)
106
+ [![dockerize](https://github.com/khoj-ai/khoj/actions/workflows/dockerize.yml/badge.svg)](https://github.com/khoj-ai/khoj/pkgs/container/khoj)
107
+ [![pypi](https://github.com/khoj-ai/khoj/actions/workflows/pypi.yml/badge.svg)](https://pypi.org/project/khoj/)
108
+ ![Discord](https://img.shields.io/discord/1112065956647284756?style=plastic&label=discord)
109
+
110
+ </div>
111
+
112
+ <div align="center">
113
+ <b>The open-source, personal AI for your digital brain</b>
114
+ </div>
115
+
116
+ <br />
117
+
118
+ <div align="center">
119
+
120
+ [🤖 Read Docs](https://docs.khoj.dev)
121
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
122
+ [🏮 Khoj Cloud](https://khoj.dev)
123
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
124
+ [💬 Get Involved](https://discord.gg/BDgyabRM6e)
125
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
126
+ [📚 Read Blog](https://blog.khoj.dev)
127
+
128
+ </div>
129
+
130
+ <div align="left">
131
+
132
+ ***
133
+
134
+ Khoj is an application that creates always-available, personal AI agents for you to extend your capabilities.
135
+ - You can share your notes and documents to extend your digital brain.
136
+ - Your AI agents have access to the internet, allowing you to incorporate realtime information.
137
+ - Khoj is accessible on Desktop, Emacs, Obsidian, Web and Whatsapp.
138
+ - You can share pdf, markdown, org-mode, notion files and github repositories.
139
+ - You'll get fast, accurate semantic search on top of your docs.
140
+ - Your agents can create deeply personal images and understand your speech.
141
+ - Khoj is open-source, self-hostable. Always.
142
+
143
+ ***
144
+
145
+ </div>
146
+
147
+ ## See it in action
148
+
149
+ <img src="https://github.com/khoj-ai/khoj/blob/master/documentation/assets/img/using_khoj_for_studying.gif?raw=true" alt="Khoj Demo">
150
+
151
+ Go to https://app.khoj.dev to see Khoj live.
152
+
153
+ ## Full feature list
154
+ You can see the full feature list [here](https://docs.khoj.dev/category/features).
155
+
156
+ ## Self-Host
157
+
158
+ To get started with self-hosting Khoj, [read the docs](https://docs.khoj.dev/get-started/setup).
159
+
160
+ ## Contributors
161
+ Cheers to our awesome contributors! 🎉
162
+
163
+ <a href="https://github.com/khoj-ai/khoj/graphs/contributors">
164
+ <img src="https://contrib.rocks/image?repo=khoj-ai/khoj" />
165
+ </a>
166
+
167
+ Made with [contrib.rocks](https://contrib.rocks).
168
+
169
+ ### Interested in Contributing?
170
+
171
+ We are always looking for contributors to help us build new features, improve the project documentation, or fix bugs. If you're interested, please see our [Contributing Guidelines](https://docs.khoj.dev/contributing/development) and check out our [Contributors Project Board](https://github.com/orgs/khoj-ai/projects/4).
172
+
173
+ ## [Sponsors](https://github.com/sponsors/khoj-ai)
174
+ Shout out to our brilliant sponsors! 🌈
175
+
176
+ <a href="http://github.com/beekeeb">
177
+ <img src="https://raw.githubusercontent.com/beekeeb/piantor/main/docs/beekeeb.png" width=250/>
178
+ </a>