Do not version API. Premature given current state of the codebase

- Reason
  - All clients that currently consume the API are part of Khoj
  - Any breaking API changes will be fixed in clients immediately
  - So decoupling client from API is not required
  - This removes the burden of maintaining muliple versions of the API
This commit is contained in:
Debanjum Singh Solanky
2022-10-08 13:16:08 +03:00
parent 2c548133f3
commit d292bdcc11
9 changed files with 34 additions and 34 deletions

View File

@@ -15,23 +15,23 @@ from src.utils.config import SearchType
from src.utils import state, constants
api_v1_0 = APIRouter()
api = APIRouter()
logger = logging.getLogger(__name__)
@api_v1_0.get('/config/data', response_model=FullConfig)
def config_data():
@api.get('/config/data', response_model=FullConfig)
def get_config_data():
return state.config
@api_v1_0.post('/config/data')
async def config_data(updated_config: FullConfig):
@api.post('/config/data')
async def set_config_data(updated_config: FullConfig):
state.config = updated_config
with open(state.config_file, 'w') as outfile:
yaml.dump(yaml.safe_load(state.config.json(by_alias=True)), outfile)
outfile.close()
return state.config
@api_v1_0.get('/search', response_model=list[SearchResponse])
@api.get('/search', response_model=list[SearchResponse])
def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Optional[bool] = False):
results: list[SearchResponse] = []
if q is None or q == '':
@@ -121,7 +121,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti
return results
@api_v1_0.get('/update')
@api.get('/update')
def update(t: Optional[SearchType] = None, force: Optional[bool] = False):
state.model = configure_search(state.model, state.config, regenerate=force, t=t)
return {'status': 'ok', 'message': 'index updated'}

View File

@@ -7,7 +7,7 @@ from typing import Optional
from fastapi import APIRouter
# Internal Packages
from src.routers.api_v1_0 import search
from src.routers.api import search
from src.processor.conversation.gpt import converse, extract_search_type, message_to_log, message_to_prompt, understand, summarize
from src.utils.config import SearchType
from src.utils.helpers import get_absolute_path, get_from_dict