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.
- khoj/__init__.py +0 -0
- khoj/app/README.md +94 -0
- khoj/app/__init__.py +0 -0
- khoj/app/asgi.py +16 -0
- khoj/app/settings.py +192 -0
- khoj/app/urls.py +25 -0
- khoj/configure.py +424 -0
- khoj/database/__init__.py +0 -0
- khoj/database/adapters/__init__.py +1234 -0
- khoj/database/admin.py +290 -0
- khoj/database/apps.py +6 -0
- khoj/database/management/__init__.py +0 -0
- khoj/database/management/commands/__init__.py +0 -0
- khoj/database/management/commands/change_generated_images_url.py +61 -0
- khoj/database/management/commands/convert_images_png_to_webp.py +99 -0
- khoj/database/migrations/0001_khojuser.py +98 -0
- khoj/database/migrations/0002_googleuser.py +32 -0
- khoj/database/migrations/0003_vector_extension.py +10 -0
- khoj/database/migrations/0004_content_types_and_more.py +181 -0
- khoj/database/migrations/0005_embeddings_corpus_id.py +19 -0
- khoj/database/migrations/0006_embeddingsdates.py +33 -0
- khoj/database/migrations/0007_add_conversation.py +27 -0
- khoj/database/migrations/0008_alter_conversation_conversation_log.py +17 -0
- khoj/database/migrations/0009_khojapiuser.py +24 -0
- khoj/database/migrations/0010_chatmodeloptions_and_more.py +83 -0
- khoj/database/migrations/0010_rename_embeddings_entry_and_more.py +30 -0
- khoj/database/migrations/0011_merge_20231102_0138.py +14 -0
- khoj/database/migrations/0012_entry_file_source.py +21 -0
- khoj/database/migrations/0013_subscription.py +37 -0
- khoj/database/migrations/0014_alter_googleuser_picture.py +17 -0
- khoj/database/migrations/0015_alter_subscription_user.py +21 -0
- khoj/database/migrations/0016_alter_subscription_renewal_date.py +17 -0
- khoj/database/migrations/0017_searchmodel.py +32 -0
- khoj/database/migrations/0018_searchmodelconfig_delete_searchmodel.py +30 -0
- khoj/database/migrations/0019_alter_googleuser_family_name_and_more.py +27 -0
- khoj/database/migrations/0020_reflectivequestion.py +36 -0
- khoj/database/migrations/0021_speechtotextmodeloptions_and_more.py +42 -0
- khoj/database/migrations/0022_texttoimagemodelconfig.py +25 -0
- khoj/database/migrations/0023_usersearchmodelconfig.py +33 -0
- khoj/database/migrations/0024_alter_entry_embeddings.py +18 -0
- khoj/database/migrations/0025_clientapplication_khojuser_phone_number_and_more.py +46 -0
- khoj/database/migrations/0025_searchmodelconfig_embeddings_inference_endpoint_and_more.py +22 -0
- khoj/database/migrations/0026_searchmodelconfig_cross_encoder_inference_endpoint_and_more.py +22 -0
- khoj/database/migrations/0027_merge_20240118_1324.py +13 -0
- khoj/database/migrations/0028_khojuser_verified_phone_number.py +17 -0
- khoj/database/migrations/0029_userrequests.py +27 -0
- khoj/database/migrations/0030_conversation_slug_and_title.py +38 -0
- khoj/database/migrations/0031_agent_conversation_agent.py +53 -0
- khoj/database/migrations/0031_alter_googleuser_locale.py +30 -0
- khoj/database/migrations/0032_merge_20240322_0427.py +14 -0
- khoj/database/migrations/0033_rename_tuning_agent_personality.py +17 -0
- khoj/database/migrations/0034_alter_chatmodeloptions_chat_model.py +32 -0
- khoj/database/migrations/0035_processlock.py +26 -0
- khoj/database/migrations/0036_alter_processlock_name.py +19 -0
- khoj/database/migrations/0036_delete_offlinechatprocessorconversationconfig.py +15 -0
- khoj/database/migrations/0036_publicconversation.py +42 -0
- khoj/database/migrations/0037_chatmodeloptions_openai_config_and_more.py +51 -0
- khoj/database/migrations/0037_searchmodelconfig_bi_encoder_docs_encode_config_and_more.py +32 -0
- khoj/database/migrations/0038_merge_20240425_0857.py +14 -0
- khoj/database/migrations/0038_merge_20240426_1640.py +12 -0
- khoj/database/migrations/0039_merge_20240501_0301.py +12 -0
- khoj/database/migrations/0040_alter_processlock_name.py +26 -0
- khoj/database/migrations/0040_merge_20240504_1010.py +14 -0
- khoj/database/migrations/0041_merge_20240505_1234.py +14 -0
- khoj/database/migrations/0042_serverchatsettings.py +46 -0
- khoj/database/migrations/0043_alter_chatmodeloptions_model_type.py +21 -0
- khoj/database/migrations/0044_conversation_file_filters.py +17 -0
- khoj/database/migrations/0045_fileobject.py +37 -0
- khoj/database/migrations/0046_khojuser_email_verification_code_and_more.py +22 -0
- khoj/database/migrations/0047_alter_entry_file_type.py +31 -0
- khoj/database/migrations/0048_voicemodeloption_uservoicemodelconfig.py +52 -0
- khoj/database/migrations/0049_datastore.py +38 -0
- khoj/database/migrations/0049_texttoimagemodelconfig_api_key_and_more.py +58 -0
- khoj/database/migrations/0050_alter_processlock_name.py +25 -0
- khoj/database/migrations/0051_merge_20240702_1220.py +14 -0
- khoj/database/migrations/0052_alter_searchmodelconfig_bi_encoder_docs_encode_config_and_more.py +27 -0
- khoj/database/migrations/__init__.py +0 -0
- khoj/database/models/__init__.py +402 -0
- khoj/database/tests.py +3 -0
- khoj/interface/email/feedback.html +34 -0
- khoj/interface/email/magic_link.html +17 -0
- khoj/interface/email/task.html +40 -0
- khoj/interface/email/welcome.html +61 -0
- khoj/interface/web/404.html +56 -0
- khoj/interface/web/agent.html +312 -0
- khoj/interface/web/agents.html +276 -0
- khoj/interface/web/assets/icons/agents.svg +6 -0
- khoj/interface/web/assets/icons/automation.svg +37 -0
- khoj/interface/web/assets/icons/cancel.svg +3 -0
- khoj/interface/web/assets/icons/chat.svg +24 -0
- khoj/interface/web/assets/icons/collapse.svg +17 -0
- khoj/interface/web/assets/icons/computer.png +0 -0
- khoj/interface/web/assets/icons/confirm-icon.svg +1 -0
- khoj/interface/web/assets/icons/copy-button-success.svg +6 -0
- khoj/interface/web/assets/icons/copy-button.svg +5 -0
- khoj/interface/web/assets/icons/credit-card.png +0 -0
- khoj/interface/web/assets/icons/delete.svg +26 -0
- khoj/interface/web/assets/icons/docx.svg +7 -0
- khoj/interface/web/assets/icons/edit.svg +4 -0
- khoj/interface/web/assets/icons/favicon-128x128.ico +0 -0
- khoj/interface/web/assets/icons/favicon-128x128.png +0 -0
- khoj/interface/web/assets/icons/favicon-256x256.png +0 -0
- khoj/interface/web/assets/icons/favicon.icns +0 -0
- khoj/interface/web/assets/icons/github.svg +1 -0
- khoj/interface/web/assets/icons/key.svg +4 -0
- khoj/interface/web/assets/icons/khoj-logo-sideways-200.png +0 -0
- khoj/interface/web/assets/icons/khoj-logo-sideways-500.png +0 -0
- khoj/interface/web/assets/icons/khoj-logo-sideways.svg +5385 -0
- khoj/interface/web/assets/icons/logotype.svg +1 -0
- khoj/interface/web/assets/icons/markdown.svg +1 -0
- khoj/interface/web/assets/icons/new.svg +23 -0
- khoj/interface/web/assets/icons/notion.svg +4 -0
- khoj/interface/web/assets/icons/openai-logomark.svg +1 -0
- khoj/interface/web/assets/icons/org.svg +1 -0
- khoj/interface/web/assets/icons/pdf.svg +23 -0
- khoj/interface/web/assets/icons/pencil-edit.svg +5 -0
- khoj/interface/web/assets/icons/plaintext.svg +1 -0
- khoj/interface/web/assets/icons/question-mark-icon.svg +1 -0
- khoj/interface/web/assets/icons/search.svg +25 -0
- khoj/interface/web/assets/icons/send.svg +1 -0
- khoj/interface/web/assets/icons/share.svg +8 -0
- khoj/interface/web/assets/icons/speaker.svg +4 -0
- khoj/interface/web/assets/icons/stop-solid.svg +37 -0
- khoj/interface/web/assets/icons/sync.svg +4 -0
- khoj/interface/web/assets/icons/thumbs-down-svgrepo-com.svg +6 -0
- khoj/interface/web/assets/icons/thumbs-up-svgrepo-com.svg +6 -0
- khoj/interface/web/assets/icons/user-silhouette.svg +4 -0
- khoj/interface/web/assets/icons/voice.svg +8 -0
- khoj/interface/web/assets/icons/web.svg +2 -0
- khoj/interface/web/assets/icons/whatsapp.svg +17 -0
- khoj/interface/web/assets/khoj.css +237 -0
- khoj/interface/web/assets/markdown-it.min.js +8476 -0
- khoj/interface/web/assets/natural-cron.min.js +1 -0
- khoj/interface/web/assets/org.min.js +1823 -0
- khoj/interface/web/assets/pico.min.css +5 -0
- khoj/interface/web/assets/purify.min.js +3 -0
- khoj/interface/web/assets/samples/desktop-browse-draw-sample.png +0 -0
- khoj/interface/web/assets/samples/desktop-plain-chat-sample.png +0 -0
- khoj/interface/web/assets/samples/desktop-remember-plan-sample.png +0 -0
- khoj/interface/web/assets/samples/phone-browse-draw-sample.png +0 -0
- khoj/interface/web/assets/samples/phone-plain-chat-sample.png +0 -0
- khoj/interface/web/assets/samples/phone-remember-plan-sample.png +0 -0
- khoj/interface/web/assets/utils.js +33 -0
- khoj/interface/web/base_config.html +445 -0
- khoj/interface/web/chat.html +3546 -0
- khoj/interface/web/config.html +1011 -0
- khoj/interface/web/config_automation.html +1103 -0
- khoj/interface/web/content_source_computer_input.html +139 -0
- khoj/interface/web/content_source_github_input.html +216 -0
- khoj/interface/web/content_source_notion_input.html +94 -0
- khoj/interface/web/khoj.webmanifest +51 -0
- khoj/interface/web/login.html +219 -0
- khoj/interface/web/public_conversation.html +2006 -0
- khoj/interface/web/search.html +470 -0
- khoj/interface/web/utils.html +48 -0
- khoj/main.py +241 -0
- khoj/manage.py +22 -0
- khoj/migrations/__init__.py +0 -0
- khoj/migrations/migrate_offline_chat_default_model.py +69 -0
- khoj/migrations/migrate_offline_chat_default_model_2.py +71 -0
- khoj/migrations/migrate_offline_chat_schema.py +83 -0
- khoj/migrations/migrate_offline_model.py +29 -0
- khoj/migrations/migrate_processor_config_openai.py +67 -0
- khoj/migrations/migrate_server_pg.py +138 -0
- khoj/migrations/migrate_version.py +17 -0
- khoj/processor/__init__.py +0 -0
- khoj/processor/content/__init__.py +0 -0
- khoj/processor/content/docx/__init__.py +0 -0
- khoj/processor/content/docx/docx_to_entries.py +110 -0
- khoj/processor/content/github/__init__.py +0 -0
- khoj/processor/content/github/github_to_entries.py +224 -0
- khoj/processor/content/images/__init__.py +0 -0
- khoj/processor/content/images/image_to_entries.py +118 -0
- khoj/processor/content/markdown/__init__.py +0 -0
- khoj/processor/content/markdown/markdown_to_entries.py +165 -0
- khoj/processor/content/notion/notion_to_entries.py +260 -0
- khoj/processor/content/org_mode/__init__.py +0 -0
- khoj/processor/content/org_mode/org_to_entries.py +231 -0
- khoj/processor/content/org_mode/orgnode.py +532 -0
- khoj/processor/content/pdf/__init__.py +0 -0
- khoj/processor/content/pdf/pdf_to_entries.py +116 -0
- khoj/processor/content/plaintext/__init__.py +0 -0
- khoj/processor/content/plaintext/plaintext_to_entries.py +122 -0
- khoj/processor/content/text_to_entries.py +297 -0
- khoj/processor/conversation/__init__.py +0 -0
- khoj/processor/conversation/anthropic/__init__.py +0 -0
- khoj/processor/conversation/anthropic/anthropic_chat.py +206 -0
- khoj/processor/conversation/anthropic/utils.py +114 -0
- khoj/processor/conversation/offline/__init__.py +0 -0
- khoj/processor/conversation/offline/chat_model.py +231 -0
- khoj/processor/conversation/offline/utils.py +78 -0
- khoj/processor/conversation/offline/whisper.py +15 -0
- khoj/processor/conversation/openai/__init__.py +0 -0
- khoj/processor/conversation/openai/gpt.py +187 -0
- khoj/processor/conversation/openai/utils.py +129 -0
- khoj/processor/conversation/openai/whisper.py +13 -0
- khoj/processor/conversation/prompts.py +758 -0
- khoj/processor/conversation/utils.py +262 -0
- khoj/processor/embeddings.py +117 -0
- khoj/processor/speech/__init__.py +0 -0
- khoj/processor/speech/text_to_speech.py +51 -0
- khoj/processor/tools/__init__.py +0 -0
- khoj/processor/tools/online_search.py +225 -0
- khoj/routers/__init__.py +0 -0
- khoj/routers/api.py +626 -0
- khoj/routers/api_agents.py +43 -0
- khoj/routers/api_chat.py +1180 -0
- khoj/routers/api_config.py +434 -0
- khoj/routers/api_phone.py +86 -0
- khoj/routers/auth.py +181 -0
- khoj/routers/email.py +133 -0
- khoj/routers/helpers.py +1188 -0
- khoj/routers/indexer.py +349 -0
- khoj/routers/notion.py +91 -0
- khoj/routers/storage.py +35 -0
- khoj/routers/subscription.py +104 -0
- khoj/routers/twilio.py +36 -0
- khoj/routers/web_client.py +471 -0
- khoj/search_filter/__init__.py +0 -0
- khoj/search_filter/base_filter.py +15 -0
- khoj/search_filter/date_filter.py +217 -0
- khoj/search_filter/file_filter.py +30 -0
- khoj/search_filter/word_filter.py +29 -0
- khoj/search_type/__init__.py +0 -0
- khoj/search_type/text_search.py +241 -0
- khoj/utils/__init__.py +0 -0
- khoj/utils/cli.py +93 -0
- khoj/utils/config.py +81 -0
- khoj/utils/constants.py +24 -0
- khoj/utils/fs_syncer.py +249 -0
- khoj/utils/helpers.py +418 -0
- khoj/utils/initialization.py +146 -0
- khoj/utils/jsonl.py +43 -0
- khoj/utils/models.py +47 -0
- khoj/utils/rawconfig.py +160 -0
- khoj/utils/state.py +46 -0
- khoj/utils/yaml.py +43 -0
- khoj-1.16.1.dev15.dist-info/METADATA +178 -0
- khoj-1.16.1.dev15.dist-info/RECORD +242 -0
- khoj-1.16.1.dev15.dist-info/WHEEL +4 -0
- khoj-1.16.1.dev15.dist-info/entry_points.txt +2 -0
- khoj-1.16.1.dev15.dist-info/licenses/LICENSE +661 -0
khoj/utils/rawconfig.py
ADDED
|
@@ -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
|
+
[](https://github.com/khoj-ai/khoj/actions/workflows/test.yml)
|
|
106
|
+
[](https://github.com/khoj-ai/khoj/pkgs/container/khoj)
|
|
107
|
+
[](https://pypi.org/project/khoj/)
|
|
108
|
+

|
|
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> • </span>
|
|
122
|
+
[🏮 Khoj Cloud](https://khoj.dev)
|
|
123
|
+
<span> • </span>
|
|
124
|
+
[💬 Get Involved](https://discord.gg/BDgyabRM6e)
|
|
125
|
+
<span> • </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>
|