khoj 2.0.0b13.dev19__py3-none-any.whl → 2.0.0b14__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/database/admin.py +2 -2
- khoj/interface/compiled/404/index.html +2 -2
- khoj/interface/compiled/_next/static/chunks/{2327-fe87dd989d71d0eb.js → 2327-438aaec1657c5ada.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/{3260-43d3019b92c315bb.js → 3260-82d2521fab032ff1.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/9808-c0742b05e1ef29ba.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/agents/layout-0114c87d7ccf6d9b.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/automations/layout-8639ff99d6c2fec6.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/automations/{page-198b26df6e09bbb0.js → page-1047097af99d31c7.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/layout-2ff3e18a6feae92a.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/chat/page-ac7ed0a1aff1b145.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/search/layout-78dd7cdd97510485.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/share/chat/layout-8addeb8079c3215b.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/share/chat/{page-e0dcb1762f8c8f88.js → page-819c6536c15e3d31.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/{webpack-d60b0c57a6c38d0f.js → webpack-5393aad3d824e0cb.js} +1 -1
- khoj/interface/compiled/_next/static/css/5c7a72bad47e50b3.css +25 -0
- khoj/interface/compiled/_next/static/css/821d0d60b0b6871d.css +1 -0
- khoj/interface/compiled/_next/static/css/ecea704005ba630c.css +1 -0
- khoj/interface/compiled/agents/index.html +2 -2
- khoj/interface/compiled/agents/index.txt +2 -2
- khoj/interface/compiled/automations/index.html +2 -2
- khoj/interface/compiled/automations/index.txt +3 -3
- khoj/interface/compiled/chat/index.html +2 -2
- khoj/interface/compiled/chat/index.txt +5 -4
- khoj/interface/compiled/index.html +2 -2
- khoj/interface/compiled/index.txt +2 -2
- khoj/interface/compiled/search/index.html +2 -2
- khoj/interface/compiled/search/index.txt +2 -2
- khoj/interface/compiled/settings/index.html +2 -2
- khoj/interface/compiled/settings/index.txt +4 -4
- khoj/interface/compiled/share/chat/index.html +2 -2
- khoj/interface/compiled/share/chat/index.txt +2 -2
- khoj/processor/conversation/google/gemini_chat.py +1 -1
- khoj/processor/conversation/google/utils.py +62 -19
- khoj/processor/conversation/openai/gpt.py +65 -28
- khoj/processor/conversation/openai/utils.py +401 -28
- khoj/processor/conversation/prompts.py +48 -30
- khoj/processor/conversation/utils.py +5 -1
- khoj/processor/tools/run_code.py +15 -22
- khoj/routers/api_chat.py +8 -3
- khoj/routers/api_content.py +1 -1
- khoj/routers/helpers.py +62 -42
- khoj/routers/research.py +7 -5
- khoj/utils/constants.py +9 -1
- khoj/utils/helpers.py +55 -15
- {khoj-2.0.0b13.dev19.dist-info → khoj-2.0.0b14.dist-info}/METADATA +1 -1
- {khoj-2.0.0b13.dev19.dist-info → khoj-2.0.0b14.dist-info}/RECORD +58 -58
- khoj/interface/compiled/_next/static/chunks/7127-97b83757db125ba6.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/agents/layout-4e2a134ec26aa606.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/automations/layout-63603d2cb33279f7.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/layout-ad4d1792ab1a4108.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/page-9a75d7369f2a7cd2.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/search/layout-c02531d586972d7d.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/share/chat/layout-e8e5db7830bf3f47.js +0 -1
- khoj/interface/compiled/_next/static/css/23b26df423cd8a9c.css +0 -1
- khoj/interface/compiled/_next/static/css/2945c4a857922f3b.css +0 -1
- khoj/interface/compiled/_next/static/css/3090706713c12a32.css +0 -25
- /khoj/interface/compiled/_next/static/{N-GdBSXoYe-DuObnbXVRO → Qn_2XyeVWxjaIRks7rzM-}/_buildManifest.js +0 -0
- /khoj/interface/compiled/_next/static/{N-GdBSXoYe-DuObnbXVRO → Qn_2XyeVWxjaIRks7rzM-}/_ssgManifest.js +0 -0
- /khoj/interface/compiled/_next/static/chunks/{1327-511bb0a862efce80.js → 1327-e254819a9172cfa7.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{1915-fbfe167c84ad60c5.js → 1915-5c6508f6ebb62a30.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{2117-e78b6902ad6f75ec.js → 2117-080746c8e170c81a.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{2939-4d4084c5b888b960.js → 2939-4af3fd24b8ffc9ad.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{4447-d6cf93724d57e34b.js → 4447-cd95608f8e93e711.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{8667-4b7790573b08c50d.js → 8667-50b03a89e82e0ba7.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{9139-ce1ae935dac9c871.js → 9139-8ac4d9feb10f8869.js} +0 -0
- {khoj-2.0.0b13.dev19.dist-info → khoj-2.0.0b14.dist-info}/WHEEL +0 -0
- {khoj-2.0.0b13.dev19.dist-info → khoj-2.0.0b14.dist-info}/entry_points.txt +0 -0
- {khoj-2.0.0b13.dev19.dist-info → khoj-2.0.0b14.dist-info}/licenses/LICENSE +0 -0
@@ -9,6 +9,9 @@ from khoj.processor.conversation.openai.utils import (
|
|
9
9
|
clean_response_schema,
|
10
10
|
completion_with_backoff,
|
11
11
|
get_structured_output_support,
|
12
|
+
is_openai_api,
|
13
|
+
responses_chat_completion_with_backoff,
|
14
|
+
responses_completion_with_backoff,
|
12
15
|
to_openai_tools,
|
13
16
|
)
|
14
17
|
from khoj.processor.conversation.utils import (
|
@@ -43,31 +46,52 @@ def send_message_to_model(
|
|
43
46
|
model_kwargs: Dict[str, Any] = {}
|
44
47
|
json_support = get_structured_output_support(model, api_base_url)
|
45
48
|
if tools and json_support == StructuredOutputSupport.TOOL:
|
46
|
-
model_kwargs["tools"] = to_openai_tools(tools)
|
49
|
+
model_kwargs["tools"] = to_openai_tools(tools, use_responses_api=is_openai_api(api_base_url))
|
47
50
|
elif response_schema and json_support >= StructuredOutputSupport.SCHEMA:
|
48
51
|
# Drop unsupported fields from schema passed to OpenAI APi
|
49
52
|
cleaned_response_schema = clean_response_schema(response_schema)
|
50
|
-
|
51
|
-
"
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
if is_openai_api(api_base_url):
|
54
|
+
model_kwargs["text"] = {
|
55
|
+
"format": {
|
56
|
+
"type": "json_schema",
|
57
|
+
"strict": True,
|
58
|
+
"name": response_schema.__name__,
|
59
|
+
"schema": cleaned_response_schema,
|
60
|
+
}
|
61
|
+
}
|
62
|
+
else:
|
63
|
+
model_kwargs["response_format"] = {
|
64
|
+
"type": "json_schema",
|
65
|
+
"json_schema": {
|
66
|
+
"schema": cleaned_response_schema,
|
67
|
+
"name": response_schema.__name__,
|
68
|
+
"strict": True,
|
69
|
+
},
|
70
|
+
}
|
58
71
|
elif response_type == "json_object" and json_support == StructuredOutputSupport.OBJECT:
|
59
72
|
model_kwargs["response_format"] = {"type": response_type}
|
60
73
|
|
61
74
|
# Get Response from GPT
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
75
|
+
if is_openai_api(api_base_url):
|
76
|
+
return responses_completion_with_backoff(
|
77
|
+
messages=messages,
|
78
|
+
model_name=model,
|
79
|
+
openai_api_key=api_key,
|
80
|
+
api_base_url=api_base_url,
|
81
|
+
deepthought=deepthought,
|
82
|
+
model_kwargs=model_kwargs,
|
83
|
+
tracer=tracer,
|
84
|
+
)
|
85
|
+
else:
|
86
|
+
return completion_with_backoff(
|
87
|
+
messages=messages,
|
88
|
+
model_name=model,
|
89
|
+
openai_api_key=api_key,
|
90
|
+
api_base_url=api_base_url,
|
91
|
+
deepthought=deepthought,
|
92
|
+
model_kwargs=model_kwargs,
|
93
|
+
tracer=tracer,
|
94
|
+
)
|
71
95
|
|
72
96
|
|
73
97
|
async def converse_openai(
|
@@ -163,13 +187,26 @@ async def converse_openai(
|
|
163
187
|
logger.debug(f"Conversation Context for GPT: {messages_to_print(messages)}")
|
164
188
|
|
165
189
|
# Get Response from GPT
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
190
|
+
if is_openai_api(api_base_url):
|
191
|
+
async for chunk in responses_chat_completion_with_backoff(
|
192
|
+
messages=messages,
|
193
|
+
model_name=model,
|
194
|
+
temperature=temperature,
|
195
|
+
openai_api_key=api_key,
|
196
|
+
api_base_url=api_base_url,
|
197
|
+
deepthought=deepthought,
|
198
|
+
tracer=tracer,
|
199
|
+
):
|
200
|
+
yield chunk
|
201
|
+
else:
|
202
|
+
# For non-OpenAI APIs, use the chat completion method
|
203
|
+
async for chunk in chat_completion_with_backoff(
|
204
|
+
messages=messages,
|
205
|
+
model_name=model,
|
206
|
+
temperature=temperature,
|
207
|
+
openai_api_key=api_key,
|
208
|
+
api_base_url=api_base_url,
|
209
|
+
deepthought=deepthought,
|
210
|
+
tracer=tracer,
|
211
|
+
):
|
212
|
+
yield chunk
|