Repository: khoj-ai/khoj (language: python)

Issue:
[FIX] The chat fails when querying with /notes while running LLAMA3 API
## Describe the bug
Problem: When querying notes: The chat interface is not responding. Backend gives out a lot of error messages.

The setup:
- Self host (localhost)
- LLAMA3 API

This works:
/general How many articles are in Wikipedia?

This fails:
How many articles are in Wikipedia?

When it fails: whenever it needs to query the notes. So specifically telling it not to (/general), then it works.

## To Reproduce
Steps to reproduce the behavior:
- Use LLAMA3 API
- Upload a file
- This chat will fail: How many articles are in Wikipedia?
- This chat works: /general How many articles are in Wikipedia?

## Screenshots
If applicable, add screenshots to help explain your problem.
![image](https://github.com/khoj-ai/khoj/assets/32351181/8422e346-2edd-47f7-8e52-0129cb3f20c9)
![image](https://github.com/khoj-ai/khoj/assets/32351181/5f131098-ec0c-4079-85e3-cbb3bfd265ff)


## Platform
- Server:
    - [ ] Cloud-Hosted (https://app.khoj.dev)
    - [X] Self-Hosted Docker
    - [ ] Self-Hosted Python package
    - [ ] Self-Hosted source code
- Client:
    - [ ] Obsidian
    - [ ] Emacs
    - [ ] Desktop app
    - [X] Web browser
    - [ ] WhatsApp
- OS:
    - [ ] Windows
    - [ ] macOS
    - [X] Linux
    - [ ] Android
    - [ ] iOS

### If self-hosted
- Server Version [e.g. 1.0.1]:
Docker from source, branch master at this commit: 3cfe5aabe5737bd9f9661a441784ff878eff4f23

## Additional context
Add any other context about the problem here.



Discussion / hints:
When I add the OpenAi API (not the OpenAI-compatible LLAMA3 API), then it works properly. 

So the issue appears when the /notes mode is used together with an OpenAi-compatible API.

Thanks for reporting @stevennt , I'll see if I can get a repro of the error on my end. Meanwhile, could you share any stack traces from your local server?

Seems that it is something to do with the tokenizer: Configure tokenizer for unsupported model: llama3-70b-8192 in Khoj settings   


`
myaiabnkhoj-server-1    | [05:56:17.344098] DEBUG    uvicorn.error: < TEXT 'How many      protocol.py:1172
myaiabnkhoj-server-1    |                            items are in wikipedia' [31 bytes]                   
myaiabnkhoj-server-1    | [05:56:17.348774] DEBUG    uvicorn.error: > TEXT '{"type":      protocol.py:1178
myaiabnkhoj-server-1    |                            "status", "message":                                 
myaiabnkhoj-server-1    |                            "**Understanding ...e":                              
myaiabnkhoj-server-1    |                            "application/json"}' [125 bytes]                     
myaiabnkhoj-server-1    | [05:56:17.355892] WARNING  khoj.processor.conversation.utils:       utils.py:217
myaiabnkhoj-server-1    |                            Fallback to default chat model                       
myaiabnkhoj-server-1    |                            tokenizer: None.                                     
myaiabnkhoj-server-1    |                            Configure tokenizer for unsupported                  
myaiabnkhoj-server-1    |                            model: llama3-70b-8192 in Khoj settings              
myaiabnkhoj-server-1    |                            to improve context stuffing.                         
myaiabnkhoj-server-1    | [05:56:17.798986] DEBUG    khoj.processor.conversation.openai before_sleep.py:65
myaiabnkhoj-server-1    |                            .utils: Retrying                                     
myaiabnkhoj-server-1    |                            khoj.processor.conversation.openai                   
myaiabnkhoj-server-1    |                            .utils.completion_with_backoff in                    
myaiabnkhoj-server-1    |                            0.41305954873250217 seconds as it                    
myaiabnkhoj-server-1    |                            raised BadRequestError: Error                        
myaiabnkhoj-server-1    |                            code: 400 - {'error': {'message':                    
myaiabnkhoj-server-1    |                            'response_format` does not support                   
myaiabnkhoj-server-1    |                            streaming', 'type':                                  
myaiabnkhoj-server-1    |                            'invalid_request_error'}}.                           
myaiabnkhoj-server-1    | [05:56:18.498893] DEBUG    khoj.processor.conversation.openai before_sleep.py:65
myaiabnkhoj-server-1    |                            .utils: Retrying                                     
myaiabnkhoj-server-1    |                            khoj.processor.conversation.openai                   
myaiabnkhoj-server-1    |                            .utils.completion_with_backoff in                    
myaiabnkhoj-server-1    |                            0.6010106707150216 seconds as it                     
myaiabnkhoj-server-1    |                            raised BadRequestError: Error                        
myaiabnkhoj-server-1    |                            code: 400 - {'error': {'message':                    
myaiabnkhoj-server-1    |                            'response_format` does not support                   
myaiabnkhoj-server-1    |                            streaming', 'type':                                  
myaiabnkhoj-server-1    |                            'invalid_request_error'}}.                           
myaiabnkhoj-server-1    | [05:56:19.389462] DEBUG    khoj.routers.helpers: Chat actor:      helpers.py:175
myaiabnkhoj-server-1    |                            Infer information sources to refer:                  
myaiabnkhoj-server-1    |                            2.038 seconds                                        
myaiabnkhoj-server-1    | [05:56:19.395893] ERROR    uvicorn.error: Exception in    websockets_impl.py:188
myaiabnkhoj-server-1    |                            ASGI application                                     
myaiabnkhoj-server-1    |                                                                                 
myaiabnkhoj-server-1    |                            ╭─ Traceback (most recent ca─╮                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/uvicorn/prot │                       
myaiabnkhoj-server-1    |                            │ ocols/websockets/websocket │                       
myaiabnkhoj-server-1    |                            │ s_impl.py:184 in run_asgi  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   181 │   │   termination  │                       
myaiabnkhoj-server-1    |                            │   182 │   │   """          │                       
myaiabnkhoj-server-1    |                            │   183 │   │   try:         │                       
myaiabnkhoj-server-1    |                            │ ❱ 184 │   │   │   result = │                       
myaiabnkhoj-server-1    |                            │   185 │   │   except BaseE │                       
myaiabnkhoj-server-1    |                            │   186 │   │   │   self.clo │                       
myaiabnkhoj-server-1    |                            │   187 │   │   │   msg = "E │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/uvicorn/midd │                       
myaiabnkhoj-server-1    |                            │ leware/proxy_headers.py:75 │                       
myaiabnkhoj-server-1    |                            │  in __call__               │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   72 │   │   │   │   │   p │                       
myaiabnkhoj-server-1    |                            │   73 │   │   │   │   │   s │                       
myaiabnkhoj-server-1    |                            │   74 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 75 │   │   return await  │                       
myaiabnkhoj-server-1    |                            │   76                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/fastapi/appl │                       
myaiabnkhoj-server-1    |                            │ ications.py:1054 in        │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1051 │   async def __cal │                       
myaiabnkhoj-server-1    |                            │   1052 │   │   if self.roo │                       
myaiabnkhoj-server-1    |                            │   1053 │   │   │   scope[" │                       
myaiabnkhoj-server-1    |                            │ ❱ 1054 │   │   await super │                       
myaiabnkhoj-server-1    |                            │   1055 │                   │                       
myaiabnkhoj-server-1    |                            │   1056 │   def add_api_rou │                       
myaiabnkhoj-server-1    |                            │   1057 │   │   self,       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ap │                       
myaiabnkhoj-server-1    |                            │ plications.py:123 in       │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   120 │   │   scope["app"] │                       
myaiabnkhoj-server-1    |                            │   121 │   │   if self.midd │                       
myaiabnkhoj-server-1    |                            │   122 │   │   │   self.mid │                       
myaiabnkhoj-server-1    |                            │ ❱ 123 │   │   await self.m │                       
myaiabnkhoj-server-1    |                            │   124 │                    │                       
myaiabnkhoj-server-1    |                            │   125 │   def on_event(sel │                       
myaiabnkhoj-server-1    |                            │   126 │   │   return self. │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/errors.py:151 in  │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   148 │                    │                       
myaiabnkhoj-server-1    |                            │   149 │   async def __call │                       
myaiabnkhoj-server-1    |                            │   150 │   │   if scope["ty │                       
myaiabnkhoj-server-1    |                            │ ❱ 151 │   │   │   await se │                       
myaiabnkhoj-server-1    |                            │   152 │   │   │   return   │                       
myaiabnkhoj-server-1    |                            │   153 │   │                │                       
myaiabnkhoj-server-1    |                            │   154 │   │   response_sta │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/sessions.py:85 in │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   82 │   │   │   │   │   h │                       
myaiabnkhoj-server-1    |                            │   83 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   84 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 85 │   │   await self.ap │                       
myaiabnkhoj-server-1    |                            │   86                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/authentication.py │                       
myaiabnkhoj-server-1    |                            │ :49 in __call__            │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   46 │   │   if auth_resul │                       
myaiabnkhoj-server-1    |                            │   47 │   │   │   auth_resu │                       
myaiabnkhoj-server-1    |                            │   48 │   │   scope["auth"] │                       
myaiabnkhoj-server-1    |                            │ ❱ 49 │   │   await self.ap │                       
myaiabnkhoj-server-1    |                            │   50 │                     │                       
myaiabnkhoj-server-1    |                            │   51 │   @staticmethod     │                       
myaiabnkhoj-server-1    |                            │   52 │   def default_on_er │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/cors.py:77 in     │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    74 │                    │                       
myaiabnkhoj-server-1    |                            │    75 │   async def __call │                       
myaiabnkhoj-server-1    |                            │    76 │   │   if scope["ty │                       
myaiabnkhoj-server-1    |                            │ ❱  77 │   │   │   await se │                       
myaiabnkhoj-server-1    |                            │    78 │   │   │   return   │                       
myaiabnkhoj-server-1    |                            │    79 │   │                │                       
myaiabnkhoj-server-1    |                            │    80 │   │   method = sco │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/exceptions.py:65  │                       
myaiabnkhoj-server-1    |                            │ in __call__                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   62 │   │   else:         │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   conn = We │                       
myaiabnkhoj-server-1    |                            │   64 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 65 │   │   await wrap_ap │                       
myaiabnkhoj-server-1    |                            │   66 │                     │                       
myaiabnkhoj-server-1    |                            │   67 │   def http_exceptio │                       
myaiabnkhoj-server-1    |                            │   68 │   │   assert isinst │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:64 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   61 │   │   │   │   handl │                       
myaiabnkhoj-server-1    |                            │   62 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   if handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 64 │   │   │   │   raise │                       
myaiabnkhoj-server-1    |                            │   65 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   66 │   │   │   if respon │                       
myaiabnkhoj-server-1    |                            │   67 │   │   │   │   msg = │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:53 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   50 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   51 │   │                 │                       
myaiabnkhoj-server-1    |                            │   52 │   │   try:          │                       
myaiabnkhoj-server-1    |                            │ ❱ 53 │   │   │   await app │                       
myaiabnkhoj-server-1    |                            │   54 │   │   except Except │                       
myaiabnkhoj-server-1    |                            │   55 │   │   │   handler = │                       
myaiabnkhoj-server-1    |                            │   56                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:756 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   753 │   │   """          │                       
myaiabnkhoj-server-1    |                            │   754 │   │   The main ent │                       
myaiabnkhoj-server-1    |                            │   755 │   │   """          │                       
myaiabnkhoj-server-1    |                            │ ❱ 756 │   │   await self.m │                       
myaiabnkhoj-server-1    |                            │   757 │                    │                       
myaiabnkhoj-server-1    |                            │   758 │   async def app(se │                       
myaiabnkhoj-server-1    |                            │   759 │   │   assert scope │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:776 in app        │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   773 │   │   │   match, c │                       
myaiabnkhoj-server-1    |                            │   774 │   │   │   if match │                       
myaiabnkhoj-server-1    |                            │   775 │   │   │   │   scop │                       
myaiabnkhoj-server-1    |                            │ ❱ 776 │   │   │   │   awai │                       
myaiabnkhoj-server-1    |                            │   777 │   │   │   │   retu │                       
myaiabnkhoj-server-1    |                            │   778 │   │   │   elif mat │                       
myaiabnkhoj-server-1    |                            │   779 │   │   │   │   part │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:373 in handle     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   370 │   │   return URLPa │                       
myaiabnkhoj-server-1    |                            │   371 │                    │                       
myaiabnkhoj-server-1    |                            │   372 │   async def handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 373 │   │   await self.a │                       
myaiabnkhoj-server-1    |                            │   374 │                    │                       
myaiabnkhoj-server-1    |                            │   375 │   def __eq__(self, │                       
myaiabnkhoj-server-1    |                            │   376 │   │   return (     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:96 in app         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    93 │   │   async def ap │                       
myaiabnkhoj-server-1    |                            │    94 │   │   │   await fu │                       
myaiabnkhoj-server-1    |                            │    95 │   │                │                       
myaiabnkhoj-server-1    |                            │ ❱  96 │   │   await wrap_a │                       
myaiabnkhoj-server-1    |                            │    97 │                    │                       
myaiabnkhoj-server-1    |                            │    98 │   return app       │                       
myaiabnkhoj-server-1    |                            │    99                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:64 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   61 │   │   │   │   handl │                       
myaiabnkhoj-server-1    |                            │   62 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   if handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 64 │   │   │   │   raise │                       
myaiabnkhoj-server-1    |                            │   65 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   66 │   │   │   if respon │                       
myaiabnkhoj-server-1    |                            │   67 │   │   │   │   msg = │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:53 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   50 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   51 │   │                 │                       
myaiabnkhoj-server-1    |                            │   52 │   │   try:          │                       
myaiabnkhoj-server-1    |                            │ ❱ 53 │   │   │   await app │                       
myaiabnkhoj-server-1    |                            │   54 │   │   except Except │                       
myaiabnkhoj-server-1    |                            │   55 │   │   │   handler = │                       
myaiabnkhoj-server-1    |                            │   56                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:94 in app         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    91 │   │   session = We │                       
myaiabnkhoj-server-1    |                            │    92 │   │                │                       
myaiabnkhoj-server-1    |                            │    93 │   │   async def ap │                       
myaiabnkhoj-server-1    |                            │ ❱  94 │   │   │   await fu │                       
myaiabnkhoj-server-1    |                            │    95 │   │                │                       
myaiabnkhoj-server-1    |                            │    96 │   │   await wrap_a │                       
myaiabnkhoj-server-1    |                            │    97                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/fastapi/rout │                       
myaiabnkhoj-server-1    |                            │ ing.py:348 in app          │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    345 │   │   │   if erro │                       
myaiabnkhoj-server-1    |                            │    346 │   │   │   │   rai │                       
myaiabnkhoj-server-1    |                            │    347 │   │   │   assert  │                       
myaiabnkhoj-server-1    |                            │ ❱  348 │   │   │   await d │                       
myaiabnkhoj-server-1    |                            │    349 │                   │                       
myaiabnkhoj-server-1    |                            │    350 │   return app      │                       
myaiabnkhoj-server-1    |                            │    351                     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/api_ │                       
myaiabnkhoj-server-1    |                            │ chat.py:578 in             │                       
myaiabnkhoj-server-1    |                            │ websocket_endpoint         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    575 │   │   is_automate │                       
myaiabnkhoj-server-1    |                            │    576 │   │               │                       
myaiabnkhoj-server-1    |                            │    577 │   │   if conversa │                       
myaiabnkhoj-server-1    |                            │ ❱  578 │   │   │   convers │                       
myaiabnkhoj-server-1    |                            │        is_automated_task)  │                       
myaiabnkhoj-server-1    |                            │    579 │   │   │   convers │                       
myaiabnkhoj-server-1    |                            │        conversation_comman │                       
myaiabnkhoj-server-1    |                            │    580 │   │   │   await s │                       
myaiabnkhoj-server-1    |                            │        {conversation_comma │                       
myaiabnkhoj-server-1    |                            │    581                     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/help │                       
myaiabnkhoj-server-1    |                            │ ers.py:250 in              │                       
myaiabnkhoj-server-1    |                            │ aget_relevant_information_ │                       
myaiabnkhoj-server-1    |                            │ sources                    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    247 │   )               │                       
myaiabnkhoj-server-1    |                            │    248 │                   │                       
myaiabnkhoj-server-1    |                            │    249 │   with timer("Cha │                       
myaiabnkhoj-server-1    |                            │ ❱  250 │   │   response =  │                       
myaiabnkhoj-server-1    |                            │        response_type="json │                       
myaiabnkhoj-server-1    |                            │    251 │                   │                       
myaiabnkhoj-server-1    |                            │    252 │   try:            │                       
myaiabnkhoj-server-1    |                            │    253 │   │   response =  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/help │                       
myaiabnkhoj-server-1    |                            │ ers.py:547 in              │                       
myaiabnkhoj-server-1    |                            │ send_message_to_model_wrap │                       
myaiabnkhoj-server-1    |                            │ per                        │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    544 │   │   │   tokeniz │                       
myaiabnkhoj-server-1    |                            │    545 │   │   )           │                       
myaiabnkhoj-server-1    |                            │    546 │   │               │                       
myaiabnkhoj-server-1    |                            │ ❱  547 │   │   openai_resp │                       
myaiabnkhoj-server-1    |                            │    548 │   │   │   message │                       
myaiabnkhoj-server-1    |                            │    549 │   │   │   api_key │                       
myaiabnkhoj-server-1    |                            │    550 │   │   │   model=c │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/processor/co │                       
myaiabnkhoj-server-1    |                            │ nversation/openai/gpt.py:9 │                       
myaiabnkhoj-server-1    |                            │ 8 in send_message_to_model │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    95 │   """              │                       
myaiabnkhoj-server-1    |                            │    96 │                    │                       
myaiabnkhoj-server-1    |                            │    97 │   # Get Response f │                       
myaiabnkhoj-server-1    |                            │ ❱  98 │   return completio │                       
myaiabnkhoj-server-1    |                            │    99 │   │   messages=mes │                       
myaiabnkhoj-server-1    |                            │   100 │   │   model=model, │                       
myaiabnkhoj-server-1    |                            │   101 │   │   openai_api_k │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:330 in wrapped_f  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   327 │   │   │   f, funct │                       
myaiabnkhoj-server-1    |                            │   328 │   │   )            │                       
myaiabnkhoj-server-1    |                            │   329 │   │   def wrapped_ │                       
myaiabnkhoj-server-1    |                            │ ❱ 330 │   │   │   return s │                       
myaiabnkhoj-server-1    |                            │   331 │   │                │                       
myaiabnkhoj-server-1    |                            │   332 │   │   def retry_wi │                       
myaiabnkhoj-server-1    |                            │   333 │   │   │   return s │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:467 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   464 │   │                │                       
myaiabnkhoj-server-1    |                            │   465 │   │   retry_state  │                       
myaiabnkhoj-server-1    |                            │   466 │   │   while True:  │                       
myaiabnkhoj-server-1    |                            │ ❱ 467 │   │   │   do = sel │                       
myaiabnkhoj-server-1    |                            │   468 │   │   │   if isins │                       
myaiabnkhoj-server-1    |                            │   469 │   │   │   │   try: │                       
myaiabnkhoj-server-1    |                            │   470 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:368 in iter       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   365 │   │   self._begin_ │                       
myaiabnkhoj-server-1    |                            │   366 │   │   result = Non │                       
myaiabnkhoj-server-1    |                            │   367 │   │   for action i │                       
myaiabnkhoj-server-1    |                            │ ❱ 368 │   │   │   result = │                       
myaiabnkhoj-server-1    |                            │   369 │   │   return resul │                       
myaiabnkhoj-server-1    |                            │   370 │                    │                       
myaiabnkhoj-server-1    |                            │   371 │   def _begin_iter( │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:410 in exc_check  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   407 │   │   │   │   fut  │                       
myaiabnkhoj-server-1    |                            │   408 │   │   │   │   retr │                       
myaiabnkhoj-server-1    |                            │   409 │   │   │   │   if s │                       
myaiabnkhoj-server-1    |                            │ ❱ 410 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   411 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │   412 │   │   │            │                       
myaiabnkhoj-server-1    |                            │   413 │   │   │   self._ad │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:183 in reraise    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   180 │                    │                       
myaiabnkhoj-server-1    |                            │   181 │   def reraise(self │                       
myaiabnkhoj-server-1    |                            │   182 │   │   if self.last │                       
myaiabnkhoj-server-1    |                            │ ❱ 183 │   │   │   raise se │                       
myaiabnkhoj-server-1    |                            │   184 │   │   raise self   │                       
myaiabnkhoj-server-1    |                            │   185 │                    │                       
myaiabnkhoj-server-1    |                            │   186 │   def __str__(self │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/lib/python3.10/concur │                       
myaiabnkhoj-server-1    |                            │ rent/futures/_base.py:451  │                       
myaiabnkhoj-server-1    |                            │ in result                  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   448 │   │   │   │   if s │                       
myaiabnkhoj-server-1    |                            │   449 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   450 │   │   │   │   elif │                       
myaiabnkhoj-server-1    |                            │ ❱ 451 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   452 │   │   │   │        │                       
myaiabnkhoj-server-1    |                            │   453 │   │   │   │   self │                       
myaiabnkhoj-server-1    |                            │   454                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/lib/python3.10/concur │                       
myaiabnkhoj-server-1    |                            │ rent/futures/_base.py:403  │                       
myaiabnkhoj-server-1    |                            │ in __get_result            │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   400 │   def __get_result │                       
myaiabnkhoj-server-1    |                            │   401 │   │   if self._exc │                       
myaiabnkhoj-server-1    |                            │   402 │   │   │   try:     │                       
myaiabnkhoj-server-1    |                            │ ❱ 403 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │   404 │   │   │   finally: │                       
myaiabnkhoj-server-1    |                            │   405 │   │   │   │   # Br │                       
myaiabnkhoj-server-1    |                            │   406 │   │   │   │   self │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:470 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   467 │   │   │   do = sel │                       
myaiabnkhoj-server-1    |                            │   468 │   │   │   if isins │                       
myaiabnkhoj-server-1    |                            │   469 │   │   │   │   try: │                       
myaiabnkhoj-server-1    |                            │ ❱ 470 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   471 │   │   │   │   exce │                       
myaiabnkhoj-server-1    |                            │   472 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   473 │   │   │   │   else │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/processor/co │                       
myaiabnkhoj-server-1    |                            │ nversation/openai/utils.py │                       
myaiabnkhoj-server-1    |                            │ :50 in                     │                       
myaiabnkhoj-server-1    |                            │ completion_with_backoff    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    47 │                    │                       
myaiabnkhoj-server-1    |                            │    48 │   formatted_messag │                       
myaiabnkhoj-server-1    |                            │       in messages]         │                       
myaiabnkhoj-server-1    |                            │    49 │                    │                       
myaiabnkhoj-server-1    |                            │ ❱  50 │   chat = client.ch │                       
myaiabnkhoj-server-1    |                            │    51 │   │   stream=True, │                       
myaiabnkhoj-server-1    |                            │    52 │   │   messages=for │                       
myaiabnkhoj-server-1    |                            │    53 │   │   model=model, │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_util │                       
myaiabnkhoj-server-1    |                            │ s/_utils.py:277 in wrapper │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   274 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   275 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   276 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │ ❱ 277 │   │   │   return f │                       
myaiabnkhoj-server-1    |                            │   278 │   │                │                       
myaiabnkhoj-server-1    |                            │   279 │   │   return wrapp │                       
myaiabnkhoj-server-1    |                            │   280                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/resou │                       
myaiabnkhoj-server-1    |                            │ rces/chat/completions.py:6 │                       
myaiabnkhoj-server-1    |                            │ 40 in create               │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    637 │   │   extra_body: │                       
myaiabnkhoj-server-1    |                            │    638 │   │   timeout: fl │                       
myaiabnkhoj-server-1    |                            │    639 │   ) -> ChatComple │                       
myaiabnkhoj-server-1    |                            │ ❱  640 │   │   return self │                       
myaiabnkhoj-server-1    |                            │    641 │   │   │   "/chat/ │                       
myaiabnkhoj-server-1    |                            │    642 │   │   │   body=ma │                       
myaiabnkhoj-server-1    |                            │    643 │   │   │   │   {   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:1250 in post    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1247 │   │   opts = Fina │                       
myaiabnkhoj-server-1    |                            │   1248 │   │   │   method= │                       
myaiabnkhoj-server-1    |                            │        **options           │                       
myaiabnkhoj-server-1    |                            │   1249 │   │   )           │                       
myaiabnkhoj-server-1    |                            │ ❱ 1250 │   │   return cast │                       
myaiabnkhoj-server-1    |                            │        stream_cls=stream_c │                       
myaiabnkhoj-server-1    |                            │   1251 │                   │                       
myaiabnkhoj-server-1    |                            │   1252 │   def patch(      │                       
myaiabnkhoj-server-1    |                            │   1253 │   │   self,       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:931 in request  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    928 │   │   stream: boo │                       
myaiabnkhoj-server-1    |                            │    929 │   │   stream_cls: │                       
myaiabnkhoj-server-1    |                            │    930 │   ) -> ResponseT  │                       
myaiabnkhoj-server-1    |                            │ ❱  931 │   │   return self │                       
myaiabnkhoj-server-1    |                            │    932 │   │   │   cast_to │                       
myaiabnkhoj-server-1    |                            │    933 │   │   │   options │                       
myaiabnkhoj-server-1    |                            │    934 │   │   │   stream= │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:1030 in         │                       
myaiabnkhoj-server-1    |                            │ _request                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1027 │   │   │   │   err │                       
myaiabnkhoj-server-1    |                            │   1028 │   │   │           │                       
myaiabnkhoj-server-1    |                            │   1029 │   │   │   log.deb │                       
myaiabnkhoj-server-1    |                            │ ❱ 1030 │   │   │   raise s │                       
myaiabnkhoj-server-1    |                            │   1031 │   │               │                       
myaiabnkhoj-server-1    |                            │   1032 │   │   return self │                       
myaiabnkhoj-server-1    |                            │   1033 │   │   │   cast_to │                       
myaiabnkhoj-server-1    |                            ╰────────────────────────────╯                       
myaiabnkhoj-server-1    |                            BadRequestError: Error code:                         
myaiabnkhoj-server-1    |                            400 - {'error': {'message':                          
myaiabnkhoj-server-1    |                            'response_format` does not                           
myaiabnkhoj-server-1    |                            support streaming', 'type':                          
myaiabnkhoj-server-1    |                            'invalid_request_error'}}                            
myaiabnkhoj-server-1    | [05:56:20.452685] DEBUG    uvicorn.error: = connection is       protocol.py:1227
myaiabnkhoj-server-1    |                            CLOSING                                              
myaiabnkhoj-server-1    | [05:56:20.453936] DEBUG    uvicorn.error: > CLOSE 1000 (OK) [2  protocol.py:1178
myaiabnkhoj-server-1    |                            bytes]                                               
myaiabnkhoj-server-1    | [05:56:20.455200] DEBUG    uvicorn.error: = connection is       protocol.py:1497
myaiabnkhoj-server-1    |                            CLOSED                                               
myaiabnkhoj-server-1    | [05:56:20.457202] DEBUG    uvicorn.error: ! failing connection  protocol.py:1412
myaiabnkhoj-server-1    |                            with code 1006                                       
myaiabnkhoj-server-1    | [05:56:20.459085] ERROR    uvicorn.error: closing handshake failed server.py:248
myaiabnkhoj-server-1    |                            ╭─ Traceback (most recent call last) ─╮              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/server.py:24 │              
myaiabnkhoj-server-1    |                            │ 4 in handler                        │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    241 │   │   │   │   raise        │              
myaiabnkhoj-server-1    |                            │    242 │   │   │                    │              
myaiabnkhoj-server-1    |                            │    243 │   │   │   try:             │              
myaiabnkhoj-server-1    |                            │ ❱  244 │   │   │   │   await self.c │              
myaiabnkhoj-server-1    |                            │    245 │   │   │   except Connectio │              
myaiabnkhoj-server-1    |                            │    246 │   │   │   │   raise        │              
myaiabnkhoj-server-1    |                            │    247 │   │   │   except Exception │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 770 in close                        │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    767 │   │   """                  │              
myaiabnkhoj-server-1    |                            │    768 │   │   try:                 │              
myaiabnkhoj-server-1    |                            │    769 │   │   │   async with async │              
myaiabnkhoj-server-1    |                            │ ❱  770 │   │   │   │   await self.w │              
myaiabnkhoj-server-1    |                            │    771 │   │   except asyncio.Timeo │              
myaiabnkhoj-server-1    |                            │    772 │   │   │   # If the close f │              
myaiabnkhoj-server-1    |                            │    773 │   │   │   # are full, the  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1236 in write_close_frame           │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1233 │   │   │   │   data = close │              
myaiabnkhoj-server-1    |                            │   1234 │   │   │                    │              
myaiabnkhoj-server-1    |                            │   1235 │   │   │   # 7.1.2. Start t │              
myaiabnkhoj-server-1    |                            │ ❱ 1236 │   │   │   await self.write │              
myaiabnkhoj-server-1    |                            │   1237 │                            │              
myaiabnkhoj-server-1    |                            │   1238 │   async def keepalive_ping │              
myaiabnkhoj-server-1    |                            │   1239 │   │   """                  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1209 in write_frame                 │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1206 │   │   │   │   f"Cannot wri │              
myaiabnkhoj-server-1    |                            │   1207 │   │   │   )                │              
myaiabnkhoj-server-1    |                            │   1208 │   │   self.write_frame_syn │              
myaiabnkhoj-server-1    |                            │ ❱ 1209 │   │   await self.drain()   │              
myaiabnkhoj-server-1    |                            │   1210 │                            │              
myaiabnkhoj-server-1    |                            │   1211 │   async def write_close_fr │              
myaiabnkhoj-server-1    |                            │   1212 │   │   self, close: Close,  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1198 in drain                       │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1195 │   │   │   self.fail_connec │              
myaiabnkhoj-server-1    |                            │   1196 │   │   │   # Wait until the │              
myaiabnkhoj-server-1    |                            │   1197 │   │   │   # with the corre │              
myaiabnkhoj-server-1    |                            │ ❱ 1198 │   │   │   await self.ensur │              
myaiabnkhoj-server-1    |                            │   1199 │                            │              
myaiabnkhoj-server-1    |                            │   1200 │   async def write_frame(   │              
myaiabnkhoj-server-1    |                            │   1201 │   │   self, fin: bool, opc │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 939 in ensure_open                  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    936 │   │   │   │   return       │              
myaiabnkhoj-server-1    |                            │    937 │   │                        │              
myaiabnkhoj-server-1    |                            │    938 │   │   if self.state is Sta │              
myaiabnkhoj-server-1    |                            │ ❱  939 │   │   │   raise self.conne │              
myaiabnkhoj-server-1    |                            │    940 │   │                        │              
myaiabnkhoj-server-1    |                            │    941 │   │   if self.state is Sta │              
myaiabnkhoj-server-1    |                            │    942 │   │   │   # If we started  │              
myaiabnkhoj-server-1    |                            ╰─────────────────────────────────────╯              
myaiabnkhoj-server-1    |                            ConnectionClosedError: sent 1000 (OK);               
myaiabnkhoj-server-1    |                            no close frame received                              
myaiabnkhoj-server-1    | [05:56:20.763183] INFO     uvicorn.error: connection closed        server.py:264
myaiabnkhoj-server-1    | [05:56:20.764402] DEBUG    uvicorn.error: x half-closing TCP    protocol.py:1319
myaiabnkhoj-server-1    |                            connection                                           




`
Awesome, this is really helpful, thanks for including it. Will see if I can get it resolved today.
Thanks for the helpful report @stevennt ! I've pushed a fix. It'll be included in the next release (~1 week). If you want the fix sooner and you're using the docker image, you can build from the `pre` tag when the image finishes building (~20 minutes from now).
I just pulled the master branch which has the below commit fix. The issue still persists. @sabaimran 

![image](https://github.com/khoj-ai/khoj/assets/32351181/c19ab382-10c8-4e1a-a0ee-ee27a7243b64)


https://github.com/khoj-ai/khoj/commit/d3c0111121ec3d2d68ea0181a3a93ecd2641e676


How are you running the project? Straight from source? Or from the docker image? 

You're seeing the exact same stack trace? 
What I did was to pull the source, run docker-compose build, docker-compose down -v, and docker-compose up.
Then I setup the configs at server admin.
First:
![image](https://github.com/khoj-ai/khoj/assets/32351181/47588582-9d06-4521-8aa5-69dad290b4b3)
then:
![image](https://github.com/khoj-ai/khoj/assets/32351181/9eaad477-35f3-47ba-9526-a2df570082c6)

Maybe something needs to be set at this tokenizer field?

![image](https://github.com/khoj-ai/khoj/assets/32351181/0c31efc6-8080-4d7e-bb5c-b090dd1ab020)
![image](https://github.com/khoj-ai/khoj/assets/32351181/de8b33ad-2f8c-4b9e-8483-ac6159ba5ed9)


Below is the stack trace:

`
docker-compose up
[+] Running 2/0
 ⠿ Container myaiabnkhoj-database-1  Created                                                                                                                                                                                                                                                                                                                       0.0s
 ⠿ Container myaiabnkhoj-server-1    Created                                                                                                                                                                                                                                                                                                                       0.0s
Attaching to myaiabnkhoj-database-1, myaiabnkhoj-server-1
myaiabnkhoj-database-1  | 
myaiabnkhoj-database-1  | PostgreSQL Database directory appears to contain a database; Skipping initialization
myaiabnkhoj-database-1  | 
myaiabnkhoj-database-1  | 2024-06-21 07:58:14.007 UTC [1] LOG:  starting PostgreSQL 15.4 (Debian 15.4-2.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
myaiabnkhoj-database-1  | 2024-06-21 07:58:14.007 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
myaiabnkhoj-database-1  | 2024-06-21 07:58:14.007 UTC [1] LOG:  listening on IPv6 address "::", port 5432
myaiabnkhoj-database-1  | 2024-06-21 07:58:14.173 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
myaiabnkhoj-database-1  | 2024-06-21 07:58:14.367 UTC [28] LOG:  database system was shut down at 2024-06-21 07:58:05 UTC
myaiabnkhoj-database-1  | 2024-06-21 07:58:14.487 UTC [1] LOG:  database system is ready to accept connections
myaiabnkhoj-server-1    | [07:58:49.489205] WARNING  khoj.routers.email: RESEND_API_KEY not    email.py:26
myaiabnkhoj-server-1    |                            set - email sending disabled                         
myaiabnkhoj-server-1    | [07:58:49.529753] INFO     khoj: 🚒 Initializing ABNCopilot v0.0.0   main.py:124
myaiabnkhoj-server-1    | [07:58:49.531214] INFO     khoj: 📦 Initializing DB:                 main.py:125
myaiabnkhoj-server-1    |                            Operations to perform:                               
myaiabnkhoj-server-1    |                              Apply all migrations: admin, auth,                 
myaiabnkhoj-server-1    |                            contenttypes, database,                              
myaiabnkhoj-server-1    |                            django_apscheduler, sessions                         
myaiabnkhoj-server-1    |                            Running migrations:                                  
myaiabnkhoj-server-1    |                              No migrations to apply.                            
myaiabnkhoj-server-1    | [07:58:49.533447] DEBUG    khoj: 🌍 Initializing Web Client:         main.py:126
myaiabnkhoj-server-1    |                            0 static files copied to                             
myaiabnkhoj-server-1    |                            '/app/src/khoj/static', 201 unmodified.              
myaiabnkhoj-server-1    | [07:58:49.539414] INFO     khoj: 🌘 Starting Khoj                    main.py:138
myaiabnkhoj-server-1    | [07:58:49.829809] INFO     khoj.configure: 🚨 Khoj is not       configure.py:198
myaiabnkhoj-server-1    |                            configured.                                          
myaiabnkhoj-server-1    |                            Initializing it with a default                       
myaiabnkhoj-server-1    |                            config.                                              
myaiabnkhoj-server-1    | /usr/local/lib/python3.10/dist-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
myaiabnkhoj-server-1    |   warnings.warn(





myaiabnkhoj-server-1    | [08:00:03.609363] INFO     khoj.database.adapters: No default    __init__.py:558
myaiabnkhoj-server-1    |                            conversation config found, skipping                  
myaiabnkhoj-server-1    |                            default agent creation                               
myaiabnkhoj-server-1    | [08:00:03.610718] INFO     khoj.configure: 📡 Telemetry enabled configure.py:240
myaiabnkhoj-server-1    | [08:00:03.611839] INFO     khoj: 🌖 ABN Copilot is ready to use      main.py:190
myaiabnkhoj-server-1    | [08:00:03.624946] INFO     uvicorn.error: Started server process    server.py:75
myaiabnkhoj-server-1    |                            [1]                                                  
myaiabnkhoj-server-1    | [08:00:03.626195] INFO     uvicorn.error: Waiting for application       on.py:45
myaiabnkhoj-server-1    |                            startup.                                             
myaiabnkhoj-server-1    | [08:00:03.627583] INFO     uvicorn.error: Application startup complete. on.py:59
myaiabnkhoj-server-1    | [08:00:03.629082] INFO     uvicorn.error: Uvicorn running on       server.py:206
myaiabnkhoj-server-1    |                            http://0.0.0.0:42110 (Press CTRL+C to                
myaiabnkhoj-server-1    |                            quit)                                                



myaiabnkhoj-server-1    | [08:04:47.153646] DEBUG    uvicorn.error: < TEXT 'What are the  protocol.py:1172
myaiabnkhoj-server-1    |                            number of articles in Wikipedia?'                    
myaiabnkhoj-server-1    |                            [45 bytes]                                           
myaiabnkhoj-server-1    | [08:04:47.160158] DEBUG    uvicorn.error: > TEXT '{"type":      protocol.py:1178
myaiabnkhoj-server-1    |                            "status", "message":                                 
myaiabnkhoj-server-1    |                            "**Understanding ...e":                              
myaiabnkhoj-server-1    |                            "application/json"}' [139 bytes]                     
myaiabnkhoj-server-1    | [08:04:49.544382] INFO     khoj.configure: 📡 Uploading         configure.py:353
myaiabnkhoj-server-1    |                            telemetry to                                         
myaiabnkhoj-server-1    |                            https://khoj.beta.haletic.com/v1/tel                 
myaiabnkhoj-server-1    |                            emetry...                                            
myaiabnkhoj-server-1    | [08:04:49.550244] DEBUG    khoj.configure: Telemetry state:     configure.py:354
myaiabnkhoj-server-1    |                            [{'telemetry_type': 'api',                           
myaiabnkhoj-server-1    |                            'server_version': '0.0.0', 'os':                     
myaiabnkhoj-server-1    |                            'Linux', 'timestamp': '2024-06-21                    
myaiabnkhoj-server-1    |                            08:03:59', 'client_host':                            
myaiabnkhoj-server-1    |                            '172.26.0.1', 'user_agent':                          
myaiabnkhoj-server-1    |                            'unknown', 'referer': 'unknown',                     
myaiabnkhoj-server-1    |                            'host': 'unknown', 'server_id':                      
myaiabnkhoj-server-1    |                            '26485c08-2711-4a10-9a5f-b96e41e1e2a                 
myaiabnkhoj-server-1    |                            d', 'subscription_type': 'standard',                 
myaiabnkhoj-server-1    |                            'is_recurring': False, 'client_id':                  
myaiabnkhoj-server-1    |                            'default', 'api':                                    
myaiabnkhoj-server-1    |                            'get_all_filenames'},                                
myaiabnkhoj-server-1    |                            {'telemetry_type': 'api',                            
myaiabnkhoj-server-1    |                            'server_version': '0.0.0', 'os':                     
myaiabnkhoj-server-1    |                            'Linux', 'timestamp': '2024-06-21                    
myaiabnkhoj-server-1    |                            08:03:59', 'client_host':                            
myaiabnkhoj-server-1    |                            '172.26.0.1', 'user_agent':                          
myaiabnkhoj-server-1    |                            'Mozilla/5.0 (X11; Linux x86_64)                     
myaiabnkhoj-server-1    |                            AppleWebKit/537.36 (KHTML, like                      
myaiabnkhoj-server-1    |                            Gecko) Chrome/123.0.0.0                              
myaiabnkhoj-server-1    |                            Safari/537.36', 'referer':                           
myaiabnkhoj-server-1    |                            'http://localhost:42110/', 'host':                   
myaiabnkhoj-server-1    |                            'localhost:42110', 'server_id':                      
myaiabnkhoj-server-1    |                            '26485c08-2711-4a10-9a5f-b96e41e1e2a                 
myaiabnkhoj-server-1    |                            d', 'subscription_type': 'standard',                 
myaiabnkhoj-server-1    |                            'is_recurring': False, 'client_id':                  
myaiabnkhoj-server-1    |                            'default', 'api': 'chat_options'},                   
myaiabnkhoj-server-1    |                            {'telemetry_type': 'api',                            
myaiabnkhoj-server-1    |                            'server_version': '0.0.0', 'os':                     
myaiabnkhoj-server-1    |                            'Linux', 'timestamp': '2024-06-21                    
myaiabnkhoj-server-1    |                            08:03:59', 'client_host':                            
myaiabnkhoj-server-1    |                            '172.26.0.1', 'user_agent':                          
myaiabnkhoj-server-1    |                            'Mozilla/5.0 (X11; Linux x86_64)                     
myaiabnkhoj-server-1    |                            AppleWebKit/537.36 (KHTML, like                      
myaiabnkhoj-server-1    |                            Gecko) Chrome/123.0.0.0                              
myaiabnkhoj-server-1    |                            Safari/537.36', 'referer':                           
myaiabnkhoj-server-1    |                            'http://localhost:42110/', 'host':                   
myaiabnkhoj-server-1    |                            'localhost:42110', 'server_id':                      
myaiabnkhoj-server-1    |                            '26485c08-2711-4a10-9a5f-b96e41e1e2a                 
myaiabnkhoj-server-1    |                            d', 'subscription_type': 'standard',                 
myaiabnkhoj-server-1    |                            'is_recurring': False, 'client_id':                  
myaiabnkhoj-server-1    |                            'default', 'api': 'chat_sessions'},                  
myaiabnkhoj-server-1    |                            {'telemetry_type': 'api',                            
myaiabnkhoj-server-1    |                            'server_version': '0.0.0', 'os':                     
myaiabnkhoj-server-1    |                            'Linux', 'timestamp': '2024-06-21                    
myaiabnkhoj-server-1    |                            08:03:59', 'client_host':                            
myaiabnkhoj-server-1    |                            '172.26.0.1', 'user_agent':                          
myaiabnkhoj-server-1    |                            'Mozilla/5.0 (X11; Linux x86_64)                     
myaiabnkhoj-server-1    |                            AppleWebKit/537.36 (KHTML, like                      
myaiabnkhoj-server-1    |                            Gecko) Chrome/123.0.0.0                              
myaiabnkhoj-server-1    |                            Safari/537.36', 'referer':                           
myaiabnkhoj-server-1    |                            'http://localhost:42110/', 'host':                   
myaiabnkhoj-server-1    |                            'localhost:42110', 'server_id':                      
myaiabnkhoj-server-1    |                            '26485c08-2711-4a10-9a5f-b96e41e1e2a                 
myaiabnkhoj-server-1    |                            d', 'subscription_type': 'standard',                 
myaiabnkhoj-server-1    |                            'is_recurring': False, 'client_id':                  
myaiabnkhoj-server-1    |                            'default', 'api': 'chat_history',                    
myaiabnkhoj-server-1    |                            'client': 'web'}, {'telemetry_type':                 
myaiabnkhoj-server-1    |                            'api', 'server_version': '0.0.0',                    
myaiabnkhoj-server-1    |                            'os': 'Linux', 'timestamp':                          
myaiabnkhoj-server-1    |                            '2024-06-21 08:04:15',                               
myaiabnkhoj-server-1    |                            'client_host': '172.26.0.1',                         
myaiabnkhoj-server-1    |                            'user_agent': 'Mozilla/5.0 (X11;                     
myaiabnkhoj-server-1    |                            Linux x86_64) AppleWebKit/537.36                     
myaiabnkhoj-server-1    |                            (KHTML, like Gecko) Chrome/123.0.0.0                 
myaiabnkhoj-server-1    |                            Safari/537.36', 'referer':                           
myaiabnkhoj-server-1    |                            'http://localhost:42110/', 'host':                   
myaiabnkhoj-server-1    |                            'localhost:42110', 'server_id':                      
myaiabnkhoj-server-1    |                            '26485c08-2711-4a10-9a5f-b96e41e1e2a                 
myaiabnkhoj-server-1    |                            d', 'subscription_type': 'standard',                 
myaiabnkhoj-server-1    |                            'is_recurring': False, 'client_id':                  
myaiabnkhoj-server-1    |                            'default', 'num_org': 0,                             
myaiabnkhoj-server-1    |                            'num_markdown': 0, 'num_pdf': 1,                     
myaiabnkhoj-server-1    |                            'num_plaintext': 0, 'num_docx': 0,                   
myaiabnkhoj-server-1    |                            'api': 'index/update', 'client':                     
myaiabnkhoj-server-1    |                            'web'}, {'telemetry_type': 'api',                    
myaiabnkhoj-server-1    |                            'server_version': '0.0.0', 'os':                     
myaiabnkhoj-server-1    |                            'Linux', 'timestamp': '2024-06-21                    
myaiabnkhoj-server-1    |                            08:04:15', 'client_host':                            
myaiabnkhoj-server-1    |                            '172.26.0.1', 'user_agent':                          
myaiabnkhoj-server-1    |                            'unknown', 'referer': 'unknown',                     
myaiabnkhoj-server-1    |                            'host': 'unknown', 'server_id':                      
myaiabnkhoj-server-1    |                            '26485c08-2711-4a10-9a5f-b96e41e1e2a                 
myaiabnkhoj-server-1    |                            d', 'subscription_type': 'standard',                 
myaiabnkhoj-server-1    |                            'is_recurring': False, 'client_id':                  
myaiabnkhoj-server-1    |                            'default', 'api':                                    
myaiabnkhoj-server-1    |                            'get_all_filenames'}]                                
myaiabnkhoj-server-1    | You are using the default legacy behaviour of the <class 'transformers.models.llama.tokenization_llama_fast.LlamaTokenizerFast'>. This is expected, and simply means that the `legacy` (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set `legacy=False`. This should only be set if you understand what it means, and thoroughly read the reason why this was added as explained in https://github.com/huggingface/transformers/pull/24565
myaiabnkhoj-server-1    | [08:04:52.298187] WARNING  khoj.processor.conversation.utils:       utils.py:217
myaiabnkhoj-server-1    |                            Fallback to default chat model                       
myaiabnkhoj-server-1    |                            tokenizer: None.                                     
myaiabnkhoj-server-1    |                            Configure tokenizer for unsupported                  
myaiabnkhoj-server-1    |                            model: llama3-70b-8192 in Khoj settings              
myaiabnkhoj-server-1    |                            to improve context stuffing.                         
myaiabnkhoj-server-1    | [08:04:52.682359] DEBUG    khoj.processor.conversation.openai before_sleep.py:65
myaiabnkhoj-server-1    |                            .utils: Retrying                                     
myaiabnkhoj-server-1    |                            khoj.processor.conversation.openai                   
myaiabnkhoj-server-1    |                            .utils.completion_with_backoff in                    
myaiabnkhoj-server-1    |                            0.6461066858467513 seconds as it                     
myaiabnkhoj-server-1    |                            raised BadRequestError: Error                        
myaiabnkhoj-server-1    |                            code: 400 - {'error': {'message':                    
myaiabnkhoj-server-1    |                            'response_format` does not support                   
myaiabnkhoj-server-1    |                            streaming', 'type':                                  
myaiabnkhoj-server-1    |                            'invalid_request_error'}}.                           
myaiabnkhoj-server-1    | [08:04:53.536637] DEBUG    khoj.processor.conversation.openai before_sleep.py:65
myaiabnkhoj-server-1    |                            .utils: Retrying                                     
myaiabnkhoj-server-1    |                            khoj.processor.conversation.openai                   
myaiabnkhoj-server-1    |                            .utils.completion_with_backoff in                    
myaiabnkhoj-server-1    |                            1.0890849572597519 seconds as it                     
myaiabnkhoj-server-1    |                            raised BadRequestError: Error                        
myaiabnkhoj-server-1    |                            code: 400 - {'error': {'message':                    
myaiabnkhoj-server-1    |                            'response_format` does not support                   
myaiabnkhoj-server-1    |                            streaming', 'type':                                  
myaiabnkhoj-server-1    |                            'invalid_request_error'}}.                           
myaiabnkhoj-server-1    | [08:04:54.883765] DEBUG    khoj.routers.helpers: Chat actor:      helpers.py:175
myaiabnkhoj-server-1    |                            Infer information sources to refer:                  
myaiabnkhoj-server-1    |                            7.722 seconds                                        
myaiabnkhoj-server-1    | [08:04:54.888881] ERROR    uvicorn.error: Exception in    websockets_impl.py:188
myaiabnkhoj-server-1    |                            ASGI application                                     
myaiabnkhoj-server-1    |                                                                                 
myaiabnkhoj-server-1    |                            ╭─ Traceback (most recent ca─╮                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/uvicorn/prot │                       
myaiabnkhoj-server-1    |                            │ ocols/websockets/websocket │                       
myaiabnkhoj-server-1    |                            │ s_impl.py:184 in run_asgi  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   181 │   │   termination  │                       
myaiabnkhoj-server-1    |                            │   182 │   │   """          │                       
myaiabnkhoj-server-1    |                            │   183 │   │   try:         │                       
myaiabnkhoj-server-1    |                            │ ❱ 184 │   │   │   result = │                       
myaiabnkhoj-server-1    |                            │   185 │   │   except BaseE │                       
myaiabnkhoj-server-1    |                            │   186 │   │   │   self.clo │                       
myaiabnkhoj-server-1    |                            │   187 │   │   │   msg = "E │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/uvicorn/midd │                       
myaiabnkhoj-server-1    |                            │ leware/proxy_headers.py:75 │                       
myaiabnkhoj-server-1    |                            │  in __call__               │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   72 │   │   │   │   │   p │                       
myaiabnkhoj-server-1    |                            │   73 │   │   │   │   │   s │                       
myaiabnkhoj-server-1    |                            │   74 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 75 │   │   return await  │                       
myaiabnkhoj-server-1    |                            │   76                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/fastapi/appl │                       
myaiabnkhoj-server-1    |                            │ ications.py:1054 in        │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1051 │   async def __cal │                       
myaiabnkhoj-server-1    |                            │   1052 │   │   if self.roo │                       
myaiabnkhoj-server-1    |                            │   1053 │   │   │   scope[" │                       
myaiabnkhoj-server-1    |                            │ ❱ 1054 │   │   await super │                       
myaiabnkhoj-server-1    |                            │   1055 │                   │                       
myaiabnkhoj-server-1    |                            │   1056 │   def add_api_rou │                       
myaiabnkhoj-server-1    |                            │   1057 │   │   self,       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ap │                       
myaiabnkhoj-server-1    |                            │ plications.py:123 in       │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   120 │   │   scope["app"] │                       
myaiabnkhoj-server-1    |                            │   121 │   │   if self.midd │                       
myaiabnkhoj-server-1    |                            │   122 │   │   │   self.mid │                       
myaiabnkhoj-server-1    |                            │ ❱ 123 │   │   await self.m │                       
myaiabnkhoj-server-1    |                            │   124 │                    │                       
myaiabnkhoj-server-1    |                            │   125 │   def on_event(sel │                       
myaiabnkhoj-server-1    |                            │   126 │   │   return self. │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/errors.py:151 in  │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   148 │                    │                       
myaiabnkhoj-server-1    |                            │   149 │   async def __call │                       
myaiabnkhoj-server-1    |                            │   150 │   │   if scope["ty │                       
myaiabnkhoj-server-1    |                            │ ❱ 151 │   │   │   await se │                       
myaiabnkhoj-server-1    |                            │   152 │   │   │   return   │                       
myaiabnkhoj-server-1    |                            │   153 │   │                │                       
myaiabnkhoj-server-1    |                            │   154 │   │   response_sta │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/sessions.py:85 in │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   82 │   │   │   │   │   h │                       
myaiabnkhoj-server-1    |                            │   83 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   84 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 85 │   │   await self.ap │                       
myaiabnkhoj-server-1    |                            │   86                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/authentication.py │                       
myaiabnkhoj-server-1    |                            │ :49 in __call__            │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   46 │   │   if auth_resul │                       
myaiabnkhoj-server-1    |                            │   47 │   │   │   auth_resu │                       
myaiabnkhoj-server-1    |                            │   48 │   │   scope["auth"] │                       
myaiabnkhoj-server-1    |                            │ ❱ 49 │   │   await self.ap │                       
myaiabnkhoj-server-1    |                            │   50 │                     │                       
myaiabnkhoj-server-1    |                            │   51 │   @staticmethod     │                       
myaiabnkhoj-server-1    |                            │   52 │   def default_on_er │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/cors.py:77 in     │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    74 │                    │                       
myaiabnkhoj-server-1    |                            │    75 │   async def __call │                       
myaiabnkhoj-server-1    |                            │    76 │   │   if scope["ty │                       
myaiabnkhoj-server-1    |                            │ ❱  77 │   │   │   await se │                       
myaiabnkhoj-server-1    |                            │    78 │   │   │   return   │                       
myaiabnkhoj-server-1    |                            │    79 │   │                │                       
myaiabnkhoj-server-1    |                            │    80 │   │   method = sco │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/exceptions.py:65  │                       
myaiabnkhoj-server-1    |                            │ in __call__                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   62 │   │   else:         │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   conn = We │                       
myaiabnkhoj-server-1    |                            │   64 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 65 │   │   await wrap_ap │                       
myaiabnkhoj-server-1    |                            │   66 │                     │                       
myaiabnkhoj-server-1    |                            │   67 │   def http_exceptio │                       
myaiabnkhoj-server-1    |                            │   68 │   │   assert isinst │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:64 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   61 │   │   │   │   handl │                       
myaiabnkhoj-server-1    |                            │   62 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   if handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 64 │   │   │   │   raise │                       
myaiabnkhoj-server-1    |                            │   65 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   66 │   │   │   if respon │                       
myaiabnkhoj-server-1    |                            │   67 │   │   │   │   msg = │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:53 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   50 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   51 │   │                 │                       
myaiabnkhoj-server-1    |                            │   52 │   │   try:          │                       
myaiabnkhoj-server-1    |                            │ ❱ 53 │   │   │   await app │                       
myaiabnkhoj-server-1    |                            │   54 │   │   except Except │                       
myaiabnkhoj-server-1    |                            │   55 │   │   │   handler = │                       
myaiabnkhoj-server-1    |                            │   56                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:756 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   753 │   │   """          │                       
myaiabnkhoj-server-1    |                            │   754 │   │   The main ent │                       
myaiabnkhoj-server-1    |                            │   755 │   │   """          │                       
myaiabnkhoj-server-1    |                            │ ❱ 756 │   │   await self.m │                       
myaiabnkhoj-server-1    |                            │   757 │                    │                       
myaiabnkhoj-server-1    |                            │   758 │   async def app(se │                       
myaiabnkhoj-server-1    |                            │   759 │   │   assert scope │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:776 in app        │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   773 │   │   │   match, c │                       
myaiabnkhoj-server-1    |                            │   774 │   │   │   if match │                       
myaiabnkhoj-server-1    |                            │   775 │   │   │   │   scop │                       
myaiabnkhoj-server-1    |                            │ ❱ 776 │   │   │   │   awai │                       
myaiabnkhoj-server-1    |                            │   777 │   │   │   │   retu │                       
myaiabnkhoj-server-1    |                            │   778 │   │   │   elif mat │                       
myaiabnkhoj-server-1    |                            │   779 │   │   │   │   part │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:373 in handle     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   370 │   │   return URLPa │                       
myaiabnkhoj-server-1    |                            │   371 │                    │                       
myaiabnkhoj-server-1    |                            │   372 │   async def handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 373 │   │   await self.a │                       
myaiabnkhoj-server-1    |                            │   374 │                    │                       
myaiabnkhoj-server-1    |                            │   375 │   def __eq__(self, │                       
myaiabnkhoj-server-1    |                            │   376 │   │   return (     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:96 in app         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    93 │   │   async def ap │                       
myaiabnkhoj-server-1    |                            │    94 │   │   │   await fu │                       
myaiabnkhoj-server-1    |                            │    95 │   │                │                       
myaiabnkhoj-server-1    |                            │ ❱  96 │   │   await wrap_a │                       
myaiabnkhoj-server-1    |                            │    97 │                    │                       
myaiabnkhoj-server-1    |                            │    98 │   return app       │                       
myaiabnkhoj-server-1    |                            │    99                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:64 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   61 │   │   │   │   handl │                       
myaiabnkhoj-server-1    |                            │   62 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   if handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 64 │   │   │   │   raise │                       
myaiabnkhoj-server-1    |                            │   65 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   66 │   │   │   if respon │                       
myaiabnkhoj-server-1    |                            │   67 │   │   │   │   msg = │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:53 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   50 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   51 │   │                 │                       
myaiabnkhoj-server-1    |                            │   52 │   │   try:          │                       
myaiabnkhoj-server-1    |                            │ ❱ 53 │   │   │   await app │                       
myaiabnkhoj-server-1    |                            │   54 │   │   except Except │                       
myaiabnkhoj-server-1    |                            │   55 │   │   │   handler = │                       
myaiabnkhoj-server-1    |                            │   56                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:94 in app         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    91 │   │   session = We │                       
myaiabnkhoj-server-1    |                            │    92 │   │                │                       
myaiabnkhoj-server-1    |                            │    93 │   │   async def ap │                       
myaiabnkhoj-server-1    |                            │ ❱  94 │   │   │   await fu │                       
myaiabnkhoj-server-1    |                            │    95 │   │                │                       
myaiabnkhoj-server-1    |                            │    96 │   │   await wrap_a │                       
myaiabnkhoj-server-1    |                            │    97                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/fastapi/rout │                       
myaiabnkhoj-server-1    |                            │ ing.py:348 in app          │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    345 │   │   │   if erro │                       
myaiabnkhoj-server-1    |                            │    346 │   │   │   │   rai │                       
myaiabnkhoj-server-1    |                            │    347 │   │   │   assert  │                       
myaiabnkhoj-server-1    |                            │ ❱  348 │   │   │   await d │                       
myaiabnkhoj-server-1    |                            │    349 │                   │                       
myaiabnkhoj-server-1    |                            │    350 │   return app      │                       
myaiabnkhoj-server-1    |                            │    351                     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/api_ │                       
myaiabnkhoj-server-1    |                            │ chat.py:593 in             │                       
myaiabnkhoj-server-1    |                            │ websocket_endpoint         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    590 │   │   is_automate │                       
myaiabnkhoj-server-1    |                            │    591 │   │               │                       
myaiabnkhoj-server-1    |                            │    592 │   │   if conversa │                       
myaiabnkhoj-server-1    |                            │ ❱  593 │   │   │   convers │                       
myaiabnkhoj-server-1    |                            │        is_automated_task)  │                       
myaiabnkhoj-server-1    |                            │    594 │   │   │   convers │                       
myaiabnkhoj-server-1    |                            │        conversation_comman │                       
myaiabnkhoj-server-1    |                            │    595 │   │   │   await s │                       
myaiabnkhoj-server-1    |                            │        {conversation_comma │                       
myaiabnkhoj-server-1    |                            │    596                     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/help │                       
myaiabnkhoj-server-1    |                            │ ers.py:250 in              │                       
myaiabnkhoj-server-1    |                            │ aget_relevant_information_ │                       
myaiabnkhoj-server-1    |                            │ sources                    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    247 │   )               │                       
myaiabnkhoj-server-1    |                            │    248 │                   │                       
myaiabnkhoj-server-1    |                            │    249 │   with timer("Cha │                       
myaiabnkhoj-server-1    |                            │ ❱  250 │   │   response =  │                       
myaiabnkhoj-server-1    |                            │        response_type="json │                       
myaiabnkhoj-server-1    |                            │    251 │                   │                       
myaiabnkhoj-server-1    |                            │    252 │   try:            │                       
myaiabnkhoj-server-1    |                            │    253 │   │   response =  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/help │                       
myaiabnkhoj-server-1    |                            │ ers.py:547 in              │                       
myaiabnkhoj-server-1    |                            │ send_message_to_model_wrap │                       
myaiabnkhoj-server-1    |                            │ per                        │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    544 │   │   │   tokeniz │                       
myaiabnkhoj-server-1    |                            │    545 │   │   )           │                       
myaiabnkhoj-server-1    |                            │    546 │   │               │                       
myaiabnkhoj-server-1    |                            │ ❱  547 │   │   openai_resp │                       
myaiabnkhoj-server-1    |                            │    548 │   │   │   message │                       
myaiabnkhoj-server-1    |                            │    549 │   │   │   api_key │                       
myaiabnkhoj-server-1    |                            │    550 │   │   │   model=c │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/processor/co │                       
myaiabnkhoj-server-1    |                            │ nversation/openai/gpt.py:9 │                       
myaiabnkhoj-server-1    |                            │ 8 in send_message_to_model │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    95 │   """              │                       
myaiabnkhoj-server-1    |                            │    96 │                    │                       
myaiabnkhoj-server-1    |                            │    97 │   # Get Response f │                       
myaiabnkhoj-server-1    |                            │ ❱  98 │   return completio │                       
myaiabnkhoj-server-1    |                            │    99 │   │   messages=mes │                       
myaiabnkhoj-server-1    |                            │   100 │   │   model=model, │                       
myaiabnkhoj-server-1    |                            │   101 │   │   openai_api_k │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:330 in wrapped_f  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   327 │   │   │   f, funct │                       
myaiabnkhoj-server-1    |                            │   328 │   │   )            │                       
myaiabnkhoj-server-1    |                            │   329 │   │   def wrapped_ │                       
myaiabnkhoj-server-1    |                            │ ❱ 330 │   │   │   return s │                       
myaiabnkhoj-server-1    |                            │   331 │   │                │                       
myaiabnkhoj-server-1    |                            │   332 │   │   def retry_wi │                       
myaiabnkhoj-server-1    |                            │   333 │   │   │   return s │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:467 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   464 │   │                │                       
myaiabnkhoj-server-1    |                            │   465 │   │   retry_state  │                       
myaiabnkhoj-server-1    |                            │   466 │   │   while True:  │                       
myaiabnkhoj-server-1    |                            │ ❱ 467 │   │   │   do = sel │                       
myaiabnkhoj-server-1    |                            │   468 │   │   │   if isins │                       
myaiabnkhoj-server-1    |                            │   469 │   │   │   │   try: │                       
myaiabnkhoj-server-1    |                            │   470 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:368 in iter       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   365 │   │   self._begin_ │                       
myaiabnkhoj-server-1    |                            │   366 │   │   result = Non │                       
myaiabnkhoj-server-1    |                            │   367 │   │   for action i │                       
myaiabnkhoj-server-1    |                            │ ❱ 368 │   │   │   result = │                       
myaiabnkhoj-server-1    |                            │   369 │   │   return resul │                       
myaiabnkhoj-server-1    |                            │   370 │                    │                       
myaiabnkhoj-server-1    |                            │   371 │   def _begin_iter( │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:410 in exc_check  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   407 │   │   │   │   fut  │                       
myaiabnkhoj-server-1    |                            │   408 │   │   │   │   retr │                       
myaiabnkhoj-server-1    |                            │   409 │   │   │   │   if s │                       
myaiabnkhoj-server-1    |                            │ ❱ 410 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   411 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │   412 │   │   │            │                       
myaiabnkhoj-server-1    |                            │   413 │   │   │   self._ad │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:183 in reraise    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   180 │                    │                       
myaiabnkhoj-server-1    |                            │   181 │   def reraise(self │                       
myaiabnkhoj-server-1    |                            │   182 │   │   if self.last │                       
myaiabnkhoj-server-1    |                            │ ❱ 183 │   │   │   raise se │                       
myaiabnkhoj-server-1    |                            │   184 │   │   raise self   │                       
myaiabnkhoj-server-1    |                            │   185 │                    │                       
myaiabnkhoj-server-1    |                            │   186 │   def __str__(self │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/lib/python3.10/concur │                       
myaiabnkhoj-server-1    |                            │ rent/futures/_base.py:451  │                       
myaiabnkhoj-server-1    |                            │ in result                  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   448 │   │   │   │   if s │                       
myaiabnkhoj-server-1    |                            │   449 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   450 │   │   │   │   elif │                       
myaiabnkhoj-server-1    |                            │ ❱ 451 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   452 │   │   │   │        │                       
myaiabnkhoj-server-1    |                            │   453 │   │   │   │   self │                       
myaiabnkhoj-server-1    |                            │   454                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/lib/python3.10/concur │                       
myaiabnkhoj-server-1    |                            │ rent/futures/_base.py:403  │                       
myaiabnkhoj-server-1    |                            │ in __get_result            │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   400 │   def __get_result │                       
myaiabnkhoj-server-1    |                            │   401 │   │   if self._exc │                       
myaiabnkhoj-server-1    |                            │   402 │   │   │   try:     │                       
myaiabnkhoj-server-1    |                            │ ❱ 403 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │   404 │   │   │   finally: │                       
myaiabnkhoj-server-1    |                            │   405 │   │   │   │   # Br │                       
myaiabnkhoj-server-1    |                            │   406 │   │   │   │   self │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:470 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   467 │   │   │   do = sel │                       
myaiabnkhoj-server-1    |                            │   468 │   │   │   if isins │                       
myaiabnkhoj-server-1    |                            │   469 │   │   │   │   try: │                       
myaiabnkhoj-server-1    |                            │ ❱ 470 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   471 │   │   │   │   exce │                       
myaiabnkhoj-server-1    |                            │   472 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   473 │   │   │   │   else │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/processor/co │                       
myaiabnkhoj-server-1    |                            │ nversation/openai/utils.py │                       
myaiabnkhoj-server-1    |                            │ :50 in                     │                       
myaiabnkhoj-server-1    |                            │ completion_with_backoff    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    47 │                    │                       
myaiabnkhoj-server-1    |                            │    48 │   formatted_messag │                       
myaiabnkhoj-server-1    |                            │       in messages]         │                       
myaiabnkhoj-server-1    |                            │    49 │                    │                       
myaiabnkhoj-server-1    |                            │ ❱  50 │   chat = client.ch │                       
myaiabnkhoj-server-1    |                            │    51 │   │   stream=True, │                       
myaiabnkhoj-server-1    |                            │    52 │   │   messages=for │                       
myaiabnkhoj-server-1    |                            │    53 │   │   model=model, │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_util │                       
myaiabnkhoj-server-1    |                            │ s/_utils.py:277 in wrapper │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   274 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   275 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   276 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │ ❱ 277 │   │   │   return f │                       
myaiabnkhoj-server-1    |                            │   278 │   │                │                       
myaiabnkhoj-server-1    |                            │   279 │   │   return wrapp │                       
myaiabnkhoj-server-1    |                            │   280                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/resou │                       
myaiabnkhoj-server-1    |                            │ rces/chat/completions.py:6 │                       
myaiabnkhoj-server-1    |                            │ 40 in create               │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    637 │   │   extra_body: │                       
myaiabnkhoj-server-1    |                            │    638 │   │   timeout: fl │                       
myaiabnkhoj-server-1    |                            │    639 │   ) -> ChatComple │                       
myaiabnkhoj-server-1    |                            │ ❱  640 │   │   return self │                       
myaiabnkhoj-server-1    |                            │    641 │   │   │   "/chat/ │                       
myaiabnkhoj-server-1    |                            │    642 │   │   │   body=ma │                       
myaiabnkhoj-server-1    |                            │    643 │   │   │   │   {   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:1250 in post    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1247 │   │   opts = Fina │                       
myaiabnkhoj-server-1    |                            │   1248 │   │   │   method= │                       
myaiabnkhoj-server-1    |                            │        **options           │                       
myaiabnkhoj-server-1    |                            │   1249 │   │   )           │                       
myaiabnkhoj-server-1    |                            │ ❱ 1250 │   │   return cast │                       
myaiabnkhoj-server-1    |                            │        stream_cls=stream_c │                       
myaiabnkhoj-server-1    |                            │   1251 │                   │                       
myaiabnkhoj-server-1    |                            │   1252 │   def patch(      │                       
myaiabnkhoj-server-1    |                            │   1253 │   │   self,       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:931 in request  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    928 │   │   stream: boo │                       
myaiabnkhoj-server-1    |                            │    929 │   │   stream_cls: │                       
myaiabnkhoj-server-1    |                            │    930 │   ) -> ResponseT  │                       
myaiabnkhoj-server-1    |                            │ ❱  931 │   │   return self │                       
myaiabnkhoj-server-1    |                            │    932 │   │   │   cast_to │                       
myaiabnkhoj-server-1    |                            │    933 │   │   │   options │                       
myaiabnkhoj-server-1    |                            │    934 │   │   │   stream= │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:1030 in         │                       
myaiabnkhoj-server-1    |                            │ _request                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1027 │   │   │   │   err │                       
myaiabnkhoj-server-1    |                            │   1028 │   │   │           │                       
myaiabnkhoj-server-1    |                            │   1029 │   │   │   log.deb │                       
myaiabnkhoj-server-1    |                            │ ❱ 1030 │   │   │   raise s │                       
myaiabnkhoj-server-1    |                            │   1031 │   │               │                       
myaiabnkhoj-server-1    |                            │   1032 │   │   return self │                       
myaiabnkhoj-server-1    |                            │   1033 │   │   │   cast_to │                       
myaiabnkhoj-server-1    |                            ╰────────────────────────────╯                       
myaiabnkhoj-server-1    |                            BadRequestError: Error code:                         
myaiabnkhoj-server-1    |                            400 - {'error': {'message':                          
myaiabnkhoj-server-1    |                            'response_format` does not                           
myaiabnkhoj-server-1    |                            support streaming', 'type':                          
myaiabnkhoj-server-1    |                            'invalid_request_error'}}                            
myaiabnkhoj-server-1    | [08:04:55.971712] DEBUG    uvicorn.error: = connection is       protocol.py:1227
myaiabnkhoj-server-1    |                            CLOSING                                              
myaiabnkhoj-server-1    | [08:04:55.972998] DEBUG    uvicorn.error: > CLOSE 1000 (OK) [2  protocol.py:1178
myaiabnkhoj-server-1    |                            bytes]                                               
myaiabnkhoj-server-1    | [08:04:55.974311] DEBUG    uvicorn.error: = connection is       protocol.py:1497
myaiabnkhoj-server-1    |                            CLOSED                                               
myaiabnkhoj-server-1    | [08:04:55.975695] DEBUG    uvicorn.error: ! failing connection  protocol.py:1412
myaiabnkhoj-server-1    |                            with code 1006                                       
myaiabnkhoj-server-1    | [08:04:55.977672] ERROR    uvicorn.error: closing handshake failed server.py:248
myaiabnkhoj-server-1    |                            ╭─ Traceback (most recent call last) ─╮              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/server.py:24 │              
myaiabnkhoj-server-1    |                            │ 4 in handler                        │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    241 │   │   │   │   raise        │              
myaiabnkhoj-server-1    |                            │    242 │   │   │                    │              
myaiabnkhoj-server-1    |                            │    243 │   │   │   try:             │              
myaiabnkhoj-server-1    |                            │ ❱  244 │   │   │   │   await self.c │              
myaiabnkhoj-server-1    |                            │    245 │   │   │   except Connectio │              
myaiabnkhoj-server-1    |                            │    246 │   │   │   │   raise        │              
myaiabnkhoj-server-1    |                            │    247 │   │   │   except Exception │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 770 in close                        │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    767 │   │   """                  │              
myaiabnkhoj-server-1    |                            │    768 │   │   try:                 │              
myaiabnkhoj-server-1    |                            │    769 │   │   │   async with async │              
myaiabnkhoj-server-1    |                            │ ❱  770 │   │   │   │   await self.w │              
myaiabnkhoj-server-1    |                            │    771 │   │   except asyncio.Timeo │              
myaiabnkhoj-server-1    |                            │    772 │   │   │   # If the close f │              
myaiabnkhoj-server-1    |                            │    773 │   │   │   # are full, the  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1236 in write_close_frame           │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1233 │   │   │   │   data = close │              
myaiabnkhoj-server-1    |                            │   1234 │   │   │                    │              
myaiabnkhoj-server-1    |                            │   1235 │   │   │   # 7.1.2. Start t │              
myaiabnkhoj-server-1    |                            │ ❱ 1236 │   │   │   await self.write │              
myaiabnkhoj-server-1    |                            │   1237 │                            │              
myaiabnkhoj-server-1    |                            │   1238 │   async def keepalive_ping │              
myaiabnkhoj-server-1    |                            │   1239 │   │   """                  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1209 in write_frame                 │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1206 │   │   │   │   f"Cannot wri │              
myaiabnkhoj-server-1    |                            │   1207 │   │   │   )                │              
myaiabnkhoj-server-1    |                            │   1208 │   │   self.write_frame_syn │              
myaiabnkhoj-server-1    |                            │ ❱ 1209 │   │   await self.drain()   │              
myaiabnkhoj-server-1    |                            │   1210 │                            │              
myaiabnkhoj-server-1    |                            │   1211 │   async def write_close_fr │              
myaiabnkhoj-server-1    |                            │   1212 │   │   self, close: Close,  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1198 in drain                       │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1195 │   │   │   self.fail_connec │              
myaiabnkhoj-server-1    |                            │   1196 │   │   │   # Wait until the │              
myaiabnkhoj-server-1    |                            │   1197 │   │   │   # with the corre │              
myaiabnkhoj-server-1    |                            │ ❱ 1198 │   │   │   await self.ensur │              
myaiabnkhoj-server-1    |                            │   1199 │                            │              
myaiabnkhoj-server-1    |                            │   1200 │   async def write_frame(   │              
myaiabnkhoj-server-1    |                            │   1201 │   │   self, fin: bool, opc │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 939 in ensure_open                  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    936 │   │   │   │   return       │              
myaiabnkhoj-server-1    |                            │    937 │   │                        │              
myaiabnkhoj-server-1    |                            │    938 │   │   if self.state is Sta │              
myaiabnkhoj-server-1    |                            │ ❱  939 │   │   │   raise self.conne │              
myaiabnkhoj-server-1    |                            │    940 │   │                        │              
myaiabnkhoj-server-1    |                            │    941 │   │   if self.state is Sta │              
myaiabnkhoj-server-1    |                            │    942 │   │   │   # If we started  │              
myaiabnkhoj-server-1    |                            ╰─────────────────────────────────────╯              
myaiabnkhoj-server-1    |                            ConnectionClosedError: sent 1000 (OK);               
myaiabnkhoj-server-1    |                            no close frame received                              
myaiabnkhoj-server-1    | [08:04:56.261760] INFO     uvicorn.error: connection closed        server.py:264
myaiabnkhoj-server-1    | [08:04:56.262973] DEBUG    uvicorn.error: x half-closing TCP    protocol.py:1319
myaiabnkhoj-server-1    |                            connection                                           



`


This doesn't work: What are the number of articles in Wikipedia?

This works: /general What are the number of articles in Wikipedia?

![image](https://github.com/khoj-ai/khoj/assets/32351181/caad0302-5304-4111-87c9-43fc0863018a)

@sabaimran 

I also saw this in a console log:

BadRequestError: Error code:                         
400 - {'error': {'message':                          
'response_format` does not                           
support streaming', 'type':                          
'invalid_request_error'}}  

![image](https://github.com/khoj-ai/khoj/assets/32351181/74f225ae-e2a8-4bc7-922f-b3c958fc6f8c)

Hmm interesting. You should run `docker compose up --build` when you're restarting the container after pulling from the latest changes.
But you're right, this is likely a different issue. I'd assumed you were using ollama / llama3 and tested on that. The tokenizer shouldn't matter here. 
/general is still working, correct?
API: I'm not using Ollama. I'm using a vendor-hosted LLAMA3 API. With that API: Yes /general works faultlessly but the moment I say /notes or /default it breaks (regardless of whether or not I have uploaded any document).

At the same time, OpenAI API works faultlessly with both /general and /notes.

Yes I do run docker-compose build with the revised code. Other test with text changes do show up, meaning the build process was ok.

@sabaimran 





Wrapping the API in LiteLLM: 

myaiabnkhoj-server-1    | [01:05:12.918899] DEBUG    uvicorn.error: < TEXT 'How can I     protocol.py:1172
myaiabnkhoj-server-1    |                            talk to an LLM' [24 bytes]                           
myaiabnkhoj-server-1    | [01:05:12.928024] DEBUG    uvicorn.error: > TEXT '{"type":      protocol.py:1178
myaiabnkhoj-server-1    |                            "status", "message":                                 
myaiabnkhoj-server-1    |                            "**Understanding ...e":                              
myaiabnkhoj-server-1    |                            "application/json"}' [118 bytes]                     
myaiabnkhoj-server-1    | [01:05:12.941103] WARNING  khoj.processor.conversation.utils:       utils.py:217
myaiabnkhoj-server-1    |                            Fallback to default chat model                       
myaiabnkhoj-server-1    |                            tokenizer: None.                                     
myaiabnkhoj-server-1    |                            Configure tokenizer for unsupported                  
myaiabnkhoj-server-1    |                            model: llama3-70b-8192 in Khoj settings              
myaiabnkhoj-server-1    |                            to improve context stuffing.                         
myaiabnkhoj-server-1    | [01:05:14.901754] DEBUG    khoj.processor.conversation.openai before_sleep.py:65
myaiabnkhoj-server-1    |                            .utils: Retrying                                     
myaiabnkhoj-server-1    |                            khoj.processor.conversation.openai                   
myaiabnkhoj-server-1    |                            .utils.completion_with_backoff in                    
myaiabnkhoj-server-1    |                            0.8713305851005899 seconds as it                     
myaiabnkhoj-server-1    |                            raised BadRequestError: Error                        
myaiabnkhoj-server-1    |                            code: 400 - {'error': {'message':                    
myaiabnkhoj-server-1    |                            "litellm.BadRequestError:                            
myaiabnkhoj-server-1    |                            BadRequestError: GroqException -                     
myaiabnkhoj-server-1    |                            Error code: 400 - {'error':                          
myaiabnkhoj-server-1    |                            {'message': 'response_format` does                   
myaiabnkhoj-server-1    |                            not support streaming', 'type':                      
myaiabnkhoj-server-1    |                            'invalid_request_error'}}",                          
myaiabnkhoj-server-1    |                            'type': None, 'param': None,                         
myaiabnkhoj-server-1    |                            'code': 400}}.                                       
myaiabnkhoj-server-1    | [01:05:16.811876] DEBUG    khoj.processor.conversation.openai before_sleep.py:65
myaiabnkhoj-server-1    |                            .utils: Retrying                                     
myaiabnkhoj-server-1    |                            khoj.processor.conversation.openai                   
myaiabnkhoj-server-1    |                            .utils.completion_with_backoff in                    
myaiabnkhoj-server-1    |                            0.04274018957486159 seconds as it                    
myaiabnkhoj-server-1    |                            raised BadRequestError: Error                        
myaiabnkhoj-server-1    |                            code: 400 - {'error': {'message':                    
myaiabnkhoj-server-1    |                            "litellm.BadRequestError:                            
myaiabnkhoj-server-1    |                            BadRequestError: GroqException -                     
myaiabnkhoj-server-1    |                            Error code: 400 - {'error':                          
myaiabnkhoj-server-1    |                            {'message': 'response_format` does                   
myaiabnkhoj-server-1    |                            not support streaming', 'type':                      
myaiabnkhoj-server-1    |                            'invalid_request_error'}}",                          
myaiabnkhoj-server-1    |                            'type': None, 'param': None,                         
myaiabnkhoj-server-1    |                            'code': 400}}.                                       
myaiabnkhoj-server-1    | [01:05:17.897260] DEBUG    khoj.routers.helpers: Chat actor:      helpers.py:175
myaiabnkhoj-server-1    |                            Infer information sources to refer:                  
myaiabnkhoj-server-1    |                            4.964 seconds                                        
myaiabnkhoj-server-1    | [01:05:17.901853] ERROR    uvicorn.error: Exception in    websockets_impl.py:188
myaiabnkhoj-server-1    |                            ASGI application                                     
myaiabnkhoj-server-1    |                                                                                 
myaiabnkhoj-server-1    |                            ╭─ Traceback (most recent ca─╮                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/uvicorn/prot │                       
myaiabnkhoj-server-1    |                            │ ocols/websockets/websocket │                       
myaiabnkhoj-server-1    |                            │ s_impl.py:184 in run_asgi  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   181 │   │   termination  │                       
myaiabnkhoj-server-1    |                            │   182 │   │   """          │                       
myaiabnkhoj-server-1    |                            │   183 │   │   try:         │                       
myaiabnkhoj-server-1    |                            │ ❱ 184 │   │   │   result = │                       
myaiabnkhoj-server-1    |                            │   185 │   │   except BaseE │                       
myaiabnkhoj-server-1    |                            │   186 │   │   │   self.clo │                       
myaiabnkhoj-server-1    |                            │   187 │   │   │   msg = "E │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/uvicorn/midd │                       
myaiabnkhoj-server-1    |                            │ leware/proxy_headers.py:75 │                       
myaiabnkhoj-server-1    |                            │  in __call__               │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   72 │   │   │   │   │   p │                       
myaiabnkhoj-server-1    |                            │   73 │   │   │   │   │   s │                       
myaiabnkhoj-server-1    |                            │   74 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 75 │   │   return await  │                       
myaiabnkhoj-server-1    |                            │   76                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/fastapi/appl │                       
myaiabnkhoj-server-1    |                            │ ications.py:1054 in        │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1051 │   async def __cal │                       
myaiabnkhoj-server-1    |                            │   1052 │   │   if self.roo │                       
myaiabnkhoj-server-1    |                            │   1053 │   │   │   scope[" │                       
myaiabnkhoj-server-1    |                            │ ❱ 1054 │   │   await super │                       
myaiabnkhoj-server-1    |                            │   1055 │                   │                       
myaiabnkhoj-server-1    |                            │   1056 │   def add_api_rou │                       
myaiabnkhoj-server-1    |                            │   1057 │   │   self,       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ap │                       
myaiabnkhoj-server-1    |                            │ plications.py:123 in       │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   120 │   │   scope["app"] │                       
myaiabnkhoj-server-1    |                            │   121 │   │   if self.midd │                       
myaiabnkhoj-server-1    |                            │   122 │   │   │   self.mid │                       
myaiabnkhoj-server-1    |                            │ ❱ 123 │   │   await self.m │                       
myaiabnkhoj-server-1    |                            │   124 │                    │                       
myaiabnkhoj-server-1    |                            │   125 │   def on_event(sel │                       
myaiabnkhoj-server-1    |                            │   126 │   │   return self. │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/errors.py:151 in  │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   148 │                    │                       
myaiabnkhoj-server-1    |                            │   149 │   async def __call │                       
myaiabnkhoj-server-1    |                            │   150 │   │   if scope["ty │                       
myaiabnkhoj-server-1    |                            │ ❱ 151 │   │   │   await se │                       
myaiabnkhoj-server-1    |                            │   152 │   │   │   return   │                       
myaiabnkhoj-server-1    |                            │   153 │   │                │                       
myaiabnkhoj-server-1    |                            │   154 │   │   response_sta │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/sessions.py:85 in │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   82 │   │   │   │   │   h │                       
myaiabnkhoj-server-1    |                            │   83 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   84 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 85 │   │   await self.ap │                       
myaiabnkhoj-server-1    |                            │   86                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/configure.py │                       
myaiabnkhoj-server-1    |                            │ :315 in __call__           │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   312 │   │   async def __ │                       
myaiabnkhoj-server-1    |                            │   313 │   │   │   if scope │                       
myaiabnkhoj-server-1    |                            │   314 │   │   │   │   scop │                       
myaiabnkhoj-server-1    |                            │ ❱ 315 │   │   │   await se │                       
myaiabnkhoj-server-1    |                            │   316 │   │                │                       
myaiabnkhoj-server-1    |                            │   317 │   │   def __init__ │                       
myaiabnkhoj-server-1    |                            │   318 │   │   │   super(). │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/authentication.py │                       
myaiabnkhoj-server-1    |                            │ :49 in __call__            │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   46 │   │   if auth_resul │                       
myaiabnkhoj-server-1    |                            │   47 │   │   │   auth_resu │                       
myaiabnkhoj-server-1    |                            │   48 │   │   scope["auth"] │                       
myaiabnkhoj-server-1    |                            │ ❱ 49 │   │   await self.ap │                       
myaiabnkhoj-server-1    |                            │   50 │                     │                       
myaiabnkhoj-server-1    |                            │   51 │   @staticmethod     │                       
myaiabnkhoj-server-1    |                            │   52 │   def default_on_er │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/cors.py:77 in     │                       
myaiabnkhoj-server-1    |                            │ __call__                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    74 │                    │                       
myaiabnkhoj-server-1    |                            │    75 │   async def __call │                       
myaiabnkhoj-server-1    |                            │    76 │   │   if scope["ty │                       
myaiabnkhoj-server-1    |                            │ ❱  77 │   │   │   await se │                       
myaiabnkhoj-server-1    |                            │    78 │   │   │   return   │                       
myaiabnkhoj-server-1    |                            │    79 │   │                │                       
myaiabnkhoj-server-1    |                            │    80 │   │   method = sco │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/mi │                       
myaiabnkhoj-server-1    |                            │ ddleware/exceptions.py:65  │                       
myaiabnkhoj-server-1    |                            │ in __call__                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   62 │   │   else:         │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   conn = We │                       
myaiabnkhoj-server-1    |                            │   64 │   │                 │                       
myaiabnkhoj-server-1    |                            │ ❱ 65 │   │   await wrap_ap │                       
myaiabnkhoj-server-1    |                            │   66 │                     │                       
myaiabnkhoj-server-1    |                            │   67 │   def http_exceptio │                       
myaiabnkhoj-server-1    |                            │   68 │   │   assert isinst │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:64 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   61 │   │   │   │   handl │                       
myaiabnkhoj-server-1    |                            │   62 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   if handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 64 │   │   │   │   raise │                       
myaiabnkhoj-server-1    |                            │   65 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   66 │   │   │   if respon │                       
myaiabnkhoj-server-1    |                            │   67 │   │   │   │   msg = │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:53 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   50 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   51 │   │                 │                       
myaiabnkhoj-server-1    |                            │   52 │   │   try:          │                       
myaiabnkhoj-server-1    |                            │ ❱ 53 │   │   │   await app │                       
myaiabnkhoj-server-1    |                            │   54 │   │   except Except │                       
myaiabnkhoj-server-1    |                            │   55 │   │   │   handler = │                       
myaiabnkhoj-server-1    |                            │   56                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:756 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   753 │   │   """          │                       
myaiabnkhoj-server-1    |                            │   754 │   │   The main ent │                       
myaiabnkhoj-server-1    |                            │   755 │   │   """          │                       
myaiabnkhoj-server-1    |                            │ ❱ 756 │   │   await self.m │                       
myaiabnkhoj-server-1    |                            │   757 │                    │                       
myaiabnkhoj-server-1    |                            │   758 │   async def app(se │                       
myaiabnkhoj-server-1    |                            │   759 │   │   assert scope │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:776 in app        │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   773 │   │   │   match, c │                       
myaiabnkhoj-server-1    |                            │   774 │   │   │   if match │                       
myaiabnkhoj-server-1    |                            │   775 │   │   │   │   scop │                       
myaiabnkhoj-server-1    |                            │ ❱ 776 │   │   │   │   awai │                       
myaiabnkhoj-server-1    |                            │   777 │   │   │   │   retu │                       
myaiabnkhoj-server-1    |                            │   778 │   │   │   elif mat │                       
myaiabnkhoj-server-1    |                            │   779 │   │   │   │   part │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:373 in handle     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   370 │   │   return URLPa │                       
myaiabnkhoj-server-1    |                            │   371 │                    │                       
myaiabnkhoj-server-1    |                            │   372 │   async def handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 373 │   │   await self.a │                       
myaiabnkhoj-server-1    |                            │   374 │                    │                       
myaiabnkhoj-server-1    |                            │   375 │   def __eq__(self, │                       
myaiabnkhoj-server-1    |                            │   376 │   │   return (     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:96 in app         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    93 │   │   async def ap │                       
myaiabnkhoj-server-1    |                            │    94 │   │   │   await fu │                       
myaiabnkhoj-server-1    |                            │    95 │   │                │                       
myaiabnkhoj-server-1    |                            │ ❱  96 │   │   await wrap_a │                       
myaiabnkhoj-server-1    |                            │    97 │                    │                       
myaiabnkhoj-server-1    |                            │    98 │   return app       │                       
myaiabnkhoj-server-1    |                            │    99                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:64 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   61 │   │   │   │   handl │                       
myaiabnkhoj-server-1    |                            │   62 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   63 │   │   │   if handle │                       
myaiabnkhoj-server-1    |                            │ ❱ 64 │   │   │   │   raise │                       
myaiabnkhoj-server-1    |                            │   65 │   │   │             │                       
myaiabnkhoj-server-1    |                            │   66 │   │   │   if respon │                       
myaiabnkhoj-server-1    |                            │   67 │   │   │   │   msg = │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/_e │                       
myaiabnkhoj-server-1    |                            │ xception_handler.py:53 in  │                       
myaiabnkhoj-server-1    |                            │ wrapped_app                │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   50 │   │   │   await sen │                       
myaiabnkhoj-server-1    |                            │   51 │   │                 │                       
myaiabnkhoj-server-1    |                            │   52 │   │   try:          │                       
myaiabnkhoj-server-1    |                            │ ❱ 53 │   │   │   await app │                       
myaiabnkhoj-server-1    |                            │   54 │   │   except Except │                       
myaiabnkhoj-server-1    |                            │   55 │   │   │   handler = │                       
myaiabnkhoj-server-1    |                            │   56                       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/starlette/ro │                       
myaiabnkhoj-server-1    |                            │ uting.py:94 in app         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    91 │   │   session = We │                       
myaiabnkhoj-server-1    |                            │    92 │   │                │                       
myaiabnkhoj-server-1    |                            │    93 │   │   async def ap │                       
myaiabnkhoj-server-1    |                            │ ❱  94 │   │   │   await fu │                       
myaiabnkhoj-server-1    |                            │    95 │   │                │                       
myaiabnkhoj-server-1    |                            │    96 │   │   await wrap_a │                       
myaiabnkhoj-server-1    |                            │    97                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/fastapi/rout │                       
myaiabnkhoj-server-1    |                            │ ing.py:348 in app          │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    345 │   │   │   if erro │                       
myaiabnkhoj-server-1    |                            │    346 │   │   │   │   rai │                       
myaiabnkhoj-server-1    |                            │    347 │   │   │   assert  │                       
myaiabnkhoj-server-1    |                            │ ❱  348 │   │   │   await d │                       
myaiabnkhoj-server-1    |                            │    349 │                   │                       
myaiabnkhoj-server-1    |                            │    350 │   return app      │                       
myaiabnkhoj-server-1    |                            │    351                     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/api_ │                       
myaiabnkhoj-server-1    |                            │ chat.py:593 in             │                       
myaiabnkhoj-server-1    |                            │ websocket_endpoint         │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    590 │   │   is_automate │                       
myaiabnkhoj-server-1    |                            │    591 │   │               │                       
myaiabnkhoj-server-1    |                            │    592 │   │   if conversa │                       
myaiabnkhoj-server-1    |                            │ ❱  593 │   │   │   convers │                       
myaiabnkhoj-server-1    |                            │        is_automated_task)  │                       
myaiabnkhoj-server-1    |                            │    594 │   │   │   convers │                       
myaiabnkhoj-server-1    |                            │        conversation_comman │                       
myaiabnkhoj-server-1    |                            │    595 │   │   │   await s │                       
myaiabnkhoj-server-1    |                            │        {conversation_comma │                       
myaiabnkhoj-server-1    |                            │    596                     │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/help │                       
myaiabnkhoj-server-1    |                            │ ers.py:250 in              │                       
myaiabnkhoj-server-1    |                            │ aget_relevant_information_ │                       
myaiabnkhoj-server-1    |                            │ sources                    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    247 │   )               │                       
myaiabnkhoj-server-1    |                            │    248 │                   │                       
myaiabnkhoj-server-1    |                            │    249 │   with timer("Cha │                       
myaiabnkhoj-server-1    |                            │ ❱  250 │   │   response =  │                       
myaiabnkhoj-server-1    |                            │        response_type="json │                       
myaiabnkhoj-server-1    |                            │    251 │                   │                       
myaiabnkhoj-server-1    |                            │    252 │   try:            │                       
myaiabnkhoj-server-1    |                            │    253 │   │   response =  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/routers/help │                       
myaiabnkhoj-server-1    |                            │ ers.py:547 in              │                       
myaiabnkhoj-server-1    |                            │ send_message_to_model_wrap │                       
myaiabnkhoj-server-1    |                            │ per                        │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    544 │   │   │   tokeniz │                       
myaiabnkhoj-server-1    |                            │    545 │   │   )           │                       
myaiabnkhoj-server-1    |                            │    546 │   │               │                       
myaiabnkhoj-server-1    |                            │ ❱  547 │   │   openai_resp │                       
myaiabnkhoj-server-1    |                            │    548 │   │   │   message │                       
myaiabnkhoj-server-1    |                            │    549 │   │   │   api_key │                       
myaiabnkhoj-server-1    |                            │    550 │   │   │   model=c │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/processor/co │                       
myaiabnkhoj-server-1    |                            │ nversation/openai/gpt.py:9 │                       
myaiabnkhoj-server-1    |                            │ 8 in send_message_to_model │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    95 │   """              │                       
myaiabnkhoj-server-1    |                            │    96 │                    │                       
myaiabnkhoj-server-1    |                            │    97 │   # Get Response f │                       
myaiabnkhoj-server-1    |                            │ ❱  98 │   return completio │                       
myaiabnkhoj-server-1    |                            │    99 │   │   messages=mes │                       
myaiabnkhoj-server-1    |                            │   100 │   │   model=model, │                       
myaiabnkhoj-server-1    |                            │   101 │   │   openai_api_k │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:330 in wrapped_f  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   327 │   │   │   f, funct │                       
myaiabnkhoj-server-1    |                            │   328 │   │   )            │                       
myaiabnkhoj-server-1    |                            │   329 │   │   def wrapped_ │                       
myaiabnkhoj-server-1    |                            │ ❱ 330 │   │   │   return s │                       
myaiabnkhoj-server-1    |                            │   331 │   │                │                       
myaiabnkhoj-server-1    |                            │   332 │   │   def retry_wi │                       
myaiabnkhoj-server-1    |                            │   333 │   │   │   return s │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:467 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   464 │   │                │                       
myaiabnkhoj-server-1    |                            │   465 │   │   retry_state  │                       
myaiabnkhoj-server-1    |                            │   466 │   │   while True:  │                       
myaiabnkhoj-server-1    |                            │ ❱ 467 │   │   │   do = sel │                       
myaiabnkhoj-server-1    |                            │   468 │   │   │   if isins │                       
myaiabnkhoj-server-1    |                            │   469 │   │   │   │   try: │                       
myaiabnkhoj-server-1    |                            │   470 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:368 in iter       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   365 │   │   self._begin_ │                       
myaiabnkhoj-server-1    |                            │   366 │   │   result = Non │                       
myaiabnkhoj-server-1    |                            │   367 │   │   for action i │                       
myaiabnkhoj-server-1    |                            │ ❱ 368 │   │   │   result = │                       
myaiabnkhoj-server-1    |                            │   369 │   │   return resul │                       
myaiabnkhoj-server-1    |                            │   370 │                    │                       
myaiabnkhoj-server-1    |                            │   371 │   def _begin_iter( │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:410 in exc_check  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   407 │   │   │   │   fut  │                       
myaiabnkhoj-server-1    |                            │   408 │   │   │   │   retr │                       
myaiabnkhoj-server-1    |                            │   409 │   │   │   │   if s │                       
myaiabnkhoj-server-1    |                            │ ❱ 410 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   411 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │   412 │   │   │            │                       
myaiabnkhoj-server-1    |                            │   413 │   │   │   self._ad │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:183 in reraise    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   180 │                    │                       
myaiabnkhoj-server-1    |                            │   181 │   def reraise(self │                       
myaiabnkhoj-server-1    |                            │   182 │   │   if self.last │                       
myaiabnkhoj-server-1    |                            │ ❱ 183 │   │   │   raise se │                       
myaiabnkhoj-server-1    |                            │   184 │   │   raise self   │                       
myaiabnkhoj-server-1    |                            │   185 │                    │                       
myaiabnkhoj-server-1    |                            │   186 │   def __str__(self │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/lib/python3.10/concur │                       
myaiabnkhoj-server-1    |                            │ rent/futures/_base.py:451  │                       
myaiabnkhoj-server-1    |                            │ in result                  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   448 │   │   │   │   if s │                       
myaiabnkhoj-server-1    |                            │   449 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   450 │   │   │   │   elif │                       
myaiabnkhoj-server-1    |                            │ ❱ 451 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   452 │   │   │   │        │                       
myaiabnkhoj-server-1    |                            │   453 │   │   │   │   self │                       
myaiabnkhoj-server-1    |                            │   454                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/lib/python3.10/concur │                       
myaiabnkhoj-server-1    |                            │ rent/futures/_base.py:403  │                       
myaiabnkhoj-server-1    |                            │ in __get_result            │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   400 │   def __get_result │                       
myaiabnkhoj-server-1    |                            │   401 │   │   if self._exc │                       
myaiabnkhoj-server-1    |                            │   402 │   │   │   try:     │                       
myaiabnkhoj-server-1    |                            │ ❱ 403 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │   404 │   │   │   finally: │                       
myaiabnkhoj-server-1    |                            │   405 │   │   │   │   # Br │                       
myaiabnkhoj-server-1    |                            │   406 │   │   │   │   self │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/tenacity/__i │                       
myaiabnkhoj-server-1    |                            │ nit__.py:470 in __call__   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   467 │   │   │   do = sel │                       
myaiabnkhoj-server-1    |                            │   468 │   │   │   if isins │                       
myaiabnkhoj-server-1    |                            │   469 │   │   │   │   try: │                       
myaiabnkhoj-server-1    |                            │ ❱ 470 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   471 │   │   │   │   exce │                       
myaiabnkhoj-server-1    |                            │   472 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   473 │   │   │   │   else │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /app/src/khoj/processor/co │                       
myaiabnkhoj-server-1    |                            │ nversation/openai/utils.py │                       
myaiabnkhoj-server-1    |                            │ :50 in                     │                       
myaiabnkhoj-server-1    |                            │ completion_with_backoff    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    47 │                    │                       
myaiabnkhoj-server-1    |                            │    48 │   formatted_messag │                       
myaiabnkhoj-server-1    |                            │       in messages]         │                       
myaiabnkhoj-server-1    |                            │    49 │                    │                       
myaiabnkhoj-server-1    |                            │ ❱  50 │   chat = client.ch │                       
myaiabnkhoj-server-1    |                            │    51 │   │   stream=True, │                       
myaiabnkhoj-server-1    |                            │    52 │   │   messages=for │                       
myaiabnkhoj-server-1    |                            │    53 │   │   model=model, │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_util │                       
myaiabnkhoj-server-1    |                            │ s/_utils.py:277 in wrapper │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   274 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   275 │   │   │   │   │    │                       
myaiabnkhoj-server-1    |                            │   276 │   │   │   │   rais │                       
myaiabnkhoj-server-1    |                            │ ❱ 277 │   │   │   return f │                       
myaiabnkhoj-server-1    |                            │   278 │   │                │                       
myaiabnkhoj-server-1    |                            │   279 │   │   return wrapp │                       
myaiabnkhoj-server-1    |                            │   280                      │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/resou │                       
myaiabnkhoj-server-1    |                            │ rces/chat/completions.py:6 │                       
myaiabnkhoj-server-1    |                            │ 40 in create               │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    637 │   │   extra_body: │                       
myaiabnkhoj-server-1    |                            │    638 │   │   timeout: fl │                       
myaiabnkhoj-server-1    |                            │    639 │   ) -> ChatComple │                       
myaiabnkhoj-server-1    |                            │ ❱  640 │   │   return self │                       
myaiabnkhoj-server-1    |                            │    641 │   │   │   "/chat/ │                       
myaiabnkhoj-server-1    |                            │    642 │   │   │   body=ma │                       
myaiabnkhoj-server-1    |                            │    643 │   │   │   │   {   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:1250 in post    │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1247 │   │   opts = Fina │                       
myaiabnkhoj-server-1    |                            │   1248 │   │   │   method= │                       
myaiabnkhoj-server-1    |                            │        **options           │                       
myaiabnkhoj-server-1    |                            │   1249 │   │   )           │                       
myaiabnkhoj-server-1    |                            │ ❱ 1250 │   │   return cast │                       
myaiabnkhoj-server-1    |                            │        stream_cls=stream_c │                       
myaiabnkhoj-server-1    |                            │   1251 │                   │                       
myaiabnkhoj-server-1    |                            │   1252 │   def patch(      │                       
myaiabnkhoj-server-1    |                            │   1253 │   │   self,       │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:931 in request  │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │    928 │   │   stream: boo │                       
myaiabnkhoj-server-1    |                            │    929 │   │   stream_cls: │                       
myaiabnkhoj-server-1    |                            │    930 │   ) -> ResponseT  │                       
myaiabnkhoj-server-1    |                            │ ❱  931 │   │   return self │                       
myaiabnkhoj-server-1    |                            │    932 │   │   │   cast_to │                       
myaiabnkhoj-server-1    |                            │    933 │   │   │   options │                       
myaiabnkhoj-server-1    |                            │    934 │   │   │   stream= │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/ │                       
myaiabnkhoj-server-1    |                            │ dist-packages/openai/_base │                       
myaiabnkhoj-server-1    |                            │ _client.py:1030 in         │                       
myaiabnkhoj-server-1    |                            │ _request                   │                       
myaiabnkhoj-server-1    |                            │                            │                       
myaiabnkhoj-server-1    |                            │   1027 │   │   │   │   err │                       
myaiabnkhoj-server-1    |                            │   1028 │   │   │           │                       
myaiabnkhoj-server-1    |                            │   1029 │   │   │   log.deb │                       
myaiabnkhoj-server-1    |                            │ ❱ 1030 │   │   │   raise s │                       
myaiabnkhoj-server-1    |                            │   1031 │   │               │                       
myaiabnkhoj-server-1    |                            │   1032 │   │   return self │                       
myaiabnkhoj-server-1    |                            │   1033 │   │   │   cast_to │                       
myaiabnkhoj-server-1    |                            ╰────────────────────────────╯                       
myaiabnkhoj-server-1    |                            BadRequestError: Error code:                         
myaiabnkhoj-server-1    |                            400 - {'error': {'message':                          
myaiabnkhoj-server-1    |                            "litellm.BadRequestError:                            
myaiabnkhoj-server-1    |                            BadRequestError: GroqException                       
myaiabnkhoj-server-1    |                            - Error code: 400 - {'error':                        
myaiabnkhoj-server-1    |                            {'message': 'response_format`                        
myaiabnkhoj-server-1    |                            does not support streaming',                         
myaiabnkhoj-server-1    |                            'type':                                              
myaiabnkhoj-server-1    |                            'invalid_request_error'}}",                          
myaiabnkhoj-server-1    |                            'type': None, 'param': None,                         
myaiabnkhoj-server-1    |                            'code': 400}}                                        
myaiabnkhoj-server-1    | [01:05:19.184406] DEBUG    uvicorn.error: = connection is       protocol.py:1227
myaiabnkhoj-server-1    |                            CLOSING                                              
myaiabnkhoj-server-1    | [01:05:19.185674] DEBUG    uvicorn.error: > CLOSE 1000 (OK) [2  protocol.py:1178
myaiabnkhoj-server-1    |                            bytes]                                               
myaiabnkhoj-server-1    | [01:05:19.186874] DEBUG    uvicorn.error: = connection is       protocol.py:1497
myaiabnkhoj-server-1    |                            CLOSED                                               
myaiabnkhoj-server-1    | [01:05:19.188183] DEBUG    uvicorn.error: % sending keepalive   protocol.py:1262
myaiabnkhoj-server-1    |                            ping                                                 
myaiabnkhoj-server-1    | [01:05:19.189827] DEBUG    uvicorn.error: ! failing connection  protocol.py:1412
myaiabnkhoj-server-1    |                            with code 1006                                       
myaiabnkhoj-server-1    | [01:05:19.191496] ERROR    uvicorn.error: closing handshake failed server.py:248
myaiabnkhoj-server-1    |                            ╭─ Traceback (most recent call last) ─╮              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/server.py:24 │              
myaiabnkhoj-server-1    |                            │ 4 in handler                        │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    241 │   │   │   │   raise        │              
myaiabnkhoj-server-1    |                            │    242 │   │   │                    │              
myaiabnkhoj-server-1    |                            │    243 │   │   │   try:             │              
myaiabnkhoj-server-1    |                            │ ❱  244 │   │   │   │   await self.c │              
myaiabnkhoj-server-1    |                            │    245 │   │   │   except Connectio │              
myaiabnkhoj-server-1    |                            │    246 │   │   │   │   raise        │              
myaiabnkhoj-server-1    |                            │    247 │   │   │   except Exception │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 770 in close                        │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    767 │   │   """                  │              
myaiabnkhoj-server-1    |                            │    768 │   │   try:                 │              
myaiabnkhoj-server-1    |                            │    769 │   │   │   async with async │              
myaiabnkhoj-server-1    |                            │ ❱  770 │   │   │   │   await self.w │              
myaiabnkhoj-server-1    |                            │    771 │   │   except asyncio.Timeo │              
myaiabnkhoj-server-1    |                            │    772 │   │   │   # If the close f │              
myaiabnkhoj-server-1    |                            │    773 │   │   │   # are full, the  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1236 in write_close_frame           │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1233 │   │   │   │   data = close │              
myaiabnkhoj-server-1    |                            │   1234 │   │   │                    │              
myaiabnkhoj-server-1    |                            │   1235 │   │   │   # 7.1.2. Start t │              
myaiabnkhoj-server-1    |                            │ ❱ 1236 │   │   │   await self.write │              
myaiabnkhoj-server-1    |                            │   1237 │                            │              
myaiabnkhoj-server-1    |                            │   1238 │   async def keepalive_ping │              
myaiabnkhoj-server-1    |                            │   1239 │   │   """                  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1209 in write_frame                 │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1206 │   │   │   │   f"Cannot wri │              
myaiabnkhoj-server-1    |                            │   1207 │   │   │   )                │              
myaiabnkhoj-server-1    |                            │   1208 │   │   self.write_frame_syn │              
myaiabnkhoj-server-1    |                            │ ❱ 1209 │   │   await self.drain()   │              
myaiabnkhoj-server-1    |                            │   1210 │                            │              
myaiabnkhoj-server-1    |                            │   1211 │   async def write_close_fr │              
myaiabnkhoj-server-1    |                            │   1212 │   │   self, close: Close,  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 1198 in drain                       │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │   1195 │   │   │   self.fail_connec │              
myaiabnkhoj-server-1    |                            │   1196 │   │   │   # Wait until the │              
myaiabnkhoj-server-1    |                            │   1197 │   │   │   # with the corre │              
myaiabnkhoj-server-1    |                            │ ❱ 1198 │   │   │   await self.ensur │              
myaiabnkhoj-server-1    |                            │   1199 │                            │              
myaiabnkhoj-server-1    |                            │   1200 │   async def write_frame(   │              
myaiabnkhoj-server-1    |                            │   1201 │   │   self, fin: bool, opc │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │ /usr/local/lib/python3.10/dist-pack │              
myaiabnkhoj-server-1    |                            │ ages/websockets/legacy/protocol.py: │              
myaiabnkhoj-server-1    |                            │ 939 in ensure_open                  │              
myaiabnkhoj-server-1    |                            │                                     │              
myaiabnkhoj-server-1    |                            │    936 │   │   │   │   return       │              
myaiabnkhoj-server-1    |                            │    937 │   │                        │              
myaiabnkhoj-server-1    |                            │    938 │   │   if self.state is Sta │              
myaiabnkhoj-server-1    |                            │ ❱  939 │   │   │   raise self.conne │              
myaiabnkhoj-server-1    |                            │    940 │   │                        │              
myaiabnkhoj-server-1    |                            │    941 │   │   if self.state is Sta │              
myaiabnkhoj-server-1    |                            │    942 │   │   │   # If we started  │              
myaiabnkhoj-server-1    |                            ╰─────────────────────────────────────╯              
myaiabnkhoj-server-1    |                            ConnectionClosedError: sent 1000 (OK);               
myaiabnkhoj-server-1    |                            no close frame received                              
myaiabnkhoj-server-1    | [01:05:19.537140] INFO     uvicorn.error: connection closed        server.py:264
myaiabnkhoj-server-1    | [01:05:19.538533] DEBUG    uvicorn.error: x half-closing TCP    protocol.py:1319
myaiabnkhoj-server-1    |                            connection                                           
myaiabnkhoj-database-1  | 2024-06-27 01:05:25.934 UTC [28] LOG:  checkpoint starting: time
myaiabnkhoj-database-1  | 2024-06-27 01:05:27.270 UTC [28] LOG:  checkpoint complete: wrote 13 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=1.038 s, sync=0.145 s, total=1.336 s; sync files=12, longest=0.113 s, average=0.012 s; distance=15 kB, estimate=15 kB


Ok I tried to wrap that LLAMA3 API (via GROQ) behind LiteLLM as well to ensure it follows the OpenAi format. The error is the same. @sabaimran 

and here is the log from litellm backend: 
litellm-1  | 01:05:17 - LiteLLM Router:ERROR: router.py:2313 - An exception occurred - litellm.BadRequestError: BadRequestError: GroqException - Error code: 400 - {'error': {'message': 'response_format` does not support streaming', 'type': 'invalid_request_error'}} LiteLLM Retried: 1 times, LiteLLM Max Retries: 2
litellm-1  | 01:05:17 - LiteLLM Proxy:ERROR: proxy_server.py:3141 - litellm.proxy.proxy_server.chat_completion(): Exception occured - litellm.BadRequestError: BadRequestError: GroqException - Error code: 400 - {'error': {'message': 'response_format` does not support streaming', 'type': 'invalid_request_error'}} LiteLLM Retried: 1 times, LiteLLM Max Retries: 2
litellm-1  | Traceback (most recent call last):
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/llms/openai.py", line 968, in async_streaming
litellm-1  |     response = await openai_aclient.chat.completions.create(
litellm-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/openai/resources/chat/completions.py", line 1181, in create
litellm-1  |     return await self._post(
litellm-1  |            ^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1790, in post
litellm-1  |     return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
litellm-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1493, in request
litellm-1  |     return await self._request(
litellm-1  |            ^^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1584, in _request
litellm-1  |     raise self._make_status_error_from_response(err.response) from None
litellm-1  | openai.BadRequestError: Error code: 400 - {'error': {'message': 'response_format` does not support streaming', 'type': 'invalid_request_error'}}
litellm-1  | 
litellm-1  | During handling of the above exception, another exception occurred:
litellm-1  | 
litellm-1  | Traceback (most recent call last):
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/main.py", line 379, in acompletion
litellm-1  |     response = await init_response
litellm-1  |                ^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/llms/openai.py", line 991, in async_streaming
litellm-1  |     raise OpenAIError(status_code=e.status_code, message=str(e))
litellm-1  | litellm.llms.openai.OpenAIError: Error code: 400 - {'error': {'message': 'response_format` does not support streaming', 'type': 'invalid_request_error'}}
litellm-1  | 
litellm-1  | During handling of the above exception, another exception occurred:
litellm-1  | 
litellm-1  | Traceback (most recent call last):
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/proxy/proxy_server.py", line 3043, in chat_completion
litellm-1  |     responses = await llm_responses
litellm-1  |                 ^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 643, in acompletion
litellm-1  |     raise e
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 631, in acompletion
litellm-1  |     response = await self.async_function_with_fallbacks(**kwargs)
litellm-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 2315, in async_function_with_fallbacks
litellm-1  |     raise original_exception
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 2177, in async_function_with_fallbacks
litellm-1  |     raise e
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 2160, in async_function_with_fallbacks
litellm-1  |     response = await self.async_function_with_retries(*args, **kwargs)
litellm-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 2415, in async_function_with_retries
litellm-1  |     raise original_exception
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 2337, in async_function_with_retries
litellm-1  |     response = await original_function(*args, **kwargs)
litellm-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 773, in _acompletion
litellm-1  |     raise e
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/router.py", line 745, in _acompletion
litellm-1  |     response = await _response
litellm-1  |                ^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/utils.py", line 1442, in wrapper_async
litellm-1  |     raise e
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/utils.py", line 1270, in wrapper_async
litellm-1  |     result = await original_function(*args, **kwargs)
litellm-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/main.py", line 407, in acompletion
litellm-1  |     raise exception_type(
litellm-1  |           ^^^^^^^^^^^^^^^
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/utils.py", line 7503, in exception_type
litellm-1  |     raise e
litellm-1  |   File "/usr/local/lib/python3.11/site-packages/litellm/utils.py", line 5818, in exception_type
litellm-1  |     raise BadRequestError(
litellm-1  | litellm.exceptions.BadRequestError: litellm.BadRequestError: BadRequestError: GroqException - Error code: 400 - {'error': {'message': 'response_format` does not support streaming', 'type': 'invalid_request_error'}} LiteLLM Retried: 1 times, LiteLLM Max Retries: 2
litellm-1  | 
litellm-1  | 01:05:17 - LiteLLM Proxy:ERROR: _common.py:120 - Giving up chat_completion(...) after 1 tries (litellm.proxy._types.ProxyException)
litellm-1  | INFO:     172.19.0.11:60098 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request

@sabaimran 

Could it be something with the streaming settings under the /notes mode?
@sabaimran  @debanjum Not sure if this is just for me or any crucial step I'm missing, but so far: Only OpenAPI endpoint works when talking to notes. All other OpenAI-compatible endpoints fail when talking to notes and only work in /general mode. 

I have tried:
- GROQ API (llama3-70b-8192 model)
- LLAMA3 served from LiteLLM
- NousResearch/Hermes-2-Pro-Mistral-7B-GGUF

![image](https://github.com/khoj-ai/khoj/assets/32351181/a5b9ce68-e2e6-4e90-a0b0-58d86752193b)

So far, this part looks the most suspicious in the log:

![image](https://github.com/khoj-ai/khoj/assets/32351181/90f24ca6-2f2a-4112-8646-bd19c3bbaf1f)

Btw, the backend has a myriad of configuration options (good job to Khoj for making it so configurable), but the backend documentation is not catching up with that :). Would be helpful to add them!


@stevennt , sorry for the long gap in responding to this! I see why this is happening. It's because the OpenAI API Compatible server you're using (in this case, via LiteLLM or Groq) fails when it sees a parameter it doesn't recognize. Specifically, it seems to be getting triggered by `response_format`, which allows is to enforce the JSON scheme with OpenAI. 

I don't seem to be running into this error with any of the OpenAI API compatible servers we're using. For LiteLLM, I think you should be able to configure the setting for [drop params](https://docs.litellm.ai/docs/completion/drop_params) to change the behavior of this failure.
Hey @sabaimran excellent. It was indeed that drop_params that solved the problem. Khoj seems to work now with the LiteLLM & Groq combination.
Thanks.

Fix patch:
diff --git a/docker-compose.yml b/docker-compose.yml
index 1b79f784d..3c5fe9f4d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -44,11 +44,20 @@ services:
       - KHOJ_DEBUG=False
       - KHOJ_ADMIN_EMAIL=username@example.com
       - KHOJ_ADMIN_PASSWORD=password
-      # Uncomment the following lines to make your instance publicly accessible.
-      # Replace the domain with your domain. Proceed with caution, especially if you are using anonymous mode.
+      # Uncomment lines below to use chat models by each provider.
+      # Ensure you set your provider specific API keys.
+      # ---
+      # - OPENAI_API_KEY=your_openai_api_key
+      # - GEMINI_API_KEY=your_gemini_api_key
+      # - ANTHROPIC_API_KEY=your_anthropic_api_key
+      # Uncomment the necessary lines below to make your instance publicly accessible.
+      # Replace the KHOJ_DOMAIN with either your domain or IP address (no http/https prefix).
+      # Proceed with caution, especially if you are using anonymous mode.
+      # ---
       # - KHOJ_NO_HTTPS=True
       # - KHOJ_DOMAIN=192.168.0.104
-    command: --host="0.0.0.0" --port=42110 -vv --anonymous-mode
+      # - KHOJ_DOMAIN=khoj.example.com
+    command: --host="0.0.0.0" --port=42110 -vv --anonymous-mode --non-interactive
 
 
 volumes:
diff --git a/documentation/assets/img/example_search_model_admin_settings.png b/documentation/assets/img/example_search_model_admin_settings.png
new file mode 100644
index 000000000..9efd0abbf
Binary files /dev/null and b/documentation/assets/img/example_search_model_admin_settings.png differ
diff --git a/documentation/docs/advanced/admin.md b/documentation/docs/advanced/admin.md
new file mode 100644
index 000000000..305741a84
--- /dev/null
+++ b/documentation/docs/advanced/admin.md
@@ -0,0 +1,73 @@
+# Admin Panel
+> Describes the Khoj settings configurable via the admin panel
+
+## App Settings
+### Agents
+Add all the agents you want to use for your different use-cases like Writer, Researcher, Therapist etc.
+- `Personality`: This is a prompt to tell the chat model how to tune the personality of the agent.
+- `Chat model`: The chat model to use for the agent.
+- `Name`: The name of the agent. This field helps give the agent a unique identity across the app.
+- `Avatar`: Url to the agents profile picture. It help give the agent a unique visual identity across the app.
+- `Style color`, `Style icon`: These fields help give the agent a unique, visually identifiable identity across the app.
+- `Slug`: This is the agent name to use in urls.
+- `Public`: Check this if the agent is expected to be visible to all users on this Khoj server.
+- `Managed by admin`: Check this if the agent is managed by admin, not by any user.
+- `Creator`: The user who created the agent.
+- `Tools`: The list of tools available to this agent. Tools include notes, image, online. This field is not currently configurable and only supports all tools (i.e `["*"]`)
+
+### Chat Model Options
+Add all the chat models you want to try, use and switch between for your different use-cases. For each chat model you add:
+- `Chat model`: The name of an [OpenAI](https://platform.openai.com/docs/models), [Anthropic](https://docs.anthropic.com/en/docs/about-claude/models#model-names), [Gemini](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-models) or [Offline](https://huggingface.co/models?pipeline_tag=text-generation&library=gguf) chat model.
+- `Model type`: The chat model provider like `OpenAI`, `Offline`.
+- `Vision enabled`: Set to `true` if your model supports vision. This is currently only supported for vision capable OpenAI models like `gpt-4o`
+- `Max prompt size`, `Subscribed max prompt size`: These are optional fields. They are used to truncate the context to the maximum context size that can be passed to the model. This can help with accuracy and cost-saving.<br />
+- `Tokenizer`: This is an optional field. It is used to accurately count tokens and truncate context passed to the chat model to stay within the models max prompt size.
+  ![example configuration for chat model options](/img/example_chatmodel_option.png)
+
+### Server Chat Settings
+The server chat settings are used as:
+1. The default chat models for subscribed (`Advanced` field) and unsubscribed (`Default` field) users.
+2. The chat model for all intermediate steps like intent detection, web search etc. during chat response generation.
+
+If a server chat setting is not added the first ChatModelOption in your config is used as the default chat model.
+
+To add a server chat setting:
+- Set your preferred default chat models in the `Default` fields of your [ServerChatSettings](http://localhost:42110/server/admin/database/serverchatsettings/)
+- The `Advanced` field doesn't need to be set when self-hosting. When unset, the `Default` chat model is used for all users and the intermediate steps.
+
+
+### OpenAI Processor Conversation Configs
+These settings configure chat model providers to be accessed over API.
+The name of this setting is kind of a misnomer, we know, it'll hopefully be changed at some point.
+For each chat model provider you [add](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add):
+- `Api key`: Set to your [OpenAI](https://platform.openai.com/api-keys), [Anthropic](https://console.anthropic.com/account/keys) or [Gemini](https://aistudio.google.com/app/apikey) API keys.
+- `Name`: Give the configuration any friendly name like `OpenAI`, `Gemini`, `Anthropic`.
+- `Api base url`: Set the API base URL. This is only relevant to set if you're using another OpenAI-compatible proxy server like [Ollama](/advanced/ollama) or [LMStudio](/advanced/lmstudio).
+  ![example configuration for openai processor](/img/example_openai_processor_config.png)
+
+### Search Model Configs
+Search models are used to generate vector embeddings of your documents for natural language search and chat. You can choose any [embeddings models on HuggingFace](https://huggingface.co/models?pipeline_tag=sentence-similarity) to try, use for your to create vector embeddings of your documents for natural language search and chat.
+
+<img src="/img/example_search_model_admin_settings.png" alt="Example Search Model Settings" style={{width: 500}} />
+
+### Text to Image Model Options
+Add text to image generation models with these settings. Khoj currently supports text to image models available via OpenAI, Stability or Replicate API
+- `api-key`: Set to your OpenAI, Stability or Replicate API key
+- `model`: Set the model name available over the selected model provider
+- `model-type`: Set to the appropiate model provider
+- `openai-config`: For image generation models available via OpenAI (compatible) API you can set the appropriate OpenAI Processor Conversation Settings instead of specifying the `api-key` field above
+
+### Speech to Text Model Options
+Add speech to text models with these settings. Khoj currently only supports whisper speech to text model via OpenAI API or Offline
+
+### Voice Model Options
+Add text to speech models with these settings. Khoj currently supports models from [ElevenLabs](https://elevenlabs.io/).
+
+## User Data
+- Users, Entrys, Conversations, Subscriptions, Github configs, Notion configs, User search configs, User conversation configs, User voice configs
+
+## Miscellaneous Data
+- Process Locks: Persistent Locks for Automations
+- Client Applications:
+
+Client applications allow you to setup third party applications that can query your Khoj server using a client application ID + secret. The secret would go in a bearer token.
diff --git a/documentation/docs/advanced/authentication.md b/documentation/docs/advanced/authentication.md
index 456f0c0c7..e5a002d41 100644
--- a/documentation/docs/advanced/authentication.md
+++ b/documentation/docs/advanced/authentication.md
@@ -7,7 +7,7 @@ This is only helpful for self-hosted users or teams. If you're using [Khoj Cloud
 By default, most of the instructions for self-hosting Khoj assume a single user, and so the default configuration is to run in anonymous mode. However, if you want to enable authentication, you can do so either with with [Magic Links](#using-magic-links) or [Google OAuth](#using-google-oauth) as shown below. This can be helpful to make Khoj securely accessible to you and your team.
 
 :::tip[Note]
-Remove the `--anonymous-mode` flag in your start up command to enable authentication.
+Remove the `--anonymous-mode` flag from your khoj start up command or docker-compose file to enable authentication.
 :::
 
 ## Using Magic Links
diff --git a/documentation/docs/advanced/remote.md b/documentation/docs/advanced/remote.md
new file mode 100644
index 000000000..94aece1f5
--- /dev/null
+++ b/documentation/docs/advanced/remote.md
@@ -0,0 +1,20 @@
+# Remote Access
+
+By default self-hosted Khoj is only accessible on the machine it is running. To securely access it from a remote machine:
+- Set the `KHOJ_DOMAIN` environment variable to your remotely accessible ip or domain via shell or docker-compose.yml.
+  Examples: `KHOJ_DOMAIN=my.khoj-domain.com`, `KHOJ_DOMAIN=192.168.0.4`.
+- Ensure the Khoj Admin password and `KHOJ_DJANGO_SECRET_KEY` environment variable are securely set.
+- Setup [Authentication](/advanced/authentication).
+- Open access to the Khoj port (default: 42110) from your OS and Network firewall.
+
+:::warning[Use HTTPS certificate]
+To expose Khoj on a custom domain over the public internet, use of an SSL certificate is strongly recommended. You can use [Let's Encrypt](https://letsencrypt.org/) to get a free SSL certificate for your domain.
+
+To disable HTTPS, set the `KHOJ_NO_HTTPS` environment variable to `True`. This can be useful if Khoj is only accessible behind a secure, private network.
+:::
+
+:::info[Try Tailscale]
+You can use [Tailscale](https://tailscale.com/) for easy, secure access to your self-hosted Khoj over the network.
+1. Set `KHOJ_DOMAIN` to your machines [tailscale ip](https://tailscale.com/kb/1452/connect-to-devices#identify-your-devices) or [fqdn on tailnet](https://tailscale.com/kb/1081/magicdns#fully-qualified-domain-names-vs-machine-names). E.g `KHOJ_DOMAIN=100.4.2.0` or `KHOJ_DOMAIN=khoj.tailfe8c.ts.net`
+2. Access Khoj by opening `http://tailscale-ip-of-server:42110` or `http://fqdn-of-server:42110` from any device on your tailscale network
+:::
diff --git a/documentation/docs/get-started/setup.mdx b/documentation/docs/get-started/setup.mdx
index 40b892aef..4d4798258 100644
--- a/documentation/docs/get-started/setup.mdx
+++ b/documentation/docs/get-started/setup.mdx
@@ -14,37 +14,63 @@ import Tabs from '@theme/Tabs';
 import TabItem from '@theme/TabItem';
 ```
 
-## Setup
+## Setup Khoj
 These are the general setup instructions for self-hosted Khoj.
-You can install the Khoj server using either Docker or Pip.
+You can install the Khoj server using either [Docker](?server=docker) or [Pip](?server=pip).
 
 :::info[Offline Model + GPU]
 If you want to use the offline chat model and you have a GPU, you should use Installation Option 2  - local setup via the Python package directly. Our Docker image doesn't currently support running the offline chat model on GPU, making inference times really slow.
 :::
 
-### 1A. Install Method 1: Docker
-
-#### Prerequisites
-1. Install Docker Engine. See [official instructions](https://docs.docker.com/engine/install/).
-2. Ensure you have Docker Compose. See [official instructions](https://docs.docker.com/compose/install/).
-
-#### Setup
-
-1. Get the sample docker-compose file [from Github](https://github.com/khoj-ai/khoj/blob/master/docker-compose.yml).
-2. Configure the environment variables in the docker-compose.yml to your choosing.<br />
-   Note: *Your admin account will automatically be created based on the admin credentials in that file, so pay attention to those.*
-3. Now start the container by running the following command in the same directory as your docker-compose.yml file. This will automatically setup the database and run the Khoj server.
+<Tabs groupId="server" queryString>
+  <TabItem value="docker" label="Docker">
+    <Tabs groupId="operating-systems" queryString="os">
+      <TabItem value="macos" label="MacOS">
+        <h3>Prerequisites</h3>
+        Install [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/)
+      </TabItem>
+      <TabItem value="windows" label="Windows">
+      <h3>Prerequisites</h3>
+      1. Install [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) and restart your machine
+         ```shell
+         # Run in PowerShell
+         wsl --install
+         ```
+      2. Install [Docker Desktop](https://docs.docker.com/desktop/install/windows-install/) with **[WSL2 backend](https://docs.docker.com/desktop/wsl/#turn-on-docker-desktop-wsl-2)** (default)
+      </TabItem>
+      <TabItem value="linux" label="Linux">
+        <h3>Prerequisites</h3>
+        Install [Docker Desktop](https://docs.docker.com/desktop/install/windows-install/).
+        You can also use your package manager to install Docker Engine & Docker Compose.
+      </TabItem>
+    </Tabs>
+
+<h3>Setup</h3>
+1. Download the Khoj docker-compose.yml file [from Github](https://github.com/khoj-ai/khoj/blob/master/docker-compose.yml)
    ```shell
+   # Windows users should use their WSL2 terminal to run these commands
+   mkdir ~/.khoj && cd ~/.khoj
+   wget https://raw.githubusercontent.com/khoj-ai/khoj/master/docker-compose.yml
+   ```
+2. Configure the environment variables in the docker-compose.yml
+   - Set `KHOJ_ADMIN_PASSWORD`, `KHOJ_DJANGO_SECRET_KEY` (and optionally the `KHOJ_ADMIN_EMAIL`) to something secure. This allows you to customize Khoj later via the admin panel.
+   - Set `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `GEMINI_API_KEY` to your API key if you want to use OpenAI, Anthropic or Gemini chat models respectively.
+3. Start Khoj by running the following command in the same directory as your docker-compose.yml file.
+   ```shell
+   # Windows users should use their WSL2 terminal to run these commands
+   cd ~/.khoj
    docker-compose up
    ```
 
-Khoj should now be running at http://localhost:42110! You can see the web UI in your browser.
-
-### 1B. Install Method 2: Pip
+:::info[Remote Access]
+By default Khoj is only accessible on the machine it is running. To access Khoj from a remote machine see [Remote Access Docs](/advanced/remote).
+:::
 
-#### Prerequisites
+Your setup is complete once you see `🌖 Khoj is ready to use` in the server logs on your terminal.
+  </TabItem>
+  <TabItem value="pip" label="Pip">
 
-##### Install Postgres (with PgVector)
+<h3>1. Install Postgres (with PgVector)</h3>
 
 Khoj uses Postgres DB for all server configuration and to scale to multi-user setups. It uses the pgvector package in Postgres to manage your document embeddings. Both Postgres and pgvector need to be installed for Khoj to work.
 
@@ -66,32 +92,32 @@ Install [Postgres.app](https://postgresapp.com/). This comes pre-installed with
     </TabItem>
   </Tabs>
 
-##### Create the Khoj database
-
-Make sure to update your environment variables to match your Postgres configuration if you're using a different name. The default values should work for most people. When prompted for a password, you can use the default password `postgres`, or configure it to your preference. Make sure to set the environment variable `POSTGRES_PASSWORD` to the same value as the password you set here.
+<h3>2. Create the Khoj database</h3>
 
-  <Tabs groupId="operating-systems" queryString="os">
-    <TabItem value="macos" label="MacOS">
+<Tabs groupId="operating-systems" queryString="os">
+  <TabItem value="macos" label="MacOS">
     ```shell
-createdb khoj -U postgres --password
+    createdb khoj -U postgres --password
     ```
-    </TabItem>
-    <TabItem value="windows" label="Windows">
+  </TabItem>
+  <TabItem value="windows" label="Windows">
     ```shell
-createdb -U postgres khoj --password
-      ```
-    </TabItem>
-    <TabItem value="linux" label="Linux">
-      ```shell
-sudo -u postgres createdb khoj --password
-      ```
-    </TabItem>
-  </Tabs>
+    createdb -U postgres khoj --password
+    ```
+  </TabItem>
+  <TabItem value="linux" label="Linux">
+    ```shell
+    sudo -u postgres createdb khoj --password
+    ```
+  </TabItem>
+</Tabs>
 
-#### Install Khoj server
+:::info[Postgres Env Config]
+Make sure to update the `POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_USER`, `POSTGRES_DB` or `POSTGRES_PASSWORD` environment variables to match any customizations in your Postgres configuration.
+:::
 
-##### Install Khoj Server
-- *Make sure [python](https://realpython.com/installing-python/) and [pip](https://pip.pypa.io/en/stable/installation/) are installed on your machine*
+<h3>3. Install Khoj Server</h3>
+- Make sure [python](https://realpython.com/installing-python/) and [pip](https://pip.pypa.io/en/stable/installation/) are installed on your machine
 - Check [llama-cpp-python setup](https://python.langchain.com/docs/integrations/llms/llamacpp#installation) if you hit any llama-cpp issues with the installation
 
 Run the following command in your terminal to install the Khoj server.
@@ -107,7 +133,7 @@ python -m pip install khoj
     ```
     </TabItem>
     <TabItem value="windows" label="Windows">
-      In PowerShell on Windows
+      Run the following command in PowerShell on Windows
       ```shell
  # 1. (Optional) To use NVIDIA (CUDA) GPU
  $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
@@ -134,56 +160,47 @@ python -m pip install khoj
     </TabItem>
   </Tabs>
 
-##### Start Khoj Server
-
-Before getting started, configure the following environment variables in your terminal for the first run
-
-  <Tabs groupId="operating-systems" queryString="os">
-    <TabItem value="macos" label="MacOS">
-      ```shell
-      export KHOJ_ADMIN_EMAIL=<your-email>
-      export KHOJ_ADMIN_PASSWORD=<your-password>
-      ```
-    </TabItem>
-    <TabItem value="windows" label="Windows">
-      If you're using PowerShell:
-      ```shell
-      $env:KHOJ_ADMIN_EMAIL="<your-email>"
-      $env:KHOJ_ADMIN_PASSWORD="<your-password>"
-      ```
-    </TabItem>
-    <TabItem value="linux" label="Linux">
-      ```shell
-      export KHOJ_ADMIN_EMAIL=<your-email>
-      export KHOJ_ADMIN_PASSWORD=<your-password>
-      ```
-    </TabItem>
-  </Tabs>
-
+<h3>4. Start Khoj Server</h3>
 
-Run the following command from your terminal to start the Khoj backend and open Khoj in your browser.
+Run the following command from your terminal to start the Khoj service.
 
 ```shell
 khoj --anonymous-mode
 ```
-`--anonymous-mode` allows you to run the server without setting up Google credentials for login. This allows you to use any of the clients without a login wall. If you want to use Google login, you can skip this flag, but you will have to add your Google developer credentials.
+`--anonymous-mode` allows access to Khoj without requiring login. This is usually fine for local only, single user setups. If you need authentication follow the [authentication setup docs](/advanced/authentication).
 
-On the first run, you will be prompted to input credentials for your admin account and do some basic configuration for your chat model settings. Once created, you can go to http://localhost:42110/server/admin and login with the credentials you just created.
+<h4>First Run</h4>
+On the first run of the above command, you will be prompted to:
+1. Create an admin account with a email and secure password
+2. Customize the chat models to enable
+   - Keep your [OpenAI](https://platform.openai.com/api-keys), [Anthropic](https://console.anthropic.com/account/keys), [Gemini](https://aistudio.google.com/app/apikey) API keys and [OpenAI](https://platform.openai.com/docs/models), [Anthropic](https://docs.anthropic.com/en/docs/about-claude/models#model-names), [Gemini](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-models), [Offline](https://huggingface.co/models?pipeline_tag=text-generation&library=gguf) chat model names handy to set any of them up during first run.
+3. Your setup is complete once you see `🌖 Khoj is ready to use` in the server logs on your terminal!
 
-Khoj should now be running at http://localhost:42110. You can see the web UI in your browser.
 
-Note: To start Khoj automatically in the background use [Task scheduler](https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10) on Windows or [Cron](https://en.wikipedia.org/wiki/Cron) on Mac, Linux (e.g. with `@reboot khoj`)
+:::tip[Auto Start]
+To start Khoj automatically in the background use [Task scheduler](https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10) on Windows or [Cron](https://en.wikipedia.org/wiki/Cron) on Mac, Linux (e.g. with `@reboot khoj`)
+:::
+  </TabItem>
+</Tabs>
 
+## Use Khoj
 
-### 2. Configure
-#### Login to the Khoj Admin Panel
+You can now open the web app at http://localhost:42110 and start interacting!<br />
+Nothing else is necessary, but you can customize your setup further by following the steps below.
+
+:::info[First Message to Offline Chat Model]
+The offline chat model gets downloaded when you first send a message to it. The download can take a few minutes! Subsequent messages should be faster.
+:::
+
+### Add Chat Models
+<h4>Login to the Khoj Admin Panel</h4>
 Go to http://localhost:42110/server/admin and login with the admin credentials you setup during installation.
 
 :::info[CSRF Error]
 Ensure you are using **localhost, not 127.0.0.1**, to access the admin panel to avoid the CSRF error.
 :::
 
-:::info[DISALLOWED HOST Error]
+:::info[DISALLOWED HOST or Bad Request (400) Error]
 You may hit this if you try access Khoj exposed on a custom domain (e.g. 192.168.12.3 or example.com) or over HTTP.
 Set the environment variables KHOJ_DOMAIN=your-domain and KHOJ_NO_HTTPS=false if required to avoid this error.
 :::
@@ -192,93 +209,132 @@ Set the environment variables KHOJ_DOMAIN=your-domain and KHOJ_NO_HTTPS=false if
 Using Safari on Mac? You might not be able to login to the admin panel. Try using Chrome or Firefox instead.
 :::
 
-#### Configure Chat Model
+<h4>Configure Chat Model</h4>
 Setup which chat model you'd want to use. Khoj supports local and online chat models.
 
-:::tip[Multiple Chat Models]
-Add a `ServerChatSettings` with `Default` and `Summarizer` fields set to your preferred chat model via [the admin panel](http://localhost:42110/server/admin/database/serverchatsettings/add/). Otherwise Khoj defaults to use the first chat model in your [ChatModelOptions](http://localhost:42110/server/admin/database/chatmodeloptions/) for all non chat response generation tasks.
-:::
-
-##### Configure OpenAI Chat
+<Tabs groupId="chatmodel" queryString>
+  <TabItem value="openai" label="OpenAI">
 
 :::info[Ollama Integration]
 Using Ollama? See the [Ollama Integration](/advanced/ollama) section for more custom setup instructions.
 :::
 
-1. Go to the [OpenAI settings](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/) in the server admin settings to add an OpenAI processor conversation config. This is where you set your API key and server API base URL. The API base URL is optional - it's only relevant if you're using another OpenAI-compatible proxy server.
-
+1. Create a new [OpenAI processor conversation config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add) in the server admin settings. This is kind of a misnomer, we know.
+   - Add your [OpenAI API key](https://platform.openai.com/api-keys)
+   - Give the configuration a friendly name like `OpenAI`
+   - (Optional) Set the API base URL. It is only relevant if you're using another OpenAI-compatible proxy server like [Ollama](/advanced/ollama) or [LMStudio](/advanced/lmstudio).
 ![example configuration for openai processor](/img/example_openai_processor_config.png)
-
-2. Go over to configure your [chat model options](http://localhost:42110/server/admin/database/chatmodeloptions/). Set the `chat-model` field to a supported chat model[^1] of your choice. For example, you can specify `gpt-4o` if you're using OpenAI.
+2. Create a new [chat model options](http://localhost:42110/server/admin/database/chatmodeloptions/add)
+    - Set the `chat-model` field to an [OpenAI chat model](https://platform.openai.com/docs/models). Example: `gpt-4o`.
     - Make sure to set the `model-type` field to `OpenAI`.
-    - The `tokenizer` and `max-prompt-size` fields are optional. Set them only if you're sure of the tokenizer or token limit for the model you're using. Contact us if you're unsure what to do here.
     - If your model supports vision, set the `vision enabled` field to `true`. This is currently only supported for OpenAI models with vision capabilities.
-
-![example configuration for chat model options](/img/example_chatmodel_option.png)
-
-##### Configure Anthropic Chat
-1. Go to the [OpenAI settings](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/) in the server admin settings to add an OpenAI processor conversation config. This is kind of a misnomer, we know. Do not configure the API base url. Just add your API key and give the configuration a friendly name.
-2. Go over to configure your [chat model options](http://localhost:42110/server/admin/database/chatmodeloptions/). Set the `chat-model` field to a supported chat model by Anthropic of your choice. For example, you can specify `claude-3-5-sonnet-20240620`.
-    - Make sure to set the `model-type` field to `Anthropic`.
     - The `tokenizer` and `max-prompt-size` fields are optional. Set them only if you're sure of the tokenizer or token limit for the model you're using. Contact us if you're unsure what to do here.
-
-##### Configure Offline Chat
-
-Offline chat stays completely private and can work without internet using open-source models.
-
-**System Requirements**:
+![example configuration for chat model options](/img/example_chatmodel_option.png)
+  </TabItem>
+  <TabItem value="anthropic" label="Anthropic">
+1. Create a new [OpenAI processor conversation config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add) in the server admin settings. This is kind of a misnomer, we know.
+   - Add your [Anthropic API key](https://console.anthropic.com/account/keys)
+   - Give the configuration a friendly name like `Anthropic`. Do not configure the API base url.
+2. Create a new [chat model options](http://localhost:42110/server/admin/database/chatmodeloptions/add)
+    - Set the `chat-model` field to an [Anthropic chat model](https://docs.anthropic.com/en/docs/about-claude/models#model-names). Example: `claude-3-5-sonnet-20240620`.
+    - Set the `model-type` field to `Anthropic`.
+    - Set the `Openai config` field to the OpenAI processor conversation config for Anthropic you created in step 1.
+  </TabItem>
+  <TabItem value="gemini" label="Gemini">
+1. Create a new [OpenAI processor conversation config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add) in the server admin settings. This is kind of a misnomer, we know.
+   - Add your [Gemini API key](https://aistudio.google.com/app/apikey)
+   - Give the configuration a friendly name like `Gemini`. Do not configure the API base url.
+2. Create a new [chat model options](http://localhost:42110/server/admin/database/chatmodeloptions/add)
+    - Set the `chat-model` field to a [Google Gemini chat model](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-models). Example: `gemini-1.5-flash`.
+    - Set the `model-type` field to `Gemini`.
+    - Set the `Openai config` field to the OpenAI processor conversation config for Gemini you created in step 1.
+
+  </TabItem>
+  <TabItem value="offline" label="Offline">
+Offline chat stays completely private and can work without internet using any open-weights model.
+
+:::tip[System Requirements]
 - Minimum 8 GB RAM. Recommend **16Gb VRAM**
 - Minimum **5 GB of Disk** available
-- A CPU supporting [AVX or AVX2 instructions](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) is required
-- An Nvidia, AMD GPU or a Mac M1+ machine would significantly speed up chat response times
-
-Any chat model on Huggingface in GGUF format can be used for local chat. Here's how you can set it up:
-
-1. No need to setup a conversation processor config!
-2. Go over to configure your [chat model options](http://localhost:42110/server/admin/database/chatmodeloptions/). Set the `chat-model` field to a supported chat model[^1] of your choice. For example, we recommend `bartowski/Meta-Llama-3.1-8B-Instruct-GGUF`, but [any gguf model on huggingface](https://huggingface.co/models?library=gguf) should work.
-  - Make sure to set the `model-type` to `Offline`. Do not set `openai config`.
-  - The `tokenizer` and `max-prompt-size` fields are optional. You can set these for non-standard models (i.e not Mistral or Llama based models) or when you know the token limit of the model to improve context stuffing.
-
-#### Share your data
-You can sync your files and folders with Khoj using the [Desktop](/clients/desktop#setup), [Obsidian](/clients/obsidian#setup), or [Emacs](/clients/emacs#setup) clients or just drag and drop specific files on the [website](/clients/web#upload-documents). You can also directly sync your [Notion workspace](/data-sources/notion_integration).
-
-[^1]: Khoj, by default, can use [OpenAI GPT3.5+ chat models](https://platform.openai.com/docs/models/overview) or [GGUF chat models](https://huggingface.co/models?library=gguf). See [this section](/advanced/use-openai-proxy) on how to locally use OpenAI-format compatible proxy servers.
+- A Nvidia, AMD GPU or a Mac M1+ machine would significantly speed up chat responses
+:::
 
-### 3. Use Khoj 🚀
+1. Get the name of your preferred chat model from [HuggingFace](https://huggingface.co/models?pipeline_tag=text-generation&library=gguf). *Most GGUF format chat models are supported*.
+2. Open the [create chat model page](http://localhost:42110/server/admin/database/chatmodeloptions/add/) on the admin panel
+3. Set the `chat-model` field to the name of your preferred chat model
+   - Make sure the `model-type` is set to `Offline`
+4. Set the newly added chat model as your preferred model in your [User chat settings](http://localhost:42110/settings) and [Server chat settings](http://localhost:42110/server/admin/database/serverchatsettings/).
+5. Restart the Khoj server and [start chatting](http://localhost:42110) with your new offline model!
+  </TabItem>
+</Tabs>
 
-Now open http://localhost:42110 to start interacting with Khoj!
+:::tip[Multiple Chat Models]
+Set your preferred default chat model in the `Default`, `Advanced` fields of your [ServerChatSettings](http://localhost:42110/server/admin/database/serverchatsettings/).
+Khoj uses these chat model for all intermediate steps like intent detection, web search etc.
+:::
 
-### 4. Install Khoj Clients (Optional)
-Khoj exposes a web interface to search, chat and configure by default.<br />
-You can install a Khoj client to sync your documents or to easily access Khoj from within Obsidian, Emacs or your OS.
+:::info[Chat Model Fields]
+ - The `tokenizer` and `max-prompt-size` fields are optional. Set them only if you're sure of the tokenizer or token limit for the model you're using. This improves context stuffing. Contact us if you're unsure what to do here.
+ - Only tick the `vision enabled` field for OpenAI models with vision capabilities like gpt-4o. Vision capabilities in other chat models is not currently utilized.
+:::
 
-- **Khoj Desktop**:<br />
-[Install](/clients/desktop#setup) the Khoj Desktop app.
+### Sync your Knowledge
 
-- **Khoj Obsidian**:<br />
-[Install](/clients/obsidian#setup) the Khoj Obsidian plugin.
+- You can chat with your notes and documents using Khoj.
+- Khoj can keep your files and folders synced using the Khoj [Desktop](/clients/desktop#setup), [Obsidian](/clients/obsidian#setup) or [Emacs](/clients/emacs#setup) clients.
+- Your [Notion workspace](/data-sources/notion_integration) can be directly synced from the web app.
+- You can also just drag and drop specific files you want to chat with on the [Web app](/clients/web#upload-documents).
 
-- **Khoj Emacs**:<br />
-[Install](/clients/emacs#setup) khoj.el
+### Setup Khoj Clients
+The Khoj web app is available by default to chat, search and configure Khoj.<br />
+You can also install a Khoj client to easily access it from Obsidian, Emacs, Whatsapp or your OS and keep your documents synced with Khoj.
 
-#### Setup host URL
+:::info[Note]
 Set the host URL on your clients settings page to your Khoj server URL. By default, use `http://127.0.0.1:42110` or `http://localhost:42110`. Note that `localhost` may not work in all cases.
+:::
+
+<Tabs groupId="client" queryString>
+  <TabItem value="desktop" label="Desktop">
+  - Read the Khoj Desktop app [setup docs](/clients/desktop#setup).
+  </TabItem>
+  <TabItem value="emacs" label="Emacs">
+  - Read the Khoj Emacs package [setup docs](/clients/emacs#setup).
+  </TabItem>
+  <TabItem value="obsidian" label="Obsidian">
+  - Read the Khoj Obsidian plugin [setup docs](/clients/obsidian#setup).
+  </TabItem>
+  <TabItem value="whatsapp" label="Whatsapp">
+  - Read the Khoj Whatsapp app [setup docs](/clients/whatsapp).
+  </TabItem>
+</Tabs>
 
 ## Upgrade
 
-  <Tabs groupId="environment">
-    <TabItem value="localsetup" label="Local Setup">
+### Upgrade Server
+  <Tabs groupId="server" queryString>
+    <TabItem value="pip" label="Pip">
       ```shell
       pip install --upgrade khoj
       ```
       *Note: To upgrade to the latest pre-release version of the khoj server run below command*
     </TabItem>
     <TabItem value="docker" label="Docker">
-      From the same directory where you have your `docker-compose` file, this will fetch the latest build and upgrade your server.
+      Run the commands below from the same directory where you have your `docker-compose.yml` file.
+      This will fetch the latest build and upgrade your server.
       ```shell
+      # Windows users should use their WSL2 terminal to run these commands
+      cd ~/.khoj  # assuming your khoj docker-compose.yml file is here
       docker-compose up --build
       ```
     </TabItem>
+  </Tabs>
+
+### Upgrade Clients
+  <Tabs groupId="client" queryString>
+    <TabItem value="desktop" label="Desktop">
+      - The Desktop app automatically updates to the latest released version on restart.
+      - You can manually download the latest version from the [Khoj Website](https://khoj.dev/downloads).
+    </TabItem>
     <TabItem value="emacs" label="Emacs">
     - Use your Emacs Package Manager to Upgrade
     - See [khoj.el package setup](/clients/emacs#setup) for details
@@ -290,9 +346,9 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau
   </Tabs>
 
 ## Uninstall
-
-  <Tabs groupId="environment">
-    <TabItem value="localsetup" label="Local Setup">
+### Uninstall Server
+  <Tabs groupId="server" queryString>
+    <TabItem value="pip" label="Pip">
     ```shell
     # uninstall khoj server
     pip uninstall khoj
@@ -302,19 +358,25 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau
     ```
     </TabItem>
     <TabItem value="docker" label="Docker">
-    From the same directory where you have your `docker-compose` file, run the command below to remove the server to delete its containers, networks, images and volumes.
+    Run the command below from the same directory where you have your `docker-compose` file.
+    This will remove the server containers, networks, images and volumes.
 
     ```shell
     docker-compose down --volumes
     ```
     </TabItem>
+  </Tabs>
+
+### Uninstall Clients
+  <Tabs groupId="client" queryString>
+    <TabItem value="desktop" label="Desktop">
+    Uninstall the Khoj Desktop client in the standard way from your OS.
+    </TabItem>
     <TabItem value="emacs" label="Emacs">
-    Uninstall the khoj Emacs, or desktop client in the standard way from Emacs or your OS respectively
-    You can also `rm -rf ~/.khoj` to remove the Khoj data directory if did a local install.
+    Uninstall the Khoj Emacs package in the standard way from Emacs.
     </TabItem>
     <TabItem value="obsidian" label="Obsidian">
-    Uninstall the khoj Obisidan, or desktop client in the standard way from Obsidian or your OS respectively
-    You can also `rm -rf ~/.khoj` to remove the Khoj data directory if did a local install.
+    Uninstall via the Community plugins tab on the settings pane in the Obsidian app
     </TabItem>
   </Tabs>
 
@@ -331,7 +393,6 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau
      ```
   3. Now start `khoj` using the standard steps described earlier
 
-
 #### Install fails while building Tokenizer dependency
 - **Details**: `pip install khoj` fails while building the `tokenizers` dependency. Complains about Rust.
 - **Fix**: Install Rust to build the tokenizers package. For example on Mac run:
@@ -342,18 +403,6 @@ Set the host URL on your clients settings page to your Khoj server URL. By defau
     ```
 - **Refer**: [Issue with Fix](https://github.com/khoj-ai/khoj/issues/82#issuecomment-1241890946) for more details
 
-
 #### Khoj in Docker errors out with \"Killed\" in error message
 - **Fix**: Increase RAM available to Docker Containers in Docker Settings
 - **Refer**: [StackOverflow Solution](https://stackoverflow.com/a/50770267), [Configure Resources on Docker for Mac](https://docs.docker.com/desktop/mac/#resources)
-
-## Advanced
-### Self Host on Custom Domain
-
-You can self-host Khoj behind a custom domain as well. To do so, you need to set the `KHOJ_DOMAIN` environment variable to your domain (e.g., `export KHOJ_DOMAIN=my-khoj-domain.com` or add it to your `docker-compose.yml`). By default, the Khoj server you set up will not be accessible outside of `localhost` or `127.0.0.1`.
-
-:::warning[Without HTTPS certificate]
-To expose Khoj on a custom domain over the public internet, use of an SSL certificate is strongly recommended. You can use [Let's Encrypt](https://letsencrypt.org/) to get a free SSL certificate for your domain.
-
-To disable HTTPS, set the `KHOJ_NO_HTTPS` environment variable to `True`. This can be useful if Khoj is only accessible behind a secure, private network.
-:::
diff --git a/documentation/yarn.lock b/documentation/yarn.lock
index 48c26f369..677b8d7a2 100644
--- a/documentation/yarn.lock
+++ b/documentation/yarn.lock
@@ -1794,9 +1794,9 @@
     config-chain "^1.1.11"
 
 "@polka/url@^1.0.0-next.24":
-  version "1.0.0-next.25"
-  resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.25.tgz#f077fdc0b5d0078d30893396ff4827a13f99e817"
-  integrity sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==
+  version "1.0.0-next.28"
+  resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.28.tgz#d45e01c4a56f143ee69c54dd6b12eade9e270a73"
+  integrity sha512-8LduaNlMZGwdZ6qWrKlfa+2M4gahzFkprZiAt2TF8uS0qQgBizKXpXURqvTJ4WtmupWxaLqjRb2UCTe72mu+Aw==
 
 "@sideway/address@^4.1.5":
   version "4.1.5"
@@ -2009,9 +2009,9 @@
     "@types/estree" "*"
 
 "@types/estree@*", "@types/estree@^1.0.0", "@types/estree@^1.0.5":
-  version "1.0.5"
-  resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4"
-  integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==
+  version "1.0.6"
+  resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
+  integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==
 
 "@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.33":
   version "4.19.5"
@@ -2126,9 +2126,9 @@
     "@types/node" "*"
 
 "@types/node@*":
-  version "22.5.4"
-  resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.4.tgz#83f7d1f65bc2ed223bdbf57c7884f1d5a4fa84e8"
-  integrity sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==
+  version "22.5.5"
+  resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.5.tgz#52f939dd0f65fc552a4ad0b392f3c466cc5d7a44"
+  integrity sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==
   dependencies:
     undici-types "~6.19.2"
 
@@ -2148,14 +2148,14 @@
   integrity sha512-rlAnzkW2sZOjbqZ743IHUhFcvzaGbqijwOu8QZnZCjfQzBqFE3s4lOTJEsxikImav9uzz/42I+O7YUs1mWgMlg==
 
 "@types/prop-types@*":
-  version "15.7.12"
-  resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
-  integrity sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==
+  version "15.7.13"
+  resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.13.tgz#2af91918ee12d9d32914feb13f5326658461b451"
+  integrity sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==
 
 "@types/qs@*":
-  version "6.9.15"
-  resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.15.tgz#adde8a060ec9c305a82de1babc1056e73bd64dce"
-  integrity sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==
+  version "6.9.16"
+  resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.16.tgz#52bba125a07c0482d26747d5d4947a64daf8f794"
+  integrity sha512-7i+zxXdPD0T4cKDuxCUXJ4wHcsJLwENa6Z3dCu8cfCK743OGy5Nu1RmAGqDPsoTDINVEcdXKRvR/zre+P2Ku1A==
 
 "@types/range-parser@*":
   version "1.2.7"
@@ -2189,9 +2189,9 @@
     "@types/react" "*"
 
 "@types/react@*":
-  version "18.3.5"
-  resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.5.tgz#5f524c2ad2089c0ff372bbdabc77ca2c4dbadf8f"
-  integrity sha512-WeqMfGJLGuLCqHGYRGHxnKrXcTitc6L/nBUWfWPcTarG3t9PsquqUMuVeXZeca+mglY4Vo5GZjCi0A3Or2lnxA==
+  version "18.3.8"
+  resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.8.tgz#1672ab19993f8aca7c7dc844c07d5d9e467d5a79"
+  integrity sha512-syBUrW3/XpnW4WJ41Pft+I+aPoDVbrBVQGEnbD7NijDGlVC+8gV/XKRY+7vMDlfPpbwYt0l1vd/Sj8bJGMbs9Q==
   dependencies:
     "@types/prop-types" "*"
     csstype "^3.0.2"
@@ -2613,9 +2613,9 @@ autoprefixer@^10.4.14, autoprefixer@^10.4.19:
     postcss-value-parser "^4.2.0"
 
 babel-loader@^9.1.3:
-  version "9.1.3"
-  resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-9.1.3.tgz#3d0e01b4e69760cc694ee306fe16d358aa1c6f9a"
-  integrity sha512-xG3ST4DglodGf8qSwv0MdeWLhrDsw/32QMdTO5T1ZIp9gQur0HkCyFs7Awskr10JKXFXwpAhiCuYX5oGXnRGbw==
+  version "9.2.1"
+  resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-9.2.1.tgz#04c7835db16c246dd19ba0914418f3937797587b"
+  integrity sha512-fqe8naHt46e0yIdkjUZYqddSXfej3AHajX+CSO5X7oy0EmPc6o5Xh+RClNoHjnieWz9AW4kZxW9yyFMhVB1QLA==
   dependencies:
     find-cache-dir "^4.0.0"
     schema-utils "^4.0.0"
@@ -2838,9 +2838,9 @@ caniuse-api@^3.0.0:
     lodash.uniq "^4.5.0"
 
 caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001646:
-  version "1.0.30001660"
-  resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001660.tgz#31218de3463fabb44d0b7607b652e56edf2e2355"
-  integrity sha512-GacvNTTuATm26qC74pt+ad1fW15mlQ/zuTzzY1ZoIzECTP8HURDfF43kNxPgf7H1jmelCBQTTbBNxdSXOA7Bqg==
+  version "1.0.30001662"
+  resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001662.tgz#3574b22dfec54a3f3b6787331da1040fe8e763ec"
+  integrity sha512-sgMUVwLmGseH8ZIrm1d51UbrhqMCH3jvS7gF/M6byuHOnKyLOBL7W8yz5V02OHwgLGA36o/AFhWzzh4uc5aqTA==
 
 ccount@^2.0.0:
   version "2.0.1"
@@ -3625,9 +3625,9 @@ ee-first@1.1.1:
   integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==
 
 electron-to-chromium@^1.5.4:
-  version "1.5.19"
-  resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.19.tgz#aeaa0a076f3f0f0e8db2c57fd10158508f00725a"
-  integrity sha512-kpLJJi3zxTR1U828P+LIUDZ5ohixyo68/IcYOHLqnbTPr/wdgn4i1ECvmALN9E16JPA6cvCG5UG79gVwVdEK5w==
+  version "1.5.27"
+  resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.27.tgz#5203ce5d6054857d84ba84d3681cbe59132ade78"
+  integrity sha512-o37j1vZqCoEgBuWWXLHQgTN/KDKe7zwpiY5CPeq2RvUqOyJw9xnrULzZAEVQ5p4h+zjMk7hgtOoPdnLxr7m/jw==
 
 emoji-regex@^8.0.0:
   version "8.0.0"
@@ -3868,9 +3868,9 @@ execa@^5.0.0:
     strip-final-newline "^2.0.0"
 
 express@^4.17.3:
-  version "4.20.0"
-  resolved "https://registry.yarnpkg.com/express/-/express-4.20.0.tgz#f1d08e591fcec770c07be4767af8eb9bcfd67c48"
-  integrity sha512-pLdae7I6QqShF5PnNTCVn4hI91Dx0Grkn2+IAsMTgMIKuQVte2dN9PeGSSAME2FR8anOhVA62QDIUaWVfEXVLw==
+  version "4.21.0"
+  resolved "https://registry.yarnpkg.com/express/-/express-4.21.0.tgz#d57cb706d49623d4ac27833f1cbc466b668eb915"
+  integrity sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==
   dependencies:
     accepts "~1.3.8"
     array-flatten "1.1.1"
@@ -3884,7 +3884,7 @@ express@^4.17.3:
     encodeurl "~2.0.0"
     escape-html "~1.0.3"
     etag "~1.8.1"
-    finalhandler "1.2.0"
+    finalhandler "1.3.1"
     fresh "0.5.2"
     http-errors "2.0.0"
     merge-descriptors "1.0.3"
@@ -3893,11 +3893,11 @@ express@^4.17.3:
     parseurl "~1.3.3"
     path-to-regexp "0.1.10"
     proxy-addr "~2.0.7"
-    qs "6.11.0"
+    qs "6.13.0"
     range-parser "~1.2.1"
     safe-buffer "5.2.1"
     send "0.19.0"
-    serve-static "1.16.0"
+    serve-static "1.16.2"
     setprototypeof "1.2.0"
     statuses "2.0.1"
     type-is "~1.6.18"
@@ -3997,13 +3997,13 @@ fill-range@^7.1.1:
   dependencies:
     to-regex-range "^5.0.1"
 
-finalhandler@1.2.0:
-  version "1.2.0"
-  resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32"
-  integrity sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==
+finalhandler@1.3.1:
+  version "1.3.1"
+  resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.3.1.tgz#0c575f1d1d324ddd1da35ad7ece3df7d19088019"
+  integrity sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==
   dependencies:
     debug "2.6.9"
-    encodeurl "~1.0.2"
+    encodeurl "~2.0.0"
     escape-html "~1.0.3"
     on-finished "2.4.1"
     parseurl "~1.3.3"
@@ -4726,10 +4726,10 @@ inline-style-parser@0.1.1:
   resolved "https://registry.yarnpkg.com/inline-style-parser/-/inline-style-parser-0.1.1.tgz#ec8a3b429274e9c0a1f1c4ffa9453a7fef72cea1"
   integrity sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==
 
-inline-style-parser@0.2.3:
-  version "0.2.3"
-  resolved "https://registry.yarnpkg.com/inline-style-parser/-/inline-style-parser-0.2.3.tgz#e35c5fb45f3a83ed7849fe487336eb7efa25971c"
-  integrity sha512-qlD8YNDqyTKTyuITrDOffsl6Tdhv+UC4hcdAVuQsK4IMQ99nSgd1MIA/Q+jQYoh9r3hVUXhYh7urSRmXPkW04g==
+inline-style-parser@0.2.4:
+  version "0.2.4"
+  resolved "https://registry.yarnpkg.com/inline-style-parser/-/inline-style-parser-0.2.4.tgz#f4af5fe72e612839fcd453d989a586566d695f22"
+  integrity sha512-0aO8FkhNZlj/ZIbNi7Lxxr12obT7cL1moPfE4tg1LkX7LlLfC6DeX4l2ZEud1ukP9jNQyNnfzQVqwbwmAATY4Q==
 
 interpret@^1.0.0:
   version "1.4.0"
@@ -5323,9 +5323,9 @@ mdast-util-gfm@^3.0.0:
     mdast-util-to-markdown "^2.0.0"
 
 mdast-util-mdx-expression@^2.0.0:
-  version "2.0.0"
-  resolved "https://registry.yarnpkg.com/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.0.tgz#4968b73724d320a379110d853e943a501bfd9d87"
-  integrity sha512-fGCu8eWdKUKNu5mohVGkhBXCXGnOTLuFqOvGMvdikr+J1w7lDJgxThOKpwRWzzbyXAU2hhSwsmssOY4yTokluw==
+  version "2.0.1"
+  resolved "https://registry.yarnpkg.com/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz#43f0abac9adc756e2086f63822a38c8d3c3a5096"
+  integrity sha512-J6f+9hUp+ldTZqKRSg7Vw5V6MqjATc+3E4gf3CFNcuZNWD8XdyI6zQ8GqH7f8169MM6P7hMBRDVGnn7oHB9kXQ==
   dependencies:
     "@types/estree-jsx" "^1.0.0"
     "@types/hast" "^3.0.0"
@@ -5484,9 +5484,9 @@ micromark-core-commonmark@^2.0.0:
     micromark-util-types "^2.0.0"
 
 micromark-extension-directive@^3.0.0:
-  version "3.0.1"
-  resolved "https://registry.yarnpkg.com/micromark-extension-directive/-/micromark-extension-directive-3.0.1.tgz#67b3985bb991a69dbcae52664c57ee54b22f635a"
-  integrity sha512-VGV2uxUzhEZmaP7NSFo2vtq7M2nUD+WfmYQD+d8i/1nHbzE+rMy9uzTvUybBbNiVbrhOZibg3gbyoARGqgDWyg==
+  version "3.0.2"
+  resolved "https://registry.yarnpkg.com/micromark-extension-directive/-/micromark-extension-directive-3.0.2.tgz#2eb61985d1995a7c1ff7621676a4f32af29409e8"
+  integrity sha512-wjcXHgk+PPdmvR58Le9d7zQYWy+vKEU9Se44p2CrCDPiLr2FMyiT4Fyb5UFKFC66wGB3kPlgD7q3TnoqPS7SZA==
   dependencies:
     devlop "^1.0.0"
     micromark-factory-space "^2.0.0"
@@ -6326,9 +6326,9 @@ path-to-regexp@2.2.1:
   integrity sha512-gu9bD6Ta5bwGrrU8muHzVOBFFREpp2iRkVfhBJahwJ6p6Xw20SjT0MxLnwkjOibQmGSYhiUnf2FLe7k+jcFmGQ==
 
 path-to-regexp@^1.7.0:
-  version "1.8.0"
-  resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
-  integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==
+  version "1.9.0"
+  resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.9.0.tgz#5dc0753acbf8521ca2e0f137b4578b917b10cf24"
+  integrity sha512-xIp7/apCFJuUHdDLWe8O1HIkb0kQrOMb/0u6FXQjemHn/ii5LrIzU6bdECnsiTF/GjZkMEKg1xdiZwNqDYlZ6g==
   dependencies:
     isarray "0.0.1"
 
@@ -6346,7 +6346,7 @@ periscopic@^3.0.0:
     estree-walker "^3.0.0"
     is-reference "^3.0.0"
 
-picocolors@^1.0.0, picocolors@^1.0.1:
+picocolors@^1.0.0, picocolors@^1.0.1, picocolors@^1.1.0:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.0.tgz#5358b76a78cde483ba5cef6a9dc9671440b27d59"
   integrity sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==
@@ -6651,13 +6651,13 @@ postcss-zindex@^6.0.2:
   integrity sha512-5BxW9l1evPB/4ZIc+2GobEBoKC+h8gPGCMi+jxsYvd2x0mjq7wazk6DrP71pStqxE9Foxh5TVnonbWpFZzXaYg==
 
 postcss@^8.4.21, postcss@^8.4.24, postcss@^8.4.26, postcss@^8.4.33, postcss@^8.4.38:
-  version "8.4.45"
-  resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.45.tgz#538d13d89a16ef71edbf75d895284ae06b79e603"
-  integrity sha512-7KTLTdzdZZYscUc65XmjFiB73vBhBfbPztCYdUNvlaso9PrzjzcmjqBPR0lNGkcVlcO4BjiO5rK/qNz+XAen1Q==
+  version "8.4.47"
+  resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.47.tgz#5bf6c9a010f3e724c503bf03ef7947dcb0fea365"
+  integrity sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==
   dependencies:
     nanoid "^3.3.7"
-    picocolors "^1.0.1"
-    source-map-js "^1.2.0"
+    picocolors "^1.1.0"
+    source-map-js "^1.2.1"
 
 pretty-error@^4.0.0:
   version "4.0.0"
@@ -6742,13 +6742,6 @@ pupa@^3.1.0:
   dependencies:
     escape-goat "^4.0.0"
 
-qs@6.11.0:
-  version "6.11.0"
-  resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a"
-  integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==
-  dependencies:
-    side-channel "^1.0.4"
-
 qs@6.13.0:
   version "6.13.0"
   resolved "https://registry.yarnpkg.com/qs/-/qs-6.13.0.tgz#6ca3bd58439f7e245655798997787b0d88a51906"
@@ -6993,9 +6986,9 @@ recursive-readdir@^2.2.2:
     minimatch "^3.0.5"
 
 regenerate-unicode-properties@^10.1.0:
-  version "10.1.1"
-  resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.1.tgz#6b0e05489d9076b04c436f318d9b067bba459480"
-  integrity sha512-X007RyZLsCJVVrjgEFVpLUTZwyOZk3oiL75ZcuYjlIWd6rNJtOjkBwQc5AsRrpbKVkxN6sklw/k/9m2jJYOf8Q==
+  version "10.2.0"
+  resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.2.0.tgz#626e39df8c372338ea9b8028d1f99dc3fd9c3db0"
+  integrity sha512-DqHn3DwbmmPVzeKj9woBadqmXxLvQoQIwu7nopMc72ztvxVmVk2SBhSnx67zuye5TP+lJsb/TBQsjLKhnDf3MA==
   dependencies:
     regenerate "^1.4.2"
 
@@ -7125,9 +7118,9 @@ remark-parse@^11.0.0:
     unified "^11.0.0"
 
 remark-rehype@^11.0.0:
-  version "11.1.0"
-  resolved "https://registry.yarnpkg.com/remark-rehype/-/remark-rehype-11.1.0.tgz#d5f264f42bcbd4d300f030975609d01a1697ccdc"
-  integrity sha512-z3tJrAs2kIs1AqIIy6pzHmAHlF1hWQ+OdY4/hv+Wxe35EhyLKcajL33iUEn3ScxtFox9nUvRufR/Zre8Q08H/g==
+  version "11.1.1"
+  resolved "https://registry.yarnpkg.com/remark-rehype/-/remark-rehype-11.1.1.tgz#f864dd2947889a11997c0a2667cd6b38f685bca7"
+  integrity sha512-g/osARvjkBXb6Wo0XvAeXQohVta8i84ACbenPpoSsxTOQH/Ae0/RGP4WZgnMH5pMLpsj4FG7OHmcIcXxpza8eQ==
   dependencies:
     "@types/hast" "^3.0.0"
     "@types/mdast" "^4.0.0"
@@ -7333,25 +7326,6 @@ semver@^7.3.2, semver@^7.3.5, semver@^7.3.7, semver@^7.5.4:
   resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
   integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==
 
-send@0.18.0:
-  version "0.18.0"
-  resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be"
-  integrity sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==
-  dependencies:
-    debug "2.6.9"
-    depd "2.0.0"
-    destroy "1.2.0"
-    encodeurl "~1.0.2"
-    escape-html "~1.0.3"
-    etag "~1.8.1"
-    fresh "0.5.2"
-    http-errors "2.0.0"
-    mime "1.6.0"
-    ms "2.1.3"
-    on-finished "2.4.1"
-    range-parser "~1.2.1"
-    statuses "2.0.1"
-
 send@0.19.0:
   version "0.19.0"
   resolved "https://registry.yarnpkg.com/send/-/send-0.19.0.tgz#bbc5a388c8ea6c048967049dbeac0e4a3f09d7f8"
@@ -7405,15 +7379,15 @@ serve-index@^1.9.1:
     mime-types "~2.1.17"
     parseurl "~1.3.2"
 
-serve-static@1.16.0:
-  version "1.16.0"
-  resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.16.0.tgz#2bf4ed49f8af311b519c46f272bf6ac3baf38a92"
-  integrity sha512-pDLK8zwl2eKaYrs8mrPZBJua4hMplRWJ1tIFksVC3FtBEBnl8dxgeHtsaMS8DhS9i4fLObaon6ABoc4/hQGdPA==
+serve-static@1.16.2:
+  version "1.16.2"
+  resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.16.2.tgz#b6a5343da47f6bdd2673848bf45754941e803296"
+  integrity sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==
   dependencies:
-    encodeurl "~1.0.2"
+    encodeurl "~2.0.0"
     escape-html "~1.0.3"
     parseurl "~1.3.3"
-    send "0.18.0"
+    send "0.19.0"
 
 set-function-length@^1.2.1:
   version "1.2.2"
@@ -7475,7 +7449,7 @@ shelljs@^0.8.5:
     interpret "^1.0.0"
     rechoir "^0.6.2"
 
-side-channel@^1.0.4, side-channel@^1.0.6:
+side-channel@^1.0.6:
   version "1.0.6"
   resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2"
   integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==
@@ -7553,7 +7527,7 @@ sort-css-media-queries@2.2.0:
   resolved "https://registry.yarnpkg.com/sort-css-media-queries/-/sort-css-media-queries-2.2.0.tgz#aa33cf4a08e0225059448b6c40eddbf9f1c8334c"
   integrity sha512-0xtkGhWCC9MGt/EzgnvbbbKhqWjl1+/rncmhTh5qCpbYguXh6S/qwePfv/JQ8jePXXmqingylxoC49pCkSPIbA==
 
-source-map-js@^1.0.1, source-map-js@^1.2.0:
+source-map-js@^1.0.1, source-map-js@^1.2.1:
   version "1.2.1"
   resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46"
   integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==
@@ -7720,11 +7694,11 @@ style-to-object@^0.4.0:
     inline-style-parser "0.1.1"
 
 style-to-object@^1.0.0:
-  version "1.0.7"
-  resolved "https://registry.yarnpkg.com/style-to-object/-/style-to-object-1.0.7.tgz#8604fb6018ac3db83e97207a4f85f579068f661c"
-  integrity sha512-uSjr59G5u6fbxUfKbb8GcqMGT3Xs9v5IbPkjb0S16GyOeBLAzSRK0CixBv5YrYvzO6TDLzIS6QCn78tkqWngPw==
+  version "1.0.8"
+  resolved "https://registry.yarnpkg.com/style-to-object/-/style-to-object-1.0.8.tgz#67a29bca47eaa587db18118d68f9d95955e81292"
+  integrity sha512-xT47I/Eo0rwJmaXC4oilDGDWLohVhR6o/xAQcPQN8q6QBuZVL8qMYL85kLmST5cPjAorwvqIA4qXTRQoYHaL6g==
   dependencies:
-    inline-style-parser "0.2.3"
+    inline-style-parser "0.2.4"
 
 stylehacks@^6.1.1:
   version "6.1.1"
@@ -7800,9 +7774,9 @@ terser-webpack-plugin@^5.3.10, terser-webpack-plugin@^5.3.9:
     terser "^5.26.0"
 
 terser@^5.10.0, terser@^5.15.1, terser@^5.26.0:
-  version "5.32.0"
-  resolved "https://registry.yarnpkg.com/terser/-/terser-5.32.0.tgz#ee811c0d2d6b741c1cc34a2bc5bcbfc1b5b1f96c"
-  integrity sha512-v3Gtw3IzpBJ0ugkxEX8U0W6+TnPKRRCWGh1jC/iM/e3Ki5+qvO1L1EAZ56bZasc64aXHwRHNIQEzm6//i5cemQ==
+  version "5.33.0"
+  resolved "https://registry.yarnpkg.com/terser/-/terser-5.33.0.tgz#8f9149538c7468ffcb1246cfec603c16720d2db1"
+  integrity sha512-JuPVaB7s1gdFKPKTelwUyRq5Sid2A3Gko2S0PncwdBq7kN9Ti9HPWDQ06MPsEDGsZeVESjKEnyGy68quBk1w6g==
   dependencies:
     "@jridgewell/source-map" "^0.3.3"
     acorn "^8.8.2"
@@ -7897,9 +7871,9 @@ undici-types@~6.19.2:
   integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==
 
 unicode-canonical-property-names-ecmascript@^2.0.0:
-  version "2.0.0"
-  resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"
-  integrity sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==
+  version "2.0.1"
+  resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz#cb3173fe47ca743e228216e4a3ddc4c84d628cc2"
+  integrity sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==
 
 unicode-emoji-modifier-base@^1.0.0:
   version "1.0.0"
@@ -7915,9 +7889,9 @@ unicode-match-property-ecmascript@^2.0.0:
     unicode-property-aliases-ecmascript "^2.0.0"
 
 unicode-match-property-value-ecmascript@^2.1.0:
-  version "2.1.0"
-  resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.1.0.tgz#cb5fffdcd16a05124f5a4b0bf7c3770208acbbe0"
-  integrity sha512-qxkjQt6qjg/mYscYMC0XKRn3Rh0wFPlfxB0xkt9CfyTvpX1Ra0+rAmdX2QyAobptSEvuy4RtpPRui6XkV+8wjA==
+  version "2.2.0"
+  resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.2.0.tgz#a0401aee72714598f739b68b104e4fe3a0cb3c71"
+  integrity sha512-4IehN3V/+kkr5YeSSDDQG8QLqO26XpL2XP3GQtqwlT/QYSECAwFztxVHjlbh0+gjJ3XmNLS0zDsbgs9jWKExLg==
 
 unicode-property-aliases-ecmascript@^2.0.0:
   version "2.1.0"
diff --git a/pyproject.toml b/pyproject.toml
index b21fc1d57..727bbfe0e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -73,7 +73,7 @@ dependencies = [
     "psycopg2-binary == 2.9.9",
     "lxml == 4.9.3",
     "tzdata == 2023.3",
-    "rapidocr-onnxruntime == 1.3.22",
+    "rapidocr-onnxruntime == 1.3.24",
     "openai-whisper >= 20231117",
     "django-phonenumber-field == 7.3.0",
     "phonenumbers == 8.13.27",
diff --git a/src/khoj/main.py b/src/khoj/main.py
index 0a492e915..272c9bb83 100644
--- a/src/khoj/main.py
+++ b/src/khoj/main.py
@@ -131,7 +131,7 @@ def run(should_start_server=True):
     logger.info(f"📦 Initializing DB:\n{db_migrate_output.getvalue().strip()}")
     logger.debug(f"🌍 Initializing Web Client:\n{collectstatic_output.getvalue().strip()}")
 
-    initialization()
+    initialization(not args.non_interactive)
 
     # Create app directory, if it doesn't exist
     state.config_file.parent.mkdir(parents=True, exist_ok=True)
diff --git a/src/khoj/processor/content/images/image_to_entries.py b/src/khoj/processor/content/images/image_to_entries.py
index d28518b7c..6dcd728cf 100644
--- a/src/khoj/processor/content/images/image_to_entries.py
+++ b/src/khoj/processor/content/images/image_to_entries.py
@@ -4,8 +4,6 @@
 from datetime import datetime
 from typing import Dict, List, Tuple
 
-from rapidocr_onnxruntime import RapidOCR
-
 from khoj.database.models import Entry as DbEntry
 from khoj.database.models import KhojUser
 from khoj.processor.content.text_to_entries import TextToEntries
@@ -58,7 +56,6 @@ def extract_image_entries(image_files) -> Tuple[Dict, List[Entry]]:  # important
         entry_to_location_map: List[Tuple[str, str]] = []
         for image_file in image_files:
             try:
-                loader = RapidOCR()
                 bytes = image_files[image_file]
                 # write the image to a temporary file
                 timestamp_now = datetime.utcnow().timestamp()
@@ -71,13 +68,18 @@ def extract_image_entries(image_files) -> Tuple[Dict, List[Entry]]:  # important
                     bytes = image_files[image_file]
                     f.write(bytes)
                 try:
+                    from rapidocr_onnxruntime import RapidOCR
+
+                    loader = RapidOCR()
                     image_entries_per_file = ""
                     result, _ = loader(tmp_file)
                     if result:
                         expanded_entries = [text[1] for text in result]
                         image_entries_per_file = " ".join(expanded_entries)
                 except ImportError:
-                    logger.warning(f"Unable to process file: {image_file}. This file will not be indexed.")
+                    logger.warning(
+                        f"Unable to process image or scanned file for text: {image_file}. This file will not be indexed."
+                    )
                     continue
                 entry_to_location_map.append((image_entries_per_file, image_file))
                 entries.extend([image_entries_per_file])
diff --git a/src/khoj/processor/conversation/utils.py b/src/khoj/processor/conversation/utils.py
index b7794361f..3f3977986 100644
--- a/src/khoj/processor/conversation/utils.py
+++ b/src/khoj/processor/conversation/utils.py
@@ -18,13 +18,20 @@
 
 logger = logging.getLogger(__name__)
 model_to_prompt_size = {
+    # OpenAI Models
     "gpt-3.5-turbo": 12000,
-    "gpt-3.5-turbo-0125": 12000,
-    "gpt-4-0125-preview": 20000,
     "gpt-4-turbo-preview": 20000,
+    "gpt-4o": 20000,
     "gpt-4o-mini": 20000,
     "o1-preview": 20000,
     "o1-mini": 20000,
+    # Google Models
+    "gemini-1.5-flash": 20000,
+    "gemini-1.5-pro": 20000,
+    # Anthropic Models
+    "claude-3-5-sonnet-20240620": 20000,
+    "claude-3-opus-20240229": 20000,
+    # Offline Models
     "TheBloke/Mistral-7B-Instruct-v0.2-GGUF": 3500,
     "NousResearch/Hermes-2-Pro-Mistral-7B-GGUF": 3500,
     "bartowski/Meta-Llama-3.1-8B-Instruct-GGUF": 20000,
@@ -163,7 +170,7 @@ def generate_chatml_messages_with_context(
         if loaded_model:
             max_prompt_size = infer_max_tokens(loaded_model.n_ctx(), model_to_prompt_size.get(model_name, math.inf))
         else:
-            max_prompt_size = model_to_prompt_size.get(model_name, 2000)
+            max_prompt_size = model_to_prompt_size.get(model_name, 10000)
 
     # Scale lookback turns proportional to max prompt size supported by model
     lookback_turns = max_prompt_size // 750
diff --git a/src/khoj/utils/cli.py b/src/khoj/utils/cli.py
index dd3388d99..2e2bb77dd 100644
--- a/src/khoj/utils/cli.py
+++ b/src/khoj/utils/cli.py
@@ -50,6 +50,12 @@ def cli(args=None):
         default=False,
         help="Run Khoj in anonymous mode. This does not require any login for connecting users.",
     )
+    parser.add_argument(
+        "--non-interactive",
+        action="store_true",
+        default=False,
+        help="Start Khoj in non-interactive mode. Assumes interactive shell unavailable for config. E.g when run via Docker.",
+    )
 
     args, remaining_args = parser.parse_known_args(args)
 
diff --git a/src/khoj/utils/constants.py b/src/khoj/utils/constants.py
index bbbbd0007..d91cc84ab 100644
--- a/src/khoj/utils/constants.py
+++ b/src/khoj/utils/constants.py
@@ -8,8 +8,15 @@
 app_env_filepath = "~/.khoj/env"
 telemetry_server = "https://khoj.beta.haletic.com/v1/telemetry"
 content_directory = "~/.khoj/content/"
-default_offline_chat_model = "bartowski/Meta-Llama-3.1-8B-Instruct-GGUF"
-default_online_chat_model = "gpt-4o-mini"
+default_offline_chat_models = [
+    "bartowski/Meta-Llama-3.1-8B-Instruct-GGUF",
+    "bartowski/gemma-2-9b-it-GGUF",
+    "bartowski/gemma-2-2b-it-GGUF",
+    "bartowski/Phi-3.5-mini-instruct-GGUF",
+]
+default_openai_chat_models = ["gpt-4o-mini", "gpt-4o"]
+default_gemini_chat_models = ["gemini-1.5-flash", "gemini-1.5-pro"]
+default_anthropic_chat_models = ["claude-3-5-sonnet-20240620", "claude-3-opus-20240229"]
 
 empty_config = {
     "search-type": {
diff --git a/src/khoj/utils/initialization.py b/src/khoj/utils/initialization.py
index 8ef0ef536..90bb9921e 100644
--- a/src/khoj/utils/initialization.py
+++ b/src/khoj/utils/initialization.py
@@ -1,25 +1,37 @@
 import logging
 import os
+from typing import Tuple
 
 from khoj.database.adapters import ConversationAdapters
 from khoj.database.models import (
     ChatModelOptions,
     KhojUser,
     OpenAIProcessorConversationConfig,
+    ServerChatSettings,
     SpeechToTextModelOptions,
     TextToImageModelConfig,
 )
 from khoj.processor.conversation.utils import model_to_prompt_size, model_to_tokenizer
-from khoj.utils.constants import default_offline_chat_model, default_online_chat_model
+from khoj.utils.constants import (
+    default_anthropic_chat_models,
+    default_gemini_chat_models,
+    default_offline_chat_models,
+    default_openai_chat_models,
+)
 
 logger = logging.getLogger(__name__)
 
 
-def initialization():
+def initialization(interactive: bool = True):
     def _create_admin_user():
         logger.info(
             "👩‍✈️ Setting up admin user. These credentials will allow you to configure your server at /server/admin."
         )
+        if not interactive and (not os.getenv("KHOJ_ADMIN_EMAIL") or not os.getenv("KHOJ_ADMIN_PASSWORD")):
+            logger.error(
+                "🚨 Admin user cannot be created. Please set the KHOJ_ADMIN_EMAIL, KHOJ_ADMIN_PASSWORD environment variables or start server in interactive mode."
+            )
+            exit(1)
         email_addr = os.getenv("KHOJ_ADMIN_EMAIL") or input("Email: ")
         password = os.getenv("KHOJ_ADMIN_PASSWORD") or input("Password: ")
         admin_user = KhojUser.objects.create_superuser(email=email_addr, username=email_addr, password=password)
@@ -27,87 +39,103 @@ def _create_admin_user():
 
     def _create_chat_configuration():
         logger.info(
-            "🗣️  Configure chat models available to your server. You can always update these at /server/admin using the credentials of your admin account"
+            "🗣️ Configure chat models available to your server. You can always update these at /server/admin using your admin account"
         )
 
-        try:
-            use_offline_model = input("Use offline chat model? (y/n): ")
-            if use_offline_model == "y":
-                logger.info("🗣️ Setting up offline chat model")
-
-                offline_chat_model = input(
-                    f"Enter the offline chat model you want to use. See HuggingFace for available GGUF models (default: {default_offline_chat_model}): "
-                )
-                if offline_chat_model == "":
-                    ChatModelOptions.objects.create(
-                        chat_model=default_offline_chat_model, model_type=ChatModelOptions.ModelType.OFFLINE
-                    )
-                else:
-                    default_max_tokens = model_to_prompt_size.get(offline_chat_model, 2000)
-                    max_tokens = input(
-                        f"Enter the maximum number of tokens to use for the offline chat model (default {default_max_tokens}):"
-                    )
-                    max_tokens = max_tokens or default_max_tokens
-
-                    default_tokenizer = model_to_tokenizer.get(
-                        offline_chat_model, "hf-internal-testing/llama-tokenizer"
-                    )
-                    tokenizer = input(
-                        f"Enter the tokenizer to use for the offline chat model (default: {default_tokenizer}):"
-                    )
-                    tokenizer = tokenizer or default_tokenizer
-
-                    ChatModelOptions.objects.create(
-                        chat_model=offline_chat_model,
-                        model_type=ChatModelOptions.ModelType.OFFLINE,
-                        max_prompt_size=max_tokens,
-                        tokenizer=tokenizer,
-                    )
-        except ModuleNotFoundError as e:
-            logger.warning("Offline models are not supported on this device.")
-
-        use_openai_model = input("Use OpenAI models? (y/n): ")
-        if use_openai_model == "y":
-            logger.info("🗣️ Setting up your OpenAI configuration")
-            api_key = input("Enter your OpenAI API key: ")
-            OpenAIProcessorConversationConfig.objects.create(api_key=api_key)
-
-            openai_chat_model = input(
-                f"Enter the OpenAI chat model you want to use (default: {default_online_chat_model}): "
-            )
-            openai_chat_model = openai_chat_model or default_online_chat_model
-
-            default_max_tokens = model_to_prompt_size.get(openai_chat_model, 2000)
-            max_tokens = input(
-                f"Enter the maximum number of tokens to use for the OpenAI chat model (default: {default_max_tokens}): "
-            )
-            max_tokens = max_tokens or default_max_tokens
-            ChatModelOptions.objects.create(
-                chat_model=openai_chat_model, model_type=ChatModelOptions.ModelType.OPENAI, max_prompt_size=max_tokens
-            )
+        # Set up OpenAI's online chat models
+        openai_configured, openai_provider = _setup_chat_model_provider(
+            ChatModelOptions.ModelType.OPENAI,
+            default_openai_chat_models,
+            default_api_key=os.getenv("OPENAI_API_KEY"),
+            vision_enabled=True,
+            is_offline=False,
+            interactive=interactive,
+        )
 
+        # Setup OpenAI speech to text model
+        if openai_configured:
             default_speech2text_model = "whisper-1"
-            openai_speech2text_model = input(
-                f"Enter the OpenAI speech to text model you want to use (default: {default_speech2text_model}): "
-            )
-            openai_speech2text_model = openai_speech2text_model or default_speech2text_model
+            if interactive:
+                openai_speech2text_model = input(
+                    f"Enter the OpenAI speech to text model you want to use (default: {default_speech2text_model}): "
+                )
+                openai_speech2text_model = openai_speech2text_model or default_speech2text_model
+            else:
+                openai_speech2text_model = default_speech2text_model
             SpeechToTextModelOptions.objects.create(
                 model_name=openai_speech2text_model, model_type=SpeechToTextModelOptions.ModelType.OPENAI
             )
 
+        # Setup OpenAI text to image model
+        if openai_configured:
             default_text_to_image_model = "dall-e-3"
-            openai_text_to_image_model = input(
-                f"Enter the OpenAI text to image model you want to use (default: {default_text_to_image_model}): "
-            )
-            openai_speech2text_model = openai_text_to_image_model or default_text_to_image_model
+            if interactive:
+                openai_text_to_image_model = input(
+                    f"Enter the OpenAI text to image model you want to use (default: {default_text_to_image_model}): "
+                )
+                openai_text_to_image_model = openai_text_to_image_model or default_text_to_image_model
+            else:
+                openai_text_to_image_model = default_text_to_image_model
             TextToImageModelConfig.objects.create(
-                model_name=openai_text_to_image_model, model_type=TextToImageModelConfig.ModelType.OPENAI
+                model_name=openai_text_to_image_model,
+                model_type=TextToImageModelConfig.ModelType.OPENAI,
+                openai_config=openai_provider,
             )
 
-        if use_offline_model == "y" or use_openai_model == "y":
-            logger.info("🗣️  Chat model configuration complete")
+        # Set up Google's Gemini online chat models
+        _setup_chat_model_provider(
+            ChatModelOptions.ModelType.GOOGLE,
+            default_gemini_chat_models,
+            default_api_key=os.getenv("GEMINI_API_KEY"),
+            vision_enabled=False,
+            is_offline=False,
+            interactive=interactive,
+            provider_name="Google Gemini",
+        )
 
-        use_offline_speech2text_model = input("Use offline speech to text model? (y/n): ")
+        # Set up Anthropic's online chat models
+        _setup_chat_model_provider(
+            ChatModelOptions.ModelType.ANTHROPIC,
+            default_anthropic_chat_models,
+            default_api_key=os.getenv("ANTHROPIC_API_KEY"),
+            vision_enabled=False,
+            is_offline=False,
+            interactive=interactive,
+        )
+
+        # Set up offline chat models
+        _setup_chat_model_provider(
+            ChatModelOptions.ModelType.OFFLINE,
+            default_offline_chat_models,
+            default_api_key=None,
+            vision_enabled=False,
+            is_offline=True,
+            interactive=interactive,
+        )
+
+        # Explicitly set default chat model
+        chat_models_configured = ChatModelOptions.objects.count()
+        if chat_models_configured > 0:
+            default_chat_model_name = ChatModelOptions.objects.first().chat_model
+            # If there are multiple chat models, ask the user to choose the default chat model
+            if chat_models_configured > 1 and interactive:
+                user_chat_model_name = input(
+                    f"Enter the default chat model to use (default: {default_chat_model_name}): "
+                )
+            else:
+                user_chat_model_name = None
+
+            # If the user's choice is valid, set it as the default chat model
+            if user_chat_model_name and ChatModelOptions.objects.filter(chat_model=user_chat_model_name).exists():
+                default_chat_model_name = user_chat_model_name
+
+            # Create a server chat settings object with the default chat model
+            default_chat_model = ChatModelOptions.objects.filter(chat_model=default_chat_model_name).first()
+            ServerChatSettings.objects.create(chat_default=default_chat_model)
+            logger.info("🗣️ Chat model configuration complete")
+
+        # Set up offline speech to text model
+        use_offline_speech2text_model = "n" if not interactive else input("Use offline speech to text model? (y/n): ")
         if use_offline_speech2text_model == "y":
             logger.info("🗣️ Setting up offline speech to text model")
             # Delete any existing speech to text model options. There can only be one.
@@ -124,6 +152,64 @@ def _create_chat_configuration():
 
             logger.info(f"🗣️  Offline speech to text model configured to {offline_speech2text_model}")
 
+    def _setup_chat_model_provider(
+        model_type: ChatModelOptions.ModelType,
+        default_chat_models: list,
+        default_api_key: str,
+        interactive: bool,
+        vision_enabled: bool = False,
+        is_offline: bool = False,
+        provider_name: str = None,
+    ) -> Tuple[bool, OpenAIProcessorConversationConfig]:
+        supported_vision_models = ["gpt-4o-mini", "gpt-4o"]
+        provider_name = provider_name or model_type.name.capitalize()
+        default_use_model = {True: "y", False: "n"}[default_api_key is not None or is_offline]
+        use_model_provider = (
+            default_use_model if not interactive else input(f"Add {provider_name} chat models? (y/n): ")
+        )
+
+        if use_model_provider != "y":
+            return False, None
+
+        logger.info(f"️💬 Setting up your {provider_name} chat configuration")
+
+        chat_model_provider = None
+        if not is_offline:
+            if interactive:
+                user_api_key = input(f"Enter your {provider_name} API key (default: {default_api_key}): ")
+                api_key = user_api_key if user_api_key != "" else default_api_key
+            else:
+                api_key = default_api_key
+            chat_model_provider = OpenAIProcessorConversationConfig.objects.create(api_key=api_key, name=provider_name)
+
+        if interactive:
+            chat_model_names = input(
+                f"Enter the {provider_name} chat models you want to use (default: {','.join(default_chat_models)}): "
+            )
+            chat_models = chat_model_names.split(",") if chat_model_names != "" else default_chat_models
+            chat_models = [model.strip() for model in chat_models]
+        else:
+            chat_models = default_chat_models
+
+        for chat_model in chat_models:
+            default_max_tokens = model_to_prompt_size.get(chat_model)
+            default_tokenizer = model_to_tokenizer.get(chat_model)
+            vision_enabled = vision_enabled and chat_model in supported_vision_models
+
+            chat_model_options = {
+                "chat_model": chat_model,
+                "model_type": model_type,
+                "max_prompt_size": default_max_tokens,
+                "vision_enabled": vision_enabled,
+                "tokenizer": default_tokenizer,
+                "openai_config": chat_model_provider,
+            }
+
+            ChatModelOptions.objects.create(**chat_model_options)
+
+        logger.info(f"🗣️ {provider_name} chat model configuration complete")
+        return True, chat_model_provider
+
     admin_user = KhojUser.objects.filter(is_staff=True).first()
     if admin_user is None:
         while True:
@@ -139,7 +225,8 @@ def _create_chat_configuration():
             try:
                 _create_chat_configuration()
                 break
-            # Some environments don't support interactive input. We catch the exception and return if that's the case. The admin can still configure their settings from the admin page.
+            # Some environments don't support interactive input. We catch the exception and return if that's the case.
+            # The admin can still configure their settings from the admin page.
             except EOFError:
                 return
             except Exception as e:


Test patch:
diff --git a/tests/test_offline_chat_actors.py b/tests/test_offline_chat_actors.py
index ed17cac9c..2a0383f11 100644
--- a/tests/test_offline_chat_actors.py
+++ b/tests/test_offline_chat_actors.py
@@ -19,12 +19,12 @@
 from khoj.processor.conversation.offline.utils import download_model
 from khoj.processor.conversation.utils import message_to_log
 from khoj.routers.helpers import aget_relevant_output_modes
-from khoj.utils.constants import default_offline_chat_model
+from khoj.utils.constants import default_offline_chat_models
 
 
 @pytest.fixture(scope="session")
 def loaded_model():
-    return download_model(default_offline_chat_model, max_tokens=5000)
+    return download_model(default_offline_chat_models[0], max_tokens=5000)
 
 
 freezegun.configure(extend_ignore_list=["transformers"])