khoj 1.24.1__py3-none-any.whl → 1.24.1.dev3__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/configure.py +0 -1
- khoj/database/adapters/__init__.py +1 -8
- khoj/interface/compiled/404/index.html +1 -1
- khoj/interface/compiled/_next/static/chunks/1603-e13f41ec2cb3f147.js +1 -0
- khoj/interface/compiled/_next/static/chunks/2697-5b013077cfa7aaf0.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/automations/page-2b82404aea9fedca.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/chat/page-09cdd872ccb8dae5.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/share/chat/page-09a009c5a9f15a00.js +1 -0
- khoj/interface/compiled/_next/static/chunks/{webpack-c4376b110507dd22.js → webpack-5752cc306704366c.js} +1 -1
- khoj/interface/compiled/_next/static/css/{2de69f0be774c768.css → 60fc94dfe42ddfe9.css} +1 -1
- khoj/interface/compiled/agents/index.html +1 -1
- khoj/interface/compiled/agents/index.txt +2 -2
- khoj/interface/compiled/automations/index.html +1 -1
- khoj/interface/compiled/automations/index.txt +2 -2
- khoj/interface/compiled/chat/index.html +1 -1
- khoj/interface/compiled/chat/index.txt +2 -2
- khoj/interface/compiled/factchecker/index.html +1 -1
- khoj/interface/compiled/factchecker/index.txt +2 -2
- khoj/interface/compiled/index.html +1 -1
- khoj/interface/compiled/index.txt +2 -2
- khoj/interface/compiled/search/index.html +1 -1
- khoj/interface/compiled/search/index.txt +2 -2
- khoj/interface/compiled/settings/index.html +1 -1
- khoj/interface/compiled/settings/index.txt +2 -2
- khoj/interface/compiled/share/chat/index.html +1 -1
- khoj/interface/compiled/share/chat/index.txt +2 -2
- khoj/interface/web/login.html +159 -261
- khoj/processor/conversation/anthropic/anthropic_chat.py +3 -2
- khoj/processor/conversation/google/gemini_chat.py +3 -2
- khoj/processor/conversation/offline/chat_model.py +3 -2
- khoj/processor/conversation/openai/gpt.py +3 -2
- khoj/processor/tools/online_search.py +5 -5
- khoj/routers/api.py +2 -2
- khoj/routers/api_chat.py +6 -15
- khoj/routers/helpers.py +5 -4
- khoj/utils/helpers.py +0 -23
- khoj/utils/rawconfig.py +0 -11
- {khoj-1.24.1.dist-info → khoj-1.24.1.dev3.dist-info}/METADATA +1 -1
- {khoj-1.24.1.dist-info → khoj-1.24.1.dev3.dist-info}/RECORD +49 -49
- khoj/interface/compiled/_next/static/chunks/1603-3e2e1528e3b6ea1d.js +0 -1
- khoj/interface/compiled/_next/static/chunks/2697-a29cb9191a9e339c.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/automations/page-4b5ccea059588a4f.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/page-5b1626fc2882c1f9.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/share/chat/page-9d9faa4a155bbf58.js +0 -1
- /khoj/interface/compiled/_next/static/{ur0fLamZjkY1Cn46tcnnQ → 2pxlycTv1ch-VIs-n6mrX}/_buildManifest.js +0 -0
- /khoj/interface/compiled/_next/static/{ur0fLamZjkY1Cn46tcnnQ → 2pxlycTv1ch-VIs-n6mrX}/_ssgManifest.js +0 -0
- /khoj/interface/compiled/_next/static/chunks/{8423-62ac6c832be2461b.js → 8423-7f5eb790353afe24.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{9178-409f672ab573b8fd.js → 9178-f478bc3670cc0cb8.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{9417-5d14ac74aaab2c66.js → 9417-2e54c6fd056982d8.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/app/agents/{page-a3db5b3869f83937.js → page-9d629103b55928fa.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/app/{page-ee9ee504f0d5ace6.js → page-3e69f2879a188806.js} +0 -0
- {khoj-1.24.1.dist-info → khoj-1.24.1.dev3.dist-info}/WHEEL +0 -0
- {khoj-1.24.1.dist-info → khoj-1.24.1.dev3.dist-info}/entry_points.txt +0 -0
- {khoj-1.24.1.dist-info → khoj-1.24.1.dev3.dist-info}/licenses/LICENSE +0 -0
khoj/interface/web/login.html
CHANGED
@@ -1,321 +1,219 @@
|
|
1
1
|
<html>
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
</head>
|
12
|
-
|
13
|
-
<body>
|
14
|
-
|
15
|
-
|
16
|
-
<div class="split left">
|
2
|
+
<head>
|
3
|
+
<meta charset="utf-8">
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=1.0">
|
5
|
+
<title>Khoj - Login</title>
|
6
|
+
|
7
|
+
<link rel="icon" type="image/png" sizes="128x128" href="https://assets.khoj.dev/khoj_lantern_128x128.png">
|
8
|
+
<link rel="manifest" href="/static/khoj.webmanifest">
|
9
|
+
<link rel="stylesheet" href="/static/assets/khoj.css">
|
10
|
+
<meta property="og:image" content="https://assets.khoj.dev/khoj_hero.png">
|
11
|
+
</head>
|
12
|
+
|
13
|
+
<body>
|
14
|
+
<div class="khoj-header"></div>
|
15
|
+
<!-- Login Modal -->
|
17
16
|
<div id="login-modal">
|
18
|
-
<img class="khoj-logo" src="https://assets.khoj.dev/khoj_lantern_128x128.png" alt="Khoj">
|
17
|
+
<img class="khoj-logo" src="https://assets.khoj.dev/khoj_lantern_128x128.png" alt="Khoj"></img>
|
19
18
|
<div class="login-modal-title">Login to Khoj</div>
|
20
|
-
<!-- Sign Up/Login with Google OAuth -->
|
21
|
-
<div class="g_id_signin" data-shape="circle" data-text="continue_with" data-logo_alignment="center"
|
22
|
-
data-size="large" data-type="standard"></div>
|
23
|
-
<div id="g_id_onload" data-client_id="{{ google_client_id }}" data-ux_mode="popup"
|
24
|
-
data-use_fedcm_for_prompt="true" data-login_uri="{{ redirect_uri }}" data-auto-select="true"></div>
|
25
|
-
|
26
|
-
<!-- Divider -->
|
27
|
-
<div class="divider">OR</div>
|
28
19
|
<!-- Sign in with Magic Link -->
|
29
20
|
<div class="khoj-magic-link">
|
30
21
|
<input type="email" id="email" placeholder="Email" autofocus required>
|
31
|
-
<button id="magic-link-button">
|
22
|
+
<button id="magic-link-button">Send Magic Link</button>
|
32
23
|
</div>
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
fill="none">
|
51
|
-
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
52
|
-
<path d="M14 2v6h6" />
|
53
|
-
<path d="M16 13H8" />
|
54
|
-
<path d="M16 17H8" />
|
55
|
-
<path d="M10 9H8" />
|
56
|
-
</svg>
|
57
|
-
<span>Get answers across your documents and the internet</span>
|
58
|
-
</div>
|
59
|
-
<div class="feature">
|
60
|
-
<svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2"
|
61
|
-
fill="none">
|
62
|
-
<path
|
63
|
-
d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" />
|
64
|
-
<path d="M3.3 7l8.7 5 8.7-5" />
|
65
|
-
</svg>
|
66
|
-
<span>Go deeper in the topics personal to you</span>
|
67
|
-
</div>
|
68
|
-
<div class="feature">
|
69
|
-
<svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2"
|
70
|
-
fill="none">
|
71
|
-
<path d="M12 2L2 7l10 5 10-5-10-5z" />
|
72
|
-
<path d="M2 17l10 5 10-5" />
|
73
|
-
<path d="M2 12l10 5 10-5" />
|
74
|
-
</svg>
|
75
|
-
<span>Use specialized agents</span>
|
76
|
-
</div>
|
24
|
+
<!-- Divider -->
|
25
|
+
<div style="text-align: center; font-size: 16px; font-weight: 500; border-top: 1px solid black;">OR</div>
|
26
|
+
<!-- Sign Up/Login with Google OAuth -->
|
27
|
+
<div
|
28
|
+
class="g_id_signin"
|
29
|
+
data-shape="circle"
|
30
|
+
data-text="continue_with"
|
31
|
+
data-logo_alignment="center"
|
32
|
+
data-size="large"
|
33
|
+
data-type="standard">
|
34
|
+
</div>
|
35
|
+
<div id="g_id_onload"
|
36
|
+
data-client_id="{{ google_client_id }}"
|
37
|
+
data-ux_mode="popup"
|
38
|
+
data-use_fedcm_for_prompt="true"
|
39
|
+
data-login_uri="{{ redirect_uri }}"
|
40
|
+
data-auto-select="true">
|
77
41
|
</div>
|
78
42
|
</div>
|
79
|
-
</div>
|
80
|
-
</div>
|
81
43
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
height: 100vh;
|
86
|
-
font-family: 'Arial', sans-serif;
|
87
|
-
color: #333;
|
88
|
-
overflow: hidden;
|
89
|
-
}
|
44
|
+
<div class="khoj-footer"></div>
|
45
|
+
</div>
|
46
|
+
</body>
|
90
47
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
}
|
48
|
+
<script>
|
49
|
+
const magicLinkButton = document.getElementById('magic-link-button');
|
50
|
+
const emailInput = document.getElementById('email');
|
95
51
|
|
96
|
-
.
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
}
|
52
|
+
magicLinkButton.addEventListener('click', async () => {
|
53
|
+
const email = emailInput.value;
|
54
|
+
if (!email) {
|
55
|
+
alert('Please enter a valid email address');
|
56
|
+
return;
|
57
|
+
}
|
103
58
|
|
104
|
-
|
105
|
-
|
106
|
-
|
59
|
+
if (!email.includes('@')) {
|
60
|
+
alert('Please enter a valid email address');
|
61
|
+
return;
|
62
|
+
}
|
107
63
|
|
108
|
-
|
109
|
-
|
110
|
-
color: white;
|
111
|
-
position: relative;
|
112
|
-
overflow: hidden;
|
113
|
-
}
|
64
|
+
magicLinkButton.disabled = true;
|
65
|
+
magicLinkButton.innerText = 'Check your email for a sign-in link!';
|
114
66
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
opacity: 0.1;
|
123
|
-
}
|
67
|
+
const response = await fetch('/auth/magic', {
|
68
|
+
method: 'POST',
|
69
|
+
headers: {
|
70
|
+
'Content-Type': 'application/json',
|
71
|
+
},
|
72
|
+
body: JSON.stringify({ "email": email }),
|
73
|
+
})
|
124
74
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
}
|
75
|
+
if (response.status === 200) {
|
76
|
+
console.log('Magic link sent to your email');
|
77
|
+
} else {
|
78
|
+
alert('Failed to send magic link');
|
79
|
+
}
|
80
|
+
});
|
81
|
+
</script>
|
131
82
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
83
|
+
<style>
|
84
|
+
@media only screen and (max-width: 700px) {
|
85
|
+
body {
|
86
|
+
display: grid;
|
87
|
+
grid-template-columns: 1fr;
|
88
|
+
grid-template-rows: 1fr auto 1fr;
|
89
|
+
font-size: small!important;
|
90
|
+
}
|
91
|
+
body > * {
|
92
|
+
grid-column: 1;
|
93
|
+
}
|
136
94
|
}
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
95
|
+
@media only screen and (min-width: 700px) {
|
96
|
+
body {
|
97
|
+
display: grid;
|
98
|
+
grid-template-columns: 1fr min(50vw, 100%) 1fr;
|
99
|
+
grid-template-rows: 1fr auto 1fr;
|
100
|
+
}
|
101
|
+
body > * {
|
102
|
+
grid-column: 2;
|
103
|
+
}
|
142
104
|
}
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
105
|
+
body {
|
106
|
+
padding: 0px;
|
107
|
+
margin: 0px;
|
108
|
+
height: 100%;
|
109
|
+
background: url('/static/assets/samples/desktop-plain-chat-sample.png') no-repeat center center fixed;
|
110
|
+
background-size: contain;
|
111
|
+
color: var(--main-text-color);
|
112
|
+
font-family: var(--font-family);
|
113
|
+
font-size: 20px;
|
114
|
+
font-weight: 300;
|
115
|
+
line-height: 1.5em;
|
116
|
+
}
|
117
|
+
body::before {
|
118
|
+
content: "";
|
119
|
+
position: absolute;
|
120
|
+
top: 0;
|
121
|
+
left: 0;
|
122
|
+
width: 100%;
|
123
|
+
height: 100%;
|
124
|
+
background: var(--frosted-background-color);
|
125
|
+
backdrop-filter: blur(10px);
|
149
126
|
}
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
align-items: center;
|
154
|
-
gap: 1rem;
|
155
|
-
font-size: 1.1rem;
|
127
|
+
body > * {
|
128
|
+
padding: 10px;
|
129
|
+
margin: 10px;
|
156
130
|
}
|
157
131
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
132
|
+
@keyframes gradient {
|
133
|
+
0% {
|
134
|
+
background-position: 0% 50%;
|
135
|
+
}
|
136
|
+
50% {
|
137
|
+
background-position: 100% 50%;
|
138
|
+
}
|
139
|
+
100% {
|
140
|
+
background-position: 0% 50%;
|
141
|
+
}
|
162
142
|
}
|
163
143
|
|
164
|
-
|
165
|
-
display: grid;
|
166
|
-
background: white;
|
167
|
-
border-radius: 10px;
|
168
|
-
padding: 40px;
|
169
|
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
144
|
+
a.khoj-logo {
|
170
145
|
text-align: center;
|
171
|
-
|
146
|
+
justify-self: center;
|
172
147
|
}
|
173
148
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
margin-bottom: 20px;
|
149
|
+
div#login-modal {
|
150
|
+
display: grid;
|
151
|
+
grid-template-columns: 1fr;
|
152
|
+
gap: 32px;
|
153
|
+
min-height: 300px;
|
154
|
+
margin-left: 25%;
|
155
|
+
margin-right: 25%;
|
156
|
+
z-index: 1;
|
183
157
|
}
|
184
158
|
|
185
159
|
.khoj-magic-link {
|
186
|
-
display:
|
187
|
-
|
188
|
-
gap:
|
160
|
+
display: grid;
|
161
|
+
grid-template-columns: 1fr;
|
162
|
+
gap: 16px;
|
163
|
+
text-align: center;
|
189
164
|
}
|
190
165
|
|
191
166
|
#email {
|
192
167
|
padding: 10px;
|
193
|
-
|
168
|
+
font-size: 16px;
|
169
|
+
border: 1px solid var(--main-text-color);
|
194
170
|
border-radius: 5px;
|
195
171
|
width: 100%;
|
196
|
-
|
172
|
+
}
|
173
|
+
|
174
|
+
#email:focus {
|
175
|
+
box-shadow: 0 0 10px var(--main-text-color);
|
197
176
|
}
|
198
177
|
|
199
178
|
#magic-link-button {
|
200
179
|
padding: 10px;
|
201
|
-
|
180
|
+
font-size: 16px;
|
181
|
+
border: 1px solid var(--main-text-color);
|
202
182
|
border-radius: 5px;
|
203
|
-
|
204
|
-
|
183
|
+
width: 100%;
|
184
|
+
background: var(--main-text-color);
|
185
|
+
color: var(--frosted-background-color);
|
205
186
|
cursor: pointer;
|
206
|
-
font-size: 16px;
|
207
|
-
transition: background-color 0.3s;
|
208
187
|
}
|
209
188
|
|
210
189
|
#magic-link-button:hover {
|
211
|
-
|
212
|
-
}
|
213
|
-
|
214
|
-
#magic-link-button:disabled {
|
215
|
-
background-color: #cccccc;
|
216
|
-
cursor: not-allowed;
|
190
|
+
box-shadow: 0 0 10px var(--main-text-color);
|
217
191
|
}
|
218
192
|
|
219
|
-
.
|
220
|
-
display: flex;
|
221
|
-
align-items: center;
|
222
|
-
text-align: center;
|
223
|
-
color: #000;
|
224
|
-
/* Adjust the text color as needed */
|
225
|
-
margin: 20px 0;
|
226
|
-
/* Adjust the margin as needed */
|
227
|
-
}
|
228
|
-
|
229
|
-
.divider::before,
|
230
|
-
.divider::after {
|
231
|
-
content: '';
|
232
|
-
flex: 1;
|
233
|
-
border-bottom: 1px solid #000;
|
234
|
-
/* Adjust the line color as needed */
|
235
|
-
margin: 0 10px;
|
236
|
-
/* Adjust the spacing as needed */
|
237
|
-
}
|
238
|
-
|
239
|
-
.g_id_signin {
|
193
|
+
div.g_id_signin {
|
240
194
|
margin: 0 auto;
|
241
195
|
display: block;
|
242
196
|
}
|
243
197
|
|
244
|
-
.
|
245
|
-
width: 100%;
|
198
|
+
div.login-modal-title {
|
246
199
|
text-align: center;
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
}
|
251
|
-
|
252
|
-
.footer-links a {
|
253
|
-
color: #666;
|
254
|
-
text-decoration: none;
|
255
|
-
margin: 0 10px;
|
256
|
-
}
|
257
|
-
|
258
|
-
.footer-links a:hover {
|
259
|
-
text-decoration: underline;
|
260
|
-
}
|
261
|
-
|
262
|
-
.divider-vertical {
|
263
|
-
display: inline-block;
|
264
|
-
width: 1px;
|
265
|
-
height: 12px;
|
266
|
-
background-color: #666;
|
267
|
-
margin: 0 10px;
|
268
|
-
vertical-align: middle;
|
200
|
+
line-height: 28px;
|
201
|
+
font-size: 24px;
|
202
|
+
font-weight: 500;
|
269
203
|
}
|
270
204
|
|
271
|
-
@media (max-width:
|
272
|
-
|
273
|
-
|
205
|
+
@media only screen and (max-width: 700px) {
|
206
|
+
body{
|
207
|
+
background: url('/static/assets/samples/phone-plain-chat-sample.png') no-repeat center center fixed;
|
208
|
+
background-size: contain;
|
274
209
|
}
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
.left {
|
281
|
-
padding: 2rem;
|
210
|
+
div#login-modal {
|
211
|
+
margin-left: 10%;
|
212
|
+
margin-right: 10%;
|
213
|
+
z-index: 1;
|
282
214
|
}
|
283
215
|
}
|
284
|
-
</style>
|
285
|
-
|
286
|
-
<script>
|
287
|
-
const magicLinkButton = document.getElementById('magic-link-button');
|
288
|
-
const emailInput = document.getElementById('email');
|
289
|
-
magicLinkButton.addEventListener('click', async () => {
|
290
|
-
const email = emailInput.value;
|
291
|
-
if (!email) {
|
292
|
-
alert('Please enter a valid email address');
|
293
|
-
return;
|
294
|
-
}
|
295
|
-
if (!email.includes('@')) {
|
296
|
-
alert('Please enter a valid email address');
|
297
|
-
return;
|
298
|
-
}
|
299
|
-
magicLinkButton.disabled = true;
|
300
|
-
magicLinkButton.innerText = 'Check your email for a sign-in link!';
|
301
|
-
const response = await fetch('/auth/magic', {
|
302
|
-
method: 'POST',
|
303
|
-
headers: {
|
304
|
-
'Content-Type': 'application/json',
|
305
|
-
},
|
306
|
-
body: JSON.stringify({ "email": email }),
|
307
|
-
});
|
308
|
-
if (response.status === 200) {
|
309
|
-
console.log('Magic link sent to your email');
|
310
|
-
} else {
|
311
|
-
alert('Failed to send magic link');
|
312
|
-
magicLinkButton.disabled = false;
|
313
|
-
magicLinkButton.innerText = 'Get Login Link';
|
314
|
-
}
|
315
|
-
});
|
316
|
-
</script>
|
317
216
|
|
217
|
+
</style>
|
318
218
|
<script src="https://accounts.google.com/gsi/client" async defer></script>
|
319
|
-
</body>
|
320
|
-
|
321
219
|
</html>
|
@@ -32,7 +32,7 @@ def extract_questions_anthropic(
|
|
32
32
|
Infer search queries to retrieve relevant notes to answer user query
|
33
33
|
"""
|
34
34
|
# Extract Past User Message and Inferred Questions from Conversation Log
|
35
|
-
location = f"{location_data}" if location_data else "Unknown"
|
35
|
+
location = f"{location_data.city}, {location_data.region}, {location_data.country}" if location_data else "Unknown"
|
36
36
|
username = prompts.user_name.format(name=user.get_full_name()) if user and user.get_full_name() else ""
|
37
37
|
|
38
38
|
# Extract Past User Message and Inferred Questions from Conversation Log
|
@@ -158,7 +158,8 @@ def converse_anthropic(
|
|
158
158
|
)
|
159
159
|
|
160
160
|
if location_data:
|
161
|
-
|
161
|
+
location = f"{location_data.city}, {location_data.region}, {location_data.country}"
|
162
|
+
location_prompt = prompts.user_location.format(location=location)
|
162
163
|
system_prompt = f"{system_prompt}\n{location_prompt}"
|
163
164
|
|
164
165
|
if user_name:
|
@@ -33,7 +33,7 @@ def extract_questions_gemini(
|
|
33
33
|
Infer search queries to retrieve relevant notes to answer user query
|
34
34
|
"""
|
35
35
|
# Extract Past User Message and Inferred Questions from Conversation Log
|
36
|
-
location = f"{location_data}" if location_data else "Unknown"
|
36
|
+
location = f"{location_data.city}, {location_data.region}, {location_data.country}" if location_data else "Unknown"
|
37
37
|
username = prompts.user_name.format(name=user.get_full_name()) if user and user.get_full_name() else ""
|
38
38
|
|
39
39
|
# Extract Past User Message and Inferred Questions from Conversation Log
|
@@ -163,7 +163,8 @@ def converse_gemini(
|
|
163
163
|
)
|
164
164
|
|
165
165
|
if location_data:
|
166
|
-
|
166
|
+
location = f"{location_data.city}, {location_data.region}, {location_data.country}"
|
167
|
+
location_prompt = prompts.user_location.format(location=location)
|
167
168
|
system_prompt = f"{system_prompt}\n{location_prompt}"
|
168
169
|
|
169
170
|
if user_name:
|
@@ -46,7 +46,7 @@ def extract_questions_offline(
|
|
46
46
|
assert loaded_model is None or isinstance(loaded_model, Llama), "loaded_model must be of type Llama, if configured"
|
47
47
|
offline_chat_model = loaded_model or download_model(model, max_tokens=max_prompt_size)
|
48
48
|
|
49
|
-
location = f"{location_data}" if location_data else "Unknown"
|
49
|
+
location = f"{location_data.city}, {location_data.region}, {location_data.country}" if location_data else "Unknown"
|
50
50
|
username = prompts.user_name.format(name=user.get_full_name()) if user and user.get_full_name() else ""
|
51
51
|
|
52
52
|
# Extract Past User Message and Inferred Questions from Conversation Log
|
@@ -171,7 +171,8 @@ def converse_offline(
|
|
171
171
|
conversation_primer = prompts.query_prompt.format(query=user_query)
|
172
172
|
|
173
173
|
if location_data:
|
174
|
-
|
174
|
+
location = f"{location_data.city}, {location_data.region}, {location_data.country}"
|
175
|
+
location_prompt = prompts.user_location.format(location=location)
|
175
176
|
system_prompt = f"{system_prompt}\n{location_prompt}"
|
176
177
|
|
177
178
|
if user_name:
|
@@ -36,7 +36,7 @@ def extract_questions(
|
|
36
36
|
"""
|
37
37
|
Infer search queries to retrieve relevant notes to answer user query
|
38
38
|
"""
|
39
|
-
location = f"{location_data}" if location_data else "Unknown"
|
39
|
+
location = f"{location_data.city}, {location_data.region}, {location_data.country}" if location_data else "Unknown"
|
40
40
|
username = prompts.user_name.format(name=user.get_full_name()) if user and user.get_full_name() else ""
|
41
41
|
|
42
42
|
# Extract Past User Message and Inferred Questions from Conversation Log
|
@@ -159,7 +159,8 @@ def converse(
|
|
159
159
|
)
|
160
160
|
|
161
161
|
if location_data:
|
162
|
-
|
162
|
+
location = f"{location_data.city}, {location_data.region}, {location_data.country}"
|
163
|
+
location_prompt = prompts.user_location.format(location=location)
|
163
164
|
system_prompt = f"{system_prompt}\n{location_prompt}"
|
164
165
|
|
165
166
|
if user_name:
|
@@ -7,6 +7,7 @@ from collections import defaultdict
|
|
7
7
|
from typing import Callable, Dict, List, Optional, Tuple, Union
|
8
8
|
|
9
9
|
import aiohttp
|
10
|
+
import requests
|
10
11
|
from bs4 import BeautifulSoup
|
11
12
|
from markdownify import markdownify
|
12
13
|
|
@@ -79,7 +80,7 @@ async def search_online(
|
|
79
80
|
|
80
81
|
with timer(f"Internet searches for {list(subqueries)} took", logger):
|
81
82
|
search_func = search_with_google if SERPER_DEV_API_KEY else search_with_jina
|
82
|
-
search_tasks = [search_func(subquery
|
83
|
+
search_tasks = [search_func(subquery) for subquery in subqueries]
|
83
84
|
search_results = await asyncio.gather(*search_tasks)
|
84
85
|
response_dict = {subquery: search_result for subquery, search_result in search_results}
|
85
86
|
|
@@ -114,9 +115,8 @@ async def search_online(
|
|
114
115
|
yield response_dict
|
115
116
|
|
116
117
|
|
117
|
-
async def search_with_google(query: str
|
118
|
-
|
119
|
-
payload = json.dumps({"q": query, "gl": country_code})
|
118
|
+
async def search_with_google(query: str) -> Tuple[str, Dict[str, List[Dict]]]:
|
119
|
+
payload = json.dumps({"q": query})
|
120
120
|
headers = {"X-API-KEY": SERPER_DEV_API_KEY, "Content-Type": "application/json"}
|
121
121
|
|
122
122
|
async with aiohttp.ClientSession() as session:
|
@@ -220,7 +220,7 @@ async def read_webpage_with_jina(web_url: str) -> str:
|
|
220
220
|
return response_json["data"]["content"]
|
221
221
|
|
222
222
|
|
223
|
-
async def search_with_jina(query: str
|
223
|
+
async def search_with_jina(query: str) -> Tuple[str, Dict[str, List[Dict]]]:
|
224
224
|
encoded_query = urllib.parse.quote(query)
|
225
225
|
jina_search_api_url = f"{JINA_SEARCH_API_URL}/{encoded_query}"
|
226
226
|
headers = {"Accept": "application/json"}
|
khoj/routers/api.py
CHANGED
@@ -574,7 +574,7 @@ async def post_automation(
|
|
574
574
|
try:
|
575
575
|
# Use the query to run as the scheduling request if the scheduling request is unset
|
576
576
|
automation = await schedule_automation(
|
577
|
-
query_to_run, subject, crontime, timezone, q, user, calling_url,
|
577
|
+
query_to_run, subject, crontime, timezone, q, user, calling_url, conversation.id
|
578
578
|
)
|
579
579
|
except Exception as e:
|
580
580
|
logger.error(f"Error creating automation {q} for {user.email}: {e}", exc_info=True)
|
@@ -679,7 +679,7 @@ def edit_job(
|
|
679
679
|
# Create new Conversation Session associated with this new task
|
680
680
|
conversation = ConversationAdapters.create_conversation_session(user, request.user.client_app, title=title)
|
681
681
|
|
682
|
-
conversation_id =
|
682
|
+
conversation_id = conversation.id
|
683
683
|
automation_metadata["conversation_id"] = conversation_id
|
684
684
|
|
685
685
|
# Modify automation with updated query, subject
|