mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Rename API path /api/config to /api/configure
- Update clients calling /api/config to call /api/configure instead
This commit is contained in:
parent
dd31936746
commit
de15a7a3fc
12 changed files with 29 additions and 29 deletions
|
@ -212,7 +212,7 @@
|
|||
const headers = { 'Authorization': `Bearer ${khojToken}` };
|
||||
|
||||
// Populate type dropdown field with enabled content types only
|
||||
fetch(`${hostURL}/api/config/types`, { headers })
|
||||
fetch(`${hostURL}/api/configure/types`, { headers })
|
||||
.then(response => response.json())
|
||||
.then(enabled_types => {
|
||||
// Show warning if no content types are enabled
|
||||
|
|
|
@ -697,7 +697,7 @@ Optionally apply CALLBACK with JSON parsed response and CBARGS."
|
|||
|
||||
(defun khoj--get-enabled-content-types ()
|
||||
"Get content types enabled for search from API."
|
||||
(khoj--call-api "/api/config/types" "GET" nil `(lambda (item) (mapcar #'intern item))))
|
||||
(khoj--call-api "/api/configure/types" "GET" nil `(lambda (item) (mapcar #'intern item))))
|
||||
|
||||
(defun khoj--query-search-api-and-render-results (query content-type buffer-name &optional rerank is-find-similar)
|
||||
"Query Khoj Search API with QUERY, CONTENT-TYPE and RERANK as query params.
|
||||
|
|
|
@ -68,8 +68,8 @@ interface ModelPickerProps {
|
|||
}
|
||||
|
||||
export const ModelPicker: React.FC<any> = (props: ModelPickerProps) => {
|
||||
const { data: models } = useOptionsRequest('/api/config/chat/model/options');
|
||||
const { data: selectedModel } = useSelectedModel('/api/config/chat/model');
|
||||
const { data: models } = useOptionsRequest('/api/configure/chat/model/options');
|
||||
const { data: selectedModel } = useSelectedModel('/api/configure/chat/model');
|
||||
const [openLoginDialog, setOpenLoginDialog] = React.useState(false);
|
||||
|
||||
let userData = useAuthenticatedData();
|
||||
|
@ -94,7 +94,7 @@ export const ModelPicker: React.FC<any> = (props: ModelPickerProps) => {
|
|||
props.setModelUsed(model);
|
||||
}
|
||||
|
||||
fetch('/api/config/chat/model' + '?id=' + String(model.id), { method: 'POST', body: JSON.stringify(model) })
|
||||
fetch('/api/configure/chat/model' + '?id=' + String(model.id), { method: 'POST', body: JSON.stringify(model) })
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to select model');
|
||||
|
|
|
@ -148,7 +148,7 @@ interface FilesMenuProps {
|
|||
|
||||
function FilesMenu(props: FilesMenuProps) {
|
||||
// Use SWR to fetch files
|
||||
const { data: files, error } = useSWR<string[]>(props.conversationId ? '/api/config/content/computer' : null, fetcher);
|
||||
const { data: files, error } = useSWR<string[]>(props.conversationId ? '/api/configure/content/computer' : null, fetcher);
|
||||
const { data: selectedFiles, error: selectedFilesError } = useSWR(props.conversationId ? `/api/chat/conversation/file-filters/${props.conversationId}` : null, fetcher);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [unfilteredFiles, setUnfilteredFiles] = useState<string[]>([]);
|
||||
|
|
|
@ -316,7 +316,7 @@ def configure_routes(app):
|
|||
app.include_router(api, prefix="/api")
|
||||
app.include_router(api_chat, prefix="/api/chat")
|
||||
app.include_router(api_agents, prefix="/api/agents")
|
||||
app.include_router(api_config, prefix="/api/config")
|
||||
app.include_router(api_config, prefix="/api/configure")
|
||||
app.include_router(indexer, prefix="/api/v1/index")
|
||||
app.include_router(notion_router, prefix="/api/notion")
|
||||
app.include_router(web_client)
|
||||
|
@ -336,7 +336,7 @@ def configure_routes(app):
|
|||
if is_twilio_enabled():
|
||||
from khoj.routers.api_phone import api_phone
|
||||
|
||||
app.include_router(api_phone, prefix="/api/config/phone")
|
||||
app.include_router(api_phone, prefix="/api/configure/phone")
|
||||
logger.info("📞 Enabled Twilio")
|
||||
|
||||
|
||||
|
|
|
@ -1954,7 +1954,7 @@ To get started, just start typing below. You can also type / to see a list of co
|
|||
}
|
||||
var allFiles;
|
||||
function renderAllFiles() {
|
||||
fetch('/api/config/content/computer')
|
||||
fetch('/api/configure/content/computer')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
var indexedFiles = document.getElementsByClassName("indexed-files")[0];
|
||||
|
|
|
@ -394,7 +394,7 @@
|
|||
|
||||
function saveProfileGivenName() {
|
||||
const givenName = document.getElementById("profile_given_name").value;
|
||||
fetch('/api/config/user/name?name=' + givenName, {
|
||||
fetch('/api/configure/user/name?name=' + givenName, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -421,7 +421,7 @@
|
|||
saveVoiceModelButton.disabled = true;
|
||||
saveVoiceModelButton.textContent = "Saving...";
|
||||
|
||||
fetch('/api/config/voice/model?id=' + voiceModel, {
|
||||
fetch('/api/configure/voice/model?id=' + voiceModel, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -455,7 +455,7 @@
|
|||
saveModelButton.innerHTML = "";
|
||||
saveModelButton.textContent = "Saving...";
|
||||
|
||||
fetch('/api/config/chat/model?id=' + chatModel, {
|
||||
fetch('/api/configure/chat/model?id=' + chatModel, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -494,7 +494,7 @@
|
|||
saveSearchModelButton.disabled = true;
|
||||
saveSearchModelButton.textContent = "Saving...";
|
||||
|
||||
fetch('/api/config/search/model?id=' + searchModel, {
|
||||
fetch('/api/configure/search/model?id=' + searchModel, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -526,7 +526,7 @@
|
|||
saveModelButton.disabled = true;
|
||||
saveModelButton.innerHTML = "Saving...";
|
||||
|
||||
fetch('/api/config/paint/model?id=' + paintModel, {
|
||||
fetch('/api/configure/paint/model?id=' + paintModel, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -553,7 +553,7 @@
|
|||
};
|
||||
|
||||
function clearContentType(content_source) {
|
||||
fetch('/api/config/content/' + content_source, {
|
||||
fetch('/api/configure/content/' + content_source, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -676,7 +676,7 @@
|
|||
|
||||
content_sources = ["computer", "github", "notion"];
|
||||
content_sources.forEach(content_source => {
|
||||
fetch(`/api/config/content/${content_source}`, {
|
||||
fetch(`/api/configure/content/${content_source}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -807,7 +807,7 @@
|
|||
|
||||
function getIndexedDataSize() {
|
||||
document.getElementById("indexed-data-size").textContent = "Calculating...";
|
||||
fetch('/api/config/content/size')
|
||||
fetch('/api/configure/content/size')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
document.getElementById("indexed-data-size").textContent = data.indexed_data_size_in_mb + " MB used";
|
||||
|
@ -815,7 +815,7 @@
|
|||
}
|
||||
|
||||
function removeFile(path) {
|
||||
fetch('/api/config/content/file?filename=' + path, {
|
||||
fetch('/api/configure/content/file?filename=' + path, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -890,7 +890,7 @@
|
|||
})
|
||||
|
||||
phonenumberRemoveButton.addEventListener("click", () => {
|
||||
fetch('/api/config/phone', {
|
||||
fetch('/api/configure/phone', {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -917,7 +917,7 @@
|
|||
}, 5000);
|
||||
} else {
|
||||
const mobileNumber = iti.getNumber();
|
||||
fetch('/api/config/phone?phone_number=' + mobileNumber, {
|
||||
fetch('/api/configure/phone?phone_number=' + mobileNumber, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -970,7 +970,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
fetch('/api/config/phone/verify?code=' + otp, {
|
||||
fetch('/api/configure/phone/verify?code=' + otp, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</style>
|
||||
<script>
|
||||
function removeFile(path) {
|
||||
fetch('/api/config/content/file?filename=' + path, {
|
||||
fetch('/api/configure/content/file?filename=' + path, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -48,7 +48,7 @@
|
|||
|
||||
// Get all currently indexed files
|
||||
function getAllComputerFilenames() {
|
||||
fetch('/api/config/content/computer')
|
||||
fetch('/api/configure/content/computer')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
var indexedFiles = document.getElementsByClassName("indexed-files")[0];
|
||||
|
@ -122,7 +122,7 @@
|
|||
deleteAllComputerFilesButton.textContent = "🗑️ Deleting...";
|
||||
deleteAllComputerFilesButton.disabled = true;
|
||||
|
||||
fetch('/api/config/content/computer', {
|
||||
fetch('/api/configure/content/computer', {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
|
||||
// Save Github config on server
|
||||
const csrfToken = document.cookie.split('; ').find(row => row.startsWith('csrftoken'))?.split('=')[1];
|
||||
fetch('/api/config/content/github', {
|
||||
fetch('/api/configure/content/github', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
// Save Notion config on server
|
||||
const csrfToken = document.cookie.split('; ').find(row => row.startsWith('csrftoken'))?.split('=')[1];
|
||||
fetch('/api/config/content/notion', {
|
||||
fetch('/api/configure/content/notion', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
@ -209,7 +209,7 @@
|
|||
|
||||
function populate_type_dropdown() {
|
||||
// Populate type dropdown field with enabled content types only
|
||||
fetch("/api/config/types")
|
||||
fetch("/api/configure/types")
|
||||
.then(response => response.json())
|
||||
.then(enabled_types => {
|
||||
// Show warning if no content types are enabled, or just one ("all")
|
||||
|
|
|
@ -269,7 +269,7 @@ def test_get_api_config_types(client, sample_org_data, default_user: KhojUser):
|
|||
text_search.setup(OrgToEntries, sample_org_data, regenerate=False, user=default_user)
|
||||
|
||||
# Act
|
||||
response = client.get(f"/api/config/types", headers=headers)
|
||||
response = client.get(f"/api/configure/types", headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
|
@ -289,7 +289,7 @@ def test_get_configured_types_with_no_content_config(fastapi_app: FastAPI):
|
|||
client = TestClient(fastapi_app)
|
||||
|
||||
# Act
|
||||
response = client.get(f"/api/config/types")
|
||||
response = client.get(f"/api/configure/types")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
|
|
Loading…
Reference in a new issue