Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] adding agent results in a 500 error #1036

Open
3 of 14 tasks
baditaflorin opened this issue Jan 7, 2025 · 6 comments
Open
3 of 14 tasks

[FIX] adding agent results in a 500 error #1036

baditaflorin opened this issue Jan 7, 2025 · 6 comments
Labels
fix Fix something that isn't working as expected question Further information is requested

Comments

@baditaflorin
Copy link

Describe the bug

A clear and concise description of what the bug is. Please include what you were expecting to happen vs. what actually happened.

To Reproduce

Steps to reproduce the behavior:

Screenshots

If applicable, add screenshots to help explain your problem.

Platform

  • Server:
    • Cloud-Hosted (https://app.khoj.dev)
    • Self-Hosted Docker
    • Self-Hosted Python package
    • Self-Hosted source code
  • Client:
    • Obsidian
    • Emacs
    • Desktop app
    • Web browser
    • WhatsApp
  • OS:
    • Windows
    • macOS
    • Linux
    • Android
    • iOS

If self-hosted

  • Server Version [e.g. 1.0.1]:

Additional context

Add any other context about the problem here.

Request URL:
http://localhost:42110/api/agents
Request Method:
POST
Status Code:
500 Internal Server Error
Remote Address:
localhost:42110
Referrer Policy:
strict-origin-when-cross-origin

Payload
{"name":"dsa","persona":"das","color":"cyan","icon":"Code","privacy_level":"private","chat_model":"bartowski/gemma-2-2b-it-GGUF","files":[]}

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 10, in map_exceptions
    yield
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_backends/sync.py", line 212, in connect_tcp
    sock = socket.create_connection(
  File "/usr/lib/python3.10/socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 228, in handle_request
    resp = self._pool.handle_request(req)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 262, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 245, in handle_request
    response = connection.handle_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 124, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_backends/sync.py", line 211, in connect_tcp
    with map_exceptions(exc_map):
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 993, in _request
    response = self._client.send(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 901, in send
    response = self._send_handling_auth(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 929, in _send_handling_auth
    response = self._send_handling_redirects(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 966, in _send_handling_redirects
    response = self._send_single_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 1002, in _send_single_request
    response = transport.handle_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 227, in handle_request
    with map_httpcore_exceptions():
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 10, in map_exceptions
    yield
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_backends/sync.py", line 212, in connect_tcp
    sock = socket.create_connection(
  File "/usr/lib/python3.10/socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 228, in handle_request
    resp = self._pool.handle_request(req)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 262, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 245, in handle_request
    response = connection.handle_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 124, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_backends/sync.py", line 211, in connect_tcp
    with map_exceptions(exc_map):
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 993, in _request
    response = self._client.send(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 901, in send
    response = self._send_handling_auth(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 929, in _send_handling_auth
    response = self._send_handling_redirects(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 966, in _send_handling_redirects
    response = self._send_single_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 1002, in _send_single_request
    response = transport.handle_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 227, in handle_request
    with map_httpcore_exceptions():
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 10, in map_exceptions
    yield
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_backends/sync.py", line 212, in connect_tcp
    sock = socket.create_connection(
  File "/usr/lib/python3.10/socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 228, in handle_request
    resp = self._pool.handle_request(req)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 262, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection_pool.py", line 245, in handle_request
    response = connection.handle_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_sync/connection.py", line 124, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_backends/sync.py", line 211, in connect_tcp
    with map_exceptions(exc_map):
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 993, in _request
    response = self._client.send(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 901, in send
    response = self._send_handling_auth(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 929, in _send_handling_auth
    response = self._send_handling_redirects(
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 966, in _send_handling_redirects
    response = self._send_single_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_client.py", line 1002, in _send_single_request
    response = transport.handle_request(request)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 227, in handle_request
    with map_httpcore_exceptions():
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/sessions.py", line 85, in __call__
    await self.app(scope, receive, send_wrapper)
  File "/app/src/khoj/configure.py", line 351, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/authentication.py", line 48, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 187, in __call__
    response = await self.dispatch_func(request, call_next)
  File "/app/src/khoj/configure.py", line 84, in dispatch
    response = await call_next(request)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 163, in call_next
    raise app_exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 149, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 93, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 144, in simple_response
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 73, in app
    response = await f(request)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 212, in run_endpoint_function
    return await dependant.call(**values)
  File "/usr/local/lib/python3.10/dist-packages/starlette/authentication.py", line 75, in async_wrapper
    return await func(*args, **kwargs)
  File "/app/src/khoj/routers/api_agents.py", line 194, in create_agent
    is_safe_prompt, reason = await acheck_if_safe_prompt(
  File "/app/src/khoj/routers/helpers.py", line 324, in acheck_if_safe_prompt
    response = await send_message_to_model_wrapper(safe_prompt_check, user=user)
  File "/app/src/khoj/routers/helpers.py", line 1035, in send_message_to_model_wrapper
    return send_message_to_model(
  File "/app/src/khoj/processor/conversation/openai/gpt.py", line 129, in send_message_to_model
    return completion_with_backoff(
  File "/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py", line 330, in wrapped_f
    return self(f, *args, **kw)
  File "/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py", line 467, in __call__
    do = self.iter(retry_state=retry_state)
  File "/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py", line 368, in iter
    result = action(retry_state)
  File "/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py", line 410, in exc_check
    raise retry_exc.reraise()
  File "/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py", line 183, in reraise
    raise self.last_attempt.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.10/dist-packages/tenacity/__init__.py", line 470, in __call__
    result = fn(*args, **kwargs)
  File "/app/src/khoj/processor/conversation/openai/utils.py", line 77, in completion_with_backoff
    chat: ChatCompletion | openai.Stream[ChatCompletionChunk] = client.chat.completions.create(
  File "/usr/local/lib/python3.10/dist-packages/openai/_utils/_utils.py", line 275, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/openai/resources/chat/completions.py", line 859, in create
    return self._post(
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 1280, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 957, in request
    return self._request(
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 1017, in _request
    return self._retry_request(
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 1095, in _retry_request
    return self._request(
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 1017, in _request
    return self._retry_request(
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 1095, in _retry_request
    return self._request(
  File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 1027, in _request
    raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.
@baditaflorin baditaflorin added the fix Fix something that isn't working as expected label Jan 7, 2025
@sabaimran
Copy link
Member

Hi @baditaflorin , could you share details of how you've configured your Ai model configuration and chat model options? The error seems to be originating from the call to the LLM.

@baditaflorin
Copy link
Author

I don't even know how to respond as I have tried every possible permutations that they are.

I had put it in offline mode, in openai mode it never worked and the logs are useless

image image image

I don't understand when it will use the ollama custom api, when is set to openai or offline? tried both, none worked.

I would love to have an command that i run and it will give you this informations for how i configured, instead of screenshots. 

and the logs are random and you cannot see nothing in one second when a error starts

 │   12 │   │   for from_exc, to_exc │                

server-1 | │ 13 │ │ │ if isinstance(ex │
server-1 | │ ❱ 14 │ │ │ │ raise to_exc │
server-1 | │ 15 │ │ raise # pragma: noc │
server-1 | │ 16 │
server-1 | │ 17 │
server-1 | ╰───────────────────────────────────╯
server-1 | ConnectError: [Errno -2] Name or
server-1 | service not known
server-1 |
server-1 | The above exception was the direct
server-1 | cause of the following exception:
server-1 |
server-1 | ╭─ Traceback (most recent call last─╮
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:993 │
server-1 | │ in _request │
server-1 | │ │
server-1 | │ 990 │ │ log.debug("Sending │
server-1 | │ 991 │ │ │
server-1 | │ 992 │ │ try: │
server-1 | │ ❱ 993 │ │ │ response = sel │
server-1 | │ 994 │ │ │ │ request, │
server-1 | │ 995 │ │ │ │ stream=str │
server-1 | │ 996 │ │ │ │ **kwargs, │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_client.py:901 in │
server-1 | │ send │
server-1 | │ │
server-1 | │ 898 │ │ │
server-1 | │ 899 │ │ auth = self._build │
server-1 | │ 900 │ │ │
server-1 | │ ❱ 901 │ │ response = self._s │
server-1 | │ 902 │ │ │ request, │
server-1 | │ 903 │ │ │ auth=auth, │
server-1 | │ 904 │ │ │ follow_redirec │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_client.py:929 in │
server-1 | │ _send_handling_auth │
server-1 | │ │
server-1 | │ 926 │ │ │ request = next │
server-1 | │ 927 │ │ │ │
server-1 | │ 928 │ │ │ while True: │
server-1 | │ ❱ 929 │ │ │ │ response = │
server-1 | │ 930 │ │ │ │ │ reques │
server-1 | │ 931 │ │ │ │ │ follow │
server-1 | │ 932 │ │ │ │ │ histor │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_client.py:966 in │
server-1 | │ _send_handling_redirects │
server-1 | │ │
server-1 | │ 963 │ │ │ for hook in se │
server-1 | │ 964 │ │ │ │ hook(reque │
server-1 | │ 965 │ │ │ │
server-1 | │ ❱ 966 │ │ │ response = sel │
server-1 | │ 967 │ │ │ try: │
server-1 | │ 968 │ │ │ │ for hook i │
server-1 | │ 969 │ │ │ │ │ hook(r │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_client.py:1002 in │
server-1 | │ _send_single_request │
server-1 | │ │
server-1 | │ 999 │ │ │ ) │
server-1 | │ 1000 │ │ │
server-1 | │ 1001 │ │ with request_conte │
server-1 | │ ❱ 1002 │ │ │ response = tra │
server-1 | │ 1003 │ │ │
server-1 | │ 1004 │ │ assert isinstance( │
server-1 | │ 1005 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_transports/default. │
server-1 | │ py:227 in handle_request │
server-1 | │ │
server-1 | │ 224 │ │ │ content=request │
server-1 | │ 225 │ │ │ extensions=requ │
server-1 | │ 226 │ │ ) │
server-1 | │ ❱ 227 │ │ with map_httpcore_e │
server-1 | │ 228 │ │ │ resp = self._po │
server-1 | │ 229 │ │ │
server-1 | │ 230 │ │ assert isinstance(r │
server-1 | │ │
server-1 | │ /usr/lib/python3.10/contextlib.py │
server-1 | │ :153 in exit
server-1 | │ │
server-1 | │ 150 │ │ │ │ # tell if w │
server-1 | │ 151 │ │ │ │ value = typ │
server-1 | │ 152 │ │ │ try: │
server-1 | │ ❱ 153 │ │ │ │ self.gen.th │
server-1 | │ 154 │ │ │ except StopIter │
server-1 | │ 155 │ │ │ │ # Suppress │
server-1 | │ 156 │ │ │ │ # was passe │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_transports/default. │
server-1 | │ py:83 in map_httpcore_exceptions │
server-1 | │ │
server-1 | │ 80 │ │ │ raise │
server-1 | │ 81 │ │ │
server-1 | │ 82 │ │ message = str(exc) │
server-1 | │ ❱ 83 │ │ raise mapped_exc(me │
server-1 | │ 84 │
server-1 | │ 85 │
server-1 | │ 86 HTTPCORE_EXC_MAP = { │
server-1 | ╰───────────────────────────────────╯
server-1 | ConnectError: [Errno -2] Name or
server-1 | service not known
server-1 |
server-1 | During handling of the above
server-1 | exception, another exception
server-1 | occurred:
server-1 |
server-1 | ╭─ Traceback (most recent call last─╮
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/_exceptions.py:10 │
server-1 | │ in map_exceptions │
server-1 | │ │
server-1 | │ 7 @contextlib.contextmanager │
server-1 | │ 8 def map_exceptions(map: Exce │
server-1 | │ 9 │ try: │
server-1 | │ ❱ 10 │ │ yield │
server-1 | │ 11 │ except Exception as exc: │
server-1 | │ 12 │ │ for from_exc, to_exc │
server-1 | │ 13 │ │ │ if isinstance(ex │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/_backends/sync.py │
server-1 | │ :212 in connect_tcp │
server-1 | │ │
server-1 | │ 209 │ │ } │
server-1 | │ 210 │ │ │
server-1 | │ 211 │ │ with map_exceptions │
server-1 | │ ❱ 212 │ │ │ sock = socket.c │
server-1 | │ 213 │ │ │ │ address, │
server-1 | │ 214 │ │ │ │ timeout, │
server-1 | │ 215 │ │ │ │ source_addr │
server-1 | │ │
server-1 | │ /usr/lib/python3.10/socket.py:824 │
server-1 | │ in create_connection │
server-1 | │ │
server-1 | │ 821 │ │
server-1 | │ 822 │ host, port = address │
server-1 | │ 823 │ err = None │
server-1 | │ ❱ 824 │ for res in getaddrinfo( │
server-1 | │ 825 │ │ af, socktype, proto │
server-1 | │ 826 │ │ sock = None │
server-1 | │ 827 │ │ try: │
server-1 | │ │
server-1 | │ /usr/lib/python3.10/socket.py:955 │
server-1 | │ in getaddrinfo │
server-1 | │ │
server-1 | │ 952 │ # We override this func │
server-1 | │ 953 │ # and socket type value │
server-1 | │ 954 │ addrlist = [] │
server-1 | │ ❱ 955 │ for res in _socket.geta │
server-1 | │ 956 │ │ af, socktype, proto │
server-1 | │ 957 │ │ addrlist.append((_i │
server-1 | │ 958 │ │ │ │ │ │ _i │
server-1 | ╰───────────────────────────────────╯
server-1 | gaierror: [Errno -2] Name or service
server-1 | not known
server-1 |
server-1 | The above exception was the direct
server-1 | cause of the following exception:
server-1 |
server-1 | ╭─ Traceback (most recent call last─╮
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_transports/default. │
server-1 | │ py:66 in map_httpcore_exceptions │
server-1 | │ │
server-1 | │ 63 @contextlib.contextmanager │
server-1 | │ 64 def map_httpcore_exceptions │
server-1 | │ 65 │ try: │
server-1 | │ ❱ 66 │ │ yield │
server-1 | │ 67 │ except Exception as exc │
server-1 | │ 68 │ │ mapped_exc = None │
server-1 | │ 69 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_transports/default. │
server-1 | │ py:228 in handle_request │
server-1 | │ │
server-1 | │ 225 │ │ │ extensions=requ │
server-1 | │ 226 │ │ ) │
server-1 | │ 227 │ │ with map_httpcore_e │
server-1 | │ ❱ 228 │ │ │ resp = self._po │
server-1 | │ 229 │ │ │
server-1 | │ 230 │ │ assert isinstance(r │
server-1 | │ 231 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/sync/connection
server-1 | │ pool.py:262 in handle_request │
server-1 | │ │
server-1 | │ 259 │ │ │ except BaseExce │
server-1 | │ 260 │ │ │ │ with Shield │
server-1 | │ 261 │ │ │ │ │ self.re │
server-1 | │ ❱ 262 │ │ │ │ raise exc │
server-1 | │ 263 │ │ │ else: │
server-1 | │ 264 │ │ │ │ break │
server-1 | │ 265 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/sync/connection
server-1 | │ pool.py:245 in handle_request │
server-1 | │ │
server-1 | │ 242 │ │ │ │ │ raise e │
server-1 | │ 243 │ │ │ │
server-1 | │ 244 │ │ │ try: │
server-1 | │ ❱ 245 │ │ │ │ response = │
server-1 | │ 246 │ │ │ except Connecti │
server-1 | │ 247 │ │ │ │ # The Conne │
server-1 | │ 248 │ │ │ │ # indicates │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/_sync/connection. │
server-1 | │ py:99 in handle_request │
server-1 | │ │
server-1 | │ 96 │ │ │ │ │ │ ) │
server-1 | │ 97 │ │ │ │ except Exce │
server-1 | │ 98 │ │ │ │ │ self.c │
server-1 | │ ❱ 99 │ │ │ │ │ raise e │
server-1 | │ 100 │ │ │ elif not self.

server-1 | │ 101 │ │ │ │ raise Conne │
server-1 | │ 102 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/_sync/connection. │
server-1 | │ py:76 in handle_request │
server-1 | │ │
server-1 | │ 73 │ │ with self.request
server-1 | │ 74 │ │ │ if self._connec │
server-1 | │ 75 │ │ │ │ try: │
server-1 | │ ❱ 76 │ │ │ │ │ stream │
server-1 | │ 77 │ │ │ │ │ │
server-1 | │ 78 │ │ │ │ │ ssl_obj │
server-1 | │ 79 │ │ │ │ │ http2_n │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/_sync/connection. │
server-1 | │ py:124 in _connect │
server-1 | │ │
server-1 | │ 121 │ │ │ │ │ │ "so │
server-1 | │ 122 │ │ │ │ │ } │
server-1 | │ 123 │ │ │ │ │ with Tr │
server-1 | │ ❱ 124 │ │ │ │ │ │ str │
server-1 | │ 125 │ │ │ │ │ │ tra │
server-1 | │ 126 │ │ │ │ else: │
server-1 | │ 127 │ │ │ │ │ kwargs │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/_backends/sync.py │
server-1 | │ :211 in connect_tcp │
server-1 | │ │
server-1 | │ 208 │ │ │ OSError: Connec │
server-1 | │ 209 │ │ } │
server-1 | │ 210 │ │ │
server-1 | │ ❱ 211 │ │ with map_exceptions │
server-1 | │ 212 │ │ │ sock = socket.c │
server-1 | │ 213 │ │ │ │ address, │
server-1 | │ 214 │ │ │ │ timeout, │
server-1 | │ │
server-1 | │ /usr/lib/python3.10/contextlib.py │
server-1 | │ :153 in exit
server-1 | │ │
server-1 | │ 150 │ │ │ │ # tell if w │
server-1 | │ 151 │ │ │ │ value = typ │
server-1 | │ 152 │ │ │ try: │
server-1 | │ ❱ 153 │ │ │ │ self.gen.th │
server-1 | │ 154 │ │ │ except StopIter │
server-1 | │ 155 │ │ │ │ # Suppress │
server-1 | │ 156 │ │ │ │ # was passe │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpcore/_exceptions.py:14 │
server-1 | │ in map_exceptions │
server-1 | │ │
server-1 | │ 11 │ except Exception as exc: │
server-1 | │ 12 │ │ for from_exc, to_exc │
server-1 | │ 13 │ │ │ if isinstance(ex │
server-1 | │ ❱ 14 │ │ │ │ raise to_exc │
server-1 | │ 15 │ │ raise # pragma: noc │
server-1 | │ 16 │
server-1 | │ 17 │
server-1 | ╰───────────────────────────────────╯
server-1 | ConnectError: [Errno -2] Name or
server-1 | service not known
server-1 |
server-1 | The above exception was the direct
server-1 | cause of the following exception:
server-1 |
server-1 | ╭─ Traceback (most recent call last─╮
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:993 │
server-1 | │ in _request │
server-1 | │ │
server-1 | │ 990 │ │ log.debug("Sending │
server-1 | │ 991 │ │ │
server-1 | │ 992 │ │ try: │
server-1 | │ ❱ 993 │ │ │ response = sel │
server-1 | │ 994 │ │ │ │ request, │
server-1 | │ 995 │ │ │ │ stream=str │
server-1 | │ 996 │ │ │ │ **kwargs, │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_client.py:901 in │
server-1 | │ send │
server-1 | │ │
server-1 | │ 898 │ │ │
server-1 | │ 899 │ │ auth = self._build │
server-1 | │ 900 │ │ │
server-1 | │ ❱ 901 │ │ response = self._s │
server-1 | │ 902 │ │ │ request, │
server-1 | │ 903 │ │ │ auth=auth, │
server-1 | │ 904 │ │ │ follow_redirec │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_client.py:929 in │
server-1 | │ _send_handling_auth │
server-1 | │ │
server-1 | │ 926 │ │ │ request = next │
server-1 | │ 927 │ │ │ │
server-1 | │ 928 │ │ │ while True: │
server-1 | │ ❱ 929 │ │ │ │ response = │
server-1 | │ 930 │ │ │ │ │ reques │
server-1 | │ 931 │ │ │ │ │ follow │
server-1 | │ 932 │ │ │ │ │ histor │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_client.py:966 in │
server-1 | │ _send_handling_redirects │
server-1 | │ │
server-1 | │ 963 │ │ │ for hook in se │
server-1 | │ 964 │ │ │ │ hook(reque │
server-1 | │ 965 │ │ │ │
server-1 | │ ❱ 966 │ │ │ response = sel │
server-1 | │ 967 │ │ │ try: │
server-1 | │ 968 │ │ │ │ for hook i │
server-1 | │ 969 │ │ │ │ │ hook(r │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_client.py:1002 in │
server-1 | │ _send_single_request │
server-1 | │ │
server-1 | │ 999 │ │ │ ) │
server-1 | │ 1000 │ │ │
server-1 | │ 1001 │ │ with request_conte │
server-1 | │ ❱ 1002 │ │ │ response = tra │
server-1 | │ 1003 │ │ │
server-1 | │ 1004 │ │ assert isinstance( │
server-1 | │ 1005 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_transports/default. │
server-1 | │ py:227 in handle_request │
server-1 | │ │
server-1 | │ 224 │ │ │ content=request │
server-1 | │ 225 │ │ │ extensions=requ │
server-1 | │ 226 │ │ ) │
server-1 | │ ❱ 227 │ │ with map_httpcore_e │
server-1 | │ 228 │ │ │ resp = self._po │
server-1 | │ 229 │ │ │
server-1 | │ 230 │ │ assert isinstance(r │
server-1 | │ │
server-1 | │ /usr/lib/python3.10/contextlib.py │
server-1 | │ :153 in exit
server-1 | │ │
server-1 | │ 150 │ │ │ │ # tell if w │
server-1 | │ 151 │ │ │ │ value = typ │
server-1 | │ 152 │ │ │ try: │
server-1 | │ ❱ 153 │ │ │ │ self.gen.th │
server-1 | │ 154 │ │ │ except StopIter │
server-1 | │ 155 │ │ │ │ # Suppress │
server-1 | │ 156 │ │ │ │ # was passe │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/httpx/_transports/default. │
server-1 | │ py:83 in map_httpcore_exceptions │
server-1 | │ │
server-1 | │ 80 │ │ │ raise │
server-1 | │ 81 │ │ │
server-1 | │ 82 │ │ message = str(exc) │
server-1 | │ ❱ 83 │ │ raise mapped_exc(me │
server-1 | │ 84 │
server-1 | │ 85 │
server-1 | │ 86 HTTPCORE_EXC_MAP = { │
server-1 | ╰───────────────────────────────────╯
server-1 | ConnectError: [Errno -2] Name or
server-1 | service not known
server-1 |
server-1 | The above exception was the direct
server-1 | cause of the following exception:
server-1 |
server-1 | ╭─ Traceback (most recent call last─╮
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/uvicorn/protocols/http/h11 │
server-1 | │ _impl.py:406 in run_asgi │
server-1 | │ │
server-1 | │ 403 │ # ASGI exception wrappe │
server-1 | │ 404 │ async def run_asgi(self │
server-1 | │ 405 │ │ try: │
server-1 | │ ❱ 406 │ │ │ result = await │
server-1 | │ 407 │ │ │ │ self.scope, │
server-1 | │ 408 │ │ │ ) │
server-1 | │ 409 │ │ except BaseExceptio │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/uvicorn/middleware/proxy_h │
server-1 | │ eaders.py:70 in call
server-1 | │ │
server-1 | │ 67 │ │ │ │ │ port = 0 │
server-1 | │ 68 │ │ │ │ │ scope["c │
server-1 | │ 69 │ │ │
server-1 | │ ❱ 70 │ │ return await self.ap │
server-1 | │ 71 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/fastapi/applications.py:10 │
server-1 | │ 54 in call
server-1 | │ │
server-1 | │ 1051 │ async def call(sel │
server-1 | │ 1052 │ │ if self.root_path: │
server-1 | │ 1053 │ │ │ scope["root_pa │
server-1 | │ ❱ 1054 │ │ await super()._ca │
server-1 | │ 1055 │ │
server-1 | │ 1056 │ def add_api_route( │
server-1 | │ 1057 │ │ self, │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/applications.py: │
server-1 | │ 113 in call
server-1 | │ │
server-1 | │ 110 │ │ scope["app"] = self │
server-1 | │ 111 │ │ if self.middleware

server-1 | │ 112 │ │ │ self.middleware │
server-1 | │ ❱ 113 │ │ await self.middlewa │
server-1 | │ 114 │ │
server-1 | │ 115 │ def on_event(self, even │
server-1 | │ 116 │ │ return self.router. │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/error │
server-1 | │ s.py:187 in call
server-1 | │ │
server-1 | │ 184 │ │ │ # We always con │
server-1 | │ 185 │ │ │ # This allows s │
server-1 | │ 186 │ │ │ # to optionally │
server-1 | │ ❱ 187 │ │ │ raise exc │
server-1 | │ 188 │ │
server-1 | │ 189 │ def format_line(self, i │
server-1 | │ str: │
server-1 | │ 190 │ │ values = { │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/error │
server-1 | │ s.py:165 in call
server-1 | │ │
server-1 | │ 162 │ │ │ await send(mess │
server-1 | │ 163 │ │ │
server-1 | │ 164 │ │ try: │
server-1 | │ ❱ 165 │ │ │ await self.app( │
server-1 | │ 166 │ │ except Exception as │
server-1 | │ 167 │ │ │ request = Reque │
server-1 | │ 168 │ │ │ if self.debug: │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/sessi │
server-1 | │ ons.py:85 in call
server-1 | │ │
server-1 | │ 82 │ │ │ │ │ headers. │
server-1 | │ 83 │ │ │ await send(messa │
server-1 | │ 84 │ │ │
server-1 | │ ❱ 85 │ │ await self.app(scope │
server-1 | │ 86 │
server-1 | │ │
server-1 | │ /app/src/khoj/configure.py:351 in │
server-1 | │ call
server-1 | │ │
server-1 | │ 348 │ │ async def call( │
server-1 | │ 349 │ │ │ if scope["type" │
server-1 | │ 350 │ │ │ │ scope["path │
server-1 | │ ❱ 351 │ │ │ await self.app( │
server-1 | │ 352 │ │ │
server-1 | │ 353 │ │ def init(self, │
server-1 | │ 354 │ │ │ super()._init
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/authe │
server-1 | │ ntication.py:48 in call
server-1 | │ │
server-1 | │ 45 │ │ if auth_result is No │
server-1 | │ 46 │ │ │ auth_result = Au │
server-1 | │ 47 │ │ scope["auth"], scope │
server-1 | │ ❱ 48 │ │ await self.app(scope │
server-1 | │ 49 │ │
server-1 | │ 50 │ @staticmethod
server-1 | │ 51 │ def default_on_error(con │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/base. │
server-1 | │ py:188 in call
server-1 | │ │
server-1 | │ 185 │ │ with collapse_excgr │
server-1 | │ 186 │ │ │ async with anyi │
server-1 | │ 187 │ │ │ │ response = │
server-1 | │ ❱ 188 │ │ │ │ await respo │
server-1 | │ 189 │ │ │ │ response_se │
server-1 | │ 190 │ │
server-1 | │ 191 │ async def dispatch(self │
server-1 | │ Response: │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/base. │
server-1 | │ py:222 in call
server-1 | │ │
server-1 | │ 219 │ │ │ } │
server-1 | │ 220 │ │ ) │
server-1 | │ 221 │ │ │
server-1 | │ ❱ 222 │ │ async for chunk in │
server-1 | │ 223 │ │ │ await send({"ty │
server-1 | │ 224 │ │ │
server-1 | │ 225 │ │ await send({"type": │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/base. │
server-1 | │ py:179 in body_stream │
server-1 | │ │
server-1 | │ 176 │ │ │ │ │ │ │ │
server-1 | │ 177 │ │ │ │ │
server-1 | │ 178 │ │ │ │ if app_exc │
server-1 | │ ❱ 179 │ │ │ │ │ raise a │
server-1 | │ 180 │ │ │ │
server-1 | │ 181 │ │ │ response = _Str │
server-1 | │ content=body_stream(), info │
server-1 | │ 182 │ │ │ response.raw_he │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/base. │
server-1 | │ py:149 in coro │
server-1 | │ │
server-1 | │ 146 │ │ │ │ │
server-1 | │ 147 │ │ │ │ async with │
server-1 | │ 148 │ │ │ │ │ try: │
server-1 | │ ❱ 149 │ │ │ │ │ │ awa │
server-1 | │ 150 │ │ │ │ │ except │
server-1 | │ 151 │ │ │ │ │ │ app │
server-1 | │ 152 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/cors. │
server-1 | │ py:93 in call
server-1 | │ │
server-1 | │ 90 │ │ │ await response( │
server-1 | │ 91 │ │ │ return │
server-1 | │ 92 │ │ │
server-1 | │ ❱ 93 │ │ await self.simple_r │
server-1 | │ 94 │ │
server-1 | │ 95 │ def is_allowed_origin(s │
server-1 | │ 96 │ │ if self.allow_all_o │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/cors. │
server-1 | │ py:144 in simple_response │
server-1 | │ │
server-1 | │ 141 │ │
server-1 | │ 142 │ async def simple_respon │
server-1 | │ request_headers: Headers) - │
server-1 | │ 143 │ │ send = functools.pa │
server-1 | │ ❱ 144 │ │ await self.app(scop │
server-1 | │ 145 │ │
server-1 | │ 146 │ async def send(self, me │
server-1 | │ None: │
server-1 | │ 147 │ │ if message["type"] │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/middleware/excep │
server-1 | │ tions.py:62 in call
server-1 | │ │
server-1 | │ 59 │ │ else: │
server-1 | │ 60 │ │ │ conn = WebSocket │
server-1 | │ 61 │ │ │
server-1 | │ ❱ 62 │ │ await wrap_app_handl │
server-1 | │ 63 │ │
server-1 | │ 64 │ def http_exception(self, │
server-1 | │ 65 │ │ assert isinstance(ex │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/_exception_handl │
server-1 | │ er.py:53 in wrapped_app │
server-1 | │ │
server-1 | │ 50 │ │ │ │ handler = _l │
server-1 | │ 51 │ │ │ │
server-1 | │ 52 │ │ │ if handler is No │
server-1 | │ ❱ 53 │ │ │ │ raise exc │
server-1 | │ 54 │ │ │ │
server-1 | │ 55 │ │ │ if response_star │
server-1 | │ 56 │ │ │ │ raise Runtim │
server-1 | │ started.") from exc │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/_exception_handl │
server-1 | │ er.py:42 in wrapped_app │
server-1 | │ │
server-1 | │ 39 │ │ │ await send(messa │
server-1 | │ 40 │ │ │
server-1 | │ 41 │ │ try: │
server-1 | │ ❱ 42 │ │ │ await app(scope, │
server-1 | │ 43 │ │ except Exception as │
server-1 | │ 44 │ │ │ handler = None │
server-1 | │ 45 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/routing.py:715 │
server-1 | │ in call
server-1 | │ │
server-1 | │ 712 │ │ """ │
server-1 | │ 713 │ │ The main entry poin │
server-1 | │ 714 │ │ """ │
server-1 | │ ❱ 715 │ │ await self.middlewa │
server-1 | │ 716 │ │
server-1 | │ 717 │ async def app(self, sco │
server-1 | │ 718 │ │ assert scope["type" │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/routing.py:735 │
server-1 | │ in app │
server-1 | │ │
server-1 | │ 732 │ │ │ match, child_sc │
server-1 | │ 733 │ │ │ if match == Mat │
server-1 | │ 734 │ │ │ │ scope.updat │
server-1 | │ ❱ 735 │ │ │ │ await route │
server-1 | │ 736 │ │ │ │ return │
server-1 | │ 737 │ │ │ elif match == M │
server-1 | │ 738 │ │ │ │ partial = r │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/routing.py:288 │
server-1 | │ in handle │
server-1 | │ │
server-1 | │ 285 │ │ │ │ response = │
server-1 | │ headers=headers) │
server-1 | │ 286 │ │ │ await response( │
server-1 | │ 287 │ │ else: │
server-1 | │ ❱ 288 │ │ │ await self.app( │
server-1 | │ 289 │ │
server-1 | │ 290 │ def eq(self, other: │
server-1 | │ 291 │ │ return ( │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/routing.py:76 in │
server-1 | │ app │
server-1 | │ │
server-1 | │ 73 │ │ │ response = awai │
server-1 | │ 74 │ │ │ await response( │
server-1 | │ 75 │ │ │
server-1 | │ ❱ 76 │ │ await wrap_app_hand │
server-1 | │ 77 │ │
server-1 | │ 78 │ return app │
server-1 | │ 79 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/_exception_handl │
server-1 | │ er.py:53 in wrapped_app │
server-1 | │ │
server-1 | │ 50 │ │ │ │ handler = _l │
server-1 | │ 51 │ │ │ │
server-1 | │ 52 │ │ │ if handler is No │
server-1 | │ ❱ 53 │ │ │ │ raise exc │
server-1 | │ 54 │ │ │ │
server-1 | │ 55 │ │ │ if response_star │
server-1 | /usr/local/lib/python3.10/dist-packages/django/db/models/fields/init.py:1655: RuntimeWarning: DateTimeField Conversation.updated_at received a naive datetime (2024-12-24 18:10:00.120671) while time zone support is active.
server-1 | warnings.warn(
server-1 | │ 56 │ │ │ │ raise Runtim │
server-1 | │ started.") from exc │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/exception_handl │
server-1 | │ er.py:42 in wrapped_app │
server-1 | │ │
server-1 | │ 39 │ │ │ await send(messa │
server-1 | │ 40 │ │ │
server-1 | │ 41 │ │ try: │
server-1 | │ ❱ 42 │ │ │ await app(scope, │
server-1 | │ 43 │ │ except Exception as │
server-1 | │ 44 │ │ │ handler = None │
server-1 | │ 45 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/routing.py:74 in │
server-1 | │ app │
server-1 | │ │
server-1 | │ 71 │ │ │
server-1 | │ 72 │ │ async def app(scope │
server-1 | │ 73 │ │ │ response = awai │
server-1 | │ ❱ 74 │ │ │ await response( │
server-1 | │ 75 │ │ │
server-1 | │ 76 │ │ await wrap_app_hand │
server-1 | │ 77 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/responses.py:252 │
server-1 | │ in call
server-1 | │ │
server-1 | │ 249 │ │ await send({"type": │
server-1 | │ 250 │ │
server-1 | │ 251 │ async def call(self │
server-1 | │ ❱ 252 │ │ async with anyio.cr │
server-1 | │ 253 │ │ │ │
server-1 | │ 254 │ │ │ async def wrap( │
server-1 | │ 255 │ │ │ │ await func( │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/anyio/backends/asyncio.p │
server-1 | │ y:597 in aexit
server-1 | │ │
server-1 | │ 594 │ │ │ │ else: │
server-1 | │ 595 │ │ │ │ │ raise │
server-1 | │ 596 │ │ │ elif exception │
server-1 | │ ❱ 597 │ │ │ │ raise exce │
server-1 | │ 598 │ │ except BaseExcepti │
server-1 | │ 599 │ │ │ # Clear the co │
server-1 | │ 600 │ │ │ # If the conte │
server-1 | │ #145). │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/responses.py:255 │
server-1 | │ in wrap │
server-1 | │ │
server-1 | │ 252 │ │ async with anyio.cr │
server-1 | │ 253 │ │ │ │
server-1 | │ 254 │ │ │ async def wrap( │
server-1 | │ ❱ 255 │ │ │ │ await func( │
server-1 | │ 256 │ │ │ │ task_group. │
server-1 | │ 257 │ │ │ │
server-1 | │ 258 │ │ │ task_group.star │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/starlette/responses.py:244 │
server-1 | │ in stream_response │
server-1 | │ │
server-1 | │ 241 │ │ │ │ "headers": │
server-1 | │ 242 │ │ │ } │
server-1 | │ 243 │ │ ) │
server-1 | │ ❱ 244 │ │ async for chunk in │
server-1 | │ 245 │ │ │ if not isinstan │
server-1 | │ 246 │ │ │ │ chunk = chu │
server-1 | │ 247 │ │ │ await send({"ty │
server-1 | │ │
server-1 | │ /app/src/khoj/routers/api_chat.py │
server-1 | │ :788 in event_generator │
server-1 | │ │
server-1 | │ 785 │ │ program_execution

server-1 | │ 786 │ │ │
server-1 | │ 787 │ │ if conversation_co │
server-1 | │ ❱ 788 │ │ │ chosen_io = aw │
server-1 | │ 789 │ │ │ │ q, │
server-1 | │ 790 │ │ │ │ meta_log, │
server-1 | │ 791 │ │ │ │ is_automat │
server-1 | │ │
server-1 | │ /app/src/khoj/routers/helpers.py: │
server-1 | │ 396 in │
server-1 | │ aget_data_sources_and_output_form │
server-1 | │ at │
server-1 | │ │
server-1 | │ 393 │ ) │
server-1 | │ 394 │ │
server-1 | │ 395 │ with timer("Chat actor │
server-1 | │ ❱ 396 │ │ response = await s │
server-1 | │ 397 │ │ │ relevant_tools │
server-1 | │ 398 │ │ │ response_type= │
server-1 | │ 399 │ │ │ user=user, │
server-1 | │ │
server-1 | │ /app/src/khoj/routers/helpers.py: │
server-1 | │ 1035 in │
server-1 | │ send_message_to_model_wrapper │
server-1 | │ │
server-1 | │ 1032 │ │ │ query_files=qu │
server-1 | │ 1033 │ │ ) │
server-1 | │ 1034 │ │ │
server-1 | │ ❱ 1035 │ │ return send_messag │
server-1 | │ 1036 │ │ │ messages=trunc │
server-1 | │ 1037 │ │ │ api_key=api_ke │
server-1 | │ 1038 │ │ │ model=chat_mod │
server-1 | │ │
server-1 | │ /app/src/khoj/processor/conversat │
server-1 | │ ion/openai/gpt.py:129 in │
server-1 | │ send_message_to_model │
server-1 | │ │
server-1 | │ 126 │ """ │
server-1 | │ 127 │ │
server-1 | │ 128 │ # Get Response from GPT │
server-1 | │ ❱ 129 │ return completion_with

server-1 | │ 130 │ │ messages=messages, │
server-1 | │ 131 │ │ model_name=model, │
server-1 | │ 132 │ │ openai_api_key=api

server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/tenacity/init.py:330 │
server-1 | │ in wrapped_f │
server-1 | │ │
server-1 | │ 327 │ │ │ f, functools.WR │
server-1 | │ 328 │ │ ) │
server-1 | │ 329 │ │ def wrapped_f(*args │
server-1 | │ ❱ 330 │ │ │ return self(f, │
server-1 | │ 331 │ │ │
server-1 | │ 332 │ │ def retry_with(*arg │
server-1 | │ 333 │ │ │ return self.cop │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/tenacity/init.py:467 │
server-1 | │ in call
server-1 | │ │
server-1 | │ 464 │ │ │
server-1 | │ 465 │ │ retry_state = Retry │
server-1 | │ 466 │ │ while True: │
server-1 | │ ❱ 467 │ │ │ do = self.iter( │
server-1 | │ 468 │ │ │ if isinstance(d │
server-1 | │ 469 │ │ │ │ try: │
server-1 | │ 470 │ │ │ │ │ result │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/tenacity/init.py:368 │
server-1 | │ in iter │
server-1 | │ │
server-1 | │ 365 │ │ self._begin_iter(re │
server-1 | │ 366 │ │ result = None │
server-1 | │ 367 │ │ for action in self. │
server-1 | │ ❱ 368 │ │ │ result = action │
server-1 | │ 369 │ │ return result │
server-1 | │ 370 │ │
server-1 | │ 371 │ def _begin_iter(self, r │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/tenacity/init.py:410 │
server-1 | │ in exc_check │
server-1 | │ │
server-1 | │ 407 │ │ │ │ fut = t.cas │
server-1 | │ 408 │ │ │ │ retry_exc = │
server-1 | │ 409 │ │ │ │ if self.rer │
server-1 | │ ❱ 410 │ │ │ │ │ raise r │
server-1 | │ 411 │ │ │ │ raise retry │
server-1 | │ 412 │ │ │ │
server-1 | │ 413 │ │ │ self._add_actio │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/tenacity/init.py:183 │
server-1 | │ in reraise │
server-1 | │ │
server-1 | │ 180 │ │
server-1 | │ 181 │ def reraise(self) -> t. │
server-1 | │ 182 │ │ if self.last_attemp │
server-1 | │ ❱ 183 │ │ │ raise self.last │
server-1 | │ 184 │ │ raise self │
server-1 | │ 185 │ │
server-1 | │ 186 │ def str(self) -> st │
server-1 | │ │
server-1 | │ /usr/lib/python3.10/concurrent/fu │
server-1 | │ tures/_base.py:451 in result │
server-1 | │ │
server-1 | │ 448 │ │ │ │ if self.st │
server-1 | │ 449 │ │ │ │ │ raise C │
server-1 | │ 450 │ │ │ │ elif self.

server-1 | │ ❱ 451 │ │ │ │ │ return │
server-1 | │ 452 │ │ │ │ │
server-1 | │ 453 │ │ │ │ self._condi │
server-1 | │ 454 │
server-1 | │ │
server-1 | │ /usr/lib/python3.10/concurrent/fu │
server-1 | │ tures/_base.py:403 in │
server-1 | │ __get_result │
server-1 | │ │
server-1 | │ 400 │ def _get_result(self): │
server-1 | │ 401 │ │ if self.exception: │
server-1 | │ 402 │ │ │ try: │
server-1 | │ ❱ 403 │ │ │ │ raise self. │
server-1 | │ 404 │ │ │ finally: │
server-1 | │ 405 │ │ │ │ # Break a r │
server-1 | │ 406 │ │ │ │ self = None │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/tenacity/init.py:470 │
server-1 | │ in call
server-1 | │ │
server-1 | │ 467 │ │ │ do = self.iter( │
server-1 | │ 468 │ │ │ if isinstance(d │
server-1 | │ 469 │ │ │ │ try: │
server-1 | │ ❱ 470 │ │ │ │ │ result │
server-1 | │ 471 │ │ │ │ except Base │
server-1 | │ 472 │ │ │ │ │ retry_s │
server-1 | │ 473 │ │ │ │ else: │
server-1 | │ │
server-1 | │ /app/src/khoj/processor/conversat │
server-1 | │ ion/openai/utils.py:77 in │
server-1 | │ completion_with_backoff │
server-1 | │ │
server-1 | │ 74 │ if os.getenv("KHOJ_LLM

server-1 | │ 75 │ │ model_kwargs["seed" │
server-1 | │ 76 │ │
server-1 | │ ❱ 77 │ chat: ChatCompletion | │
server-1 | │ client.chat.completions.cre │
server-1 | │ 78 │ │ messages=formatted

server-1 | │ 79 │ │ model=model_name, │
server-1 | │ 80 │ │ stream=stream, │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_utils/utils.py:27 │
server-1 | │ 9 in wrapper │
server-1 | │ │
server-1 | │ 276 │ │ │ │ │ else: │
server-1 | │ 277 │ │ │ │ │ │ msg │
server-1 | │ 278 │ │ │ │ raise TypeE │
server-1 | │ ❱ 279 │ │ │ return func(*ar │
server-1 | │ 280 │ │ │
server-1 | │ 281 │ │ return wrapper # t │
server-1 | │ 282 │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/resources/chat/comp │
server-1 | │ letions.py:859 in create │
server-1 | │ │
server-1 | │ 856 │ │ timeout: float | h │
server-1 | │ 857 │ ) -> ChatCompletion | │
server-1 | │ 858 │ │ validate_response

server-1 | │ ❱ 859 │ │ return self._post( │
server-1 | │ 860 │ │ │ "/chat/complet │
server-1 | │ 861 │ │ │ body=maybe_tra │
server-1 | │ 862 │ │ │ │ { │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:128 │
server-1 | │ 0 in post │
server-1 | │ │
server-1 | │ 1277 │ │ opts = FinalReques │
server-1 | │ 1278 │ │ │ method="post", │
server-1 | │ **options │
server-1 | │ 1279 │ │ ) │
server-1 | │ ❱ 1280 │ │ return cast(Respon │
server-1 | │ stream_cls=stream_cls)) │
server-1 | │ 1281 │ │
server-1 | │ 1282 │ def patch( │
server-1 | │ 1283 │ │ self, │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:957 │
server-1 | │ in request │
server-1 | │ │
server-1 | │ 954 │ │ else: │
server-1 | │ 955 │ │ │ retries_taken │
server-1 | │ 956 │ │ │
server-1 | │ ❱ 957 │ │ return self._reque │
server-1 | │ 958 │ │ │ cast_to=cast_t │
server-1 | │ 959 │ │ │ options=option │
server-1 | │ 960 │ │ │ stream=stream, │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:101 │
server-1 | │ 7 in request │
server-1 | │ │
server-1 | │ 1014 │ │ │ log.debug("Enc │
server-1 | │ 1015 │ │ │ │
server-1 | │ 1016 │ │ │ if remaining_r │
server-1 | │ ❱ 1017 │ │ │ │ return sel │
server-1 | │ 1018 │ │ │ │ │ input

server-1 | │ 1019 │ │ │ │ │ cast_t │
server-1 | │ 1020 │ │ │ │ │ retrie │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:109 │
server-1 | │ 5 in _retry_request │
server-1 | │ │
server-1 | │ 1092 │ │ # different thread │
server-1 | │ 1093 │ │ time.sleep(timeout │
server-1 | │ 1094 │ │ │
server-1 | │ ❱ 1095 │ │ return self._reque │
server-1 | │ 1096 │ │ │ options=option │
server-1 | │ 1097 │ │ │ cast_to=cast_t │
server-1 | │ 1098 │ │ │ retries_taken= │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:101 │
server-1 | │ 7 in request │
server-1 | │ │
server-1 | │ 1014 │ │ │ log.debug("Enc │
server-1 | │ 1015 │ │ │ │
server-1 | │ 1016 │ │ │ if remaining_r │
server-1 | │ ❱ 1017 │ │ │ │ return sel │
server-1 | │ 1018 │ │ │ │ │ input

server-1 | │ 1019 │ │ │ │ │ cast_t │
server-1 | │ 1020 │ │ │ │ │ retrie │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:109 │
server-1 | │ 5 in _retry_request │
server-1 | │ │
server-1 | │ 1092 │ │ # different thread │
server-1 | │ 1093 │ │ time.sleep(timeout │
server-1 | │ 1094 │ │ │
server-1 | │ ❱ 1095 │ │ return self._reque │
server-1 | │ 1096 │ │ │ options=option │
server-1 | │ 1097 │ │ │ cast_to=cast_t │
server-1 | │ 1098 │ │ │ retries_taken= │
server-1 | │ │
server-1 | │ /usr/local/lib/python3.10/dist-pa │
server-1 | │ ckages/openai/_base_client.py:102 │
server-1 | │ 7 in _request │
server-1 | │ │
server-1 | │ 1024 │ │ │ │ ) │
server-1 | │ 1025 │ │ │ │
server-1 | │ 1026 │ │ │ log.debug("Rai │
server-1 | │ ❱ 1027 │ │ │ raise APIConne │
server-1 | │ 1028 │ │ │
server-1 | │ 1029 │ │ log.debug( │
server-1 | │ 1030 │ │ │ 'HTTP Response │
server-1 | ╰───────────────────────────────────╯
server-1 | APIConnectionError: Connection error.


@baditaflorin
Copy link
Author

To try to have everything in one place this is the setup that I needed to arrive just to be able to access the admin panel repeatably without the CORS errors and to try to have all things in one network so they can communicate between themselves

entrypoint.sh

#!/bin/bash
set -e

# Path to the settings file
SETTINGS_FILE="/app/src/khoj/app/settings.py"

# Add the correct Python path
export PYTHONPATH="/app/src:${PYTHONPATH}"

# Set Django settings module
export DJANGO_SETTINGS_MODULE="khoj.app.settings"

# Backup the original settings file
cp $SETTINGS_FILE "${SETTINGS_FILE}.bak"

# Append CSRF settings to the file
cat >> $SETTINGS_FILE << 'END'
# CSRF Settings Override
import os

CSRF_COOKIE_DOMAIN = os.getenv('CSRF_COOKIE_DOMAIN', '1.1.1.1')
CSRF_COOKIE_SECURE = os.getenv('CSRF_COOKIE_SECURE', 'False').lower() == 'true'
CSRF_USE_SESSIONS = os.getenv('CSRF_USE_SESSIONS', 'True').lower() == 'true'
CSRF_COOKIE_SAMESITE = os.getenv('CSRF_COOKIE_SAMESITE', 'None')
SESSION_COOKIE_DOMAIN = os.getenv('SESSION_COOKIE_DOMAIN', '1.1.1.1')
SESSION_COOKIE_SECURE = os.getenv('SESSION_COOKIE_SECURE', 'False').lower() == 'true'
CSRF_COOKIE_HTTPONLY = os.getenv('CSRF_COOKIE_HTTPONLY', 'False').lower() == 'true'
CSRF_HEADER_NAME = os.getenv('CSRF_HEADER_NAME', 'HTTP_X_CSRFTOKEN')
END

# Change to the correct directory
cd /app/src

# Run the Khoj server with the provided arguments
python3 -m khoj.main "$@"

Dockerfile.khoj

FROM ghcr.io/khoj-ai/khoj:latest

# Copy the entrypoint script
COPY entrypoint.sh /entrypoint.sh

# Make the entrypoint script executable
RUN chmod +x /entrypoint.sh

# Set the entrypoint
ENTRYPOINT ["/entrypoint.sh"]

# Set default command (this will be passed to entrypoint.sh)
CMD ["--host=0.0.0.0", "--port=42110", "-vv", "--anonymous-mode", "--non-interactive"]

docker-compose.yml

version: '3.8'

services:
  ollama:
    image: ollama/ollama:latest
    ports:
      - "11434:11434"
    volumes:
      - ollama_data:/root/.ollama
    environment:
      - OLLAMA_ORIGINS=*
      - OLLAMA_HOST=0.0.0.0
    command: >
      sh -c "ollama serve &
             sleep 10 &&
             ollama pull mistral:latest &&
             wait"
    extra_hosts:
      - "host.docker.internal:host-gateway"

  database:
    image: ankane/pgvector
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres&^%$
      POSTGRES_DB: postgres
    volumes:
      - khoj_db:/var/lib/postgresql/data/
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 30s
      timeout: 10s
      retries: 5
    extra_hosts:
      - "host.docker.internal:host-gateway"

  sandbox:
    image: ghcr.io/khoj-ai/terrarium:latest
    ports:
      - "8080:8080"
    extra_hosts:
      - "host.docker.internal:host-gateway"

  search:
    image: docker.io/searxng/searxng:latest
    ports:
      - "42113:8080"
    volumes:
      - khoj_search:/etc/searxng
    environment:
      - SEARXNG_BASE_URL=http://localhost:42113/
    extra_hosts:
      - "host.docker.internal:host-gateway"

  server:
    depends_on:
      database:
        condition: service_healthy
    build:
      context: .
      dockerfile: Dockerfile.khoj
    ports:
      - "42110:42110"
    working_dir: /app
    volumes:
      - khoj_config:/root/.khoj/
      - khoj_models:/root/.cache/torch/sentence_transformers
      - khoj_models:/root/.cache/huggingface
    environment:
      # Database settings
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres&^%$
      - POSTGRES_HOST=database
      - POSTGRES_PORT=5432

      # Khoj settings
      - KHOJ_DJANGO_SECRET_KEY=secret@#$%^
      - KHOJ_DEBUG=True
      - [email protected]
      - KHOJ_ADMIN_PASSWORD=password
      - KHOJ_TERRARIUM_URL=http://sandbox:8080
      - KHOJ_SEARXNG_URL=http://search:8080
      - OPENAI_API_BASE=http://docker.hosts.internal:11434/v1/

      # Domain settings
      - KHOJ_NO_HTTPS=True
      - KHOJ_DOMAIN=https://refactored-fiesta-4q4jx7p495cq65q-42110.app.github.dev
      - KHOJ_ALLOWED_HOSTS=https://refactored-fiesta-4q4jx7p495cq65q-42110.app.github.dev

      # CSRF and Session settings
      - CSRF_COOKIE_SECURE=False
      - DJANGO_CSRF_TRUSTED_ORIGINS=https://refactored-fiesta-4q4jx7p495cq65q-42110.app.github.dev
      - SESSION_COOKIE_SECURE=False
      - CSRF_COOKIE_DOMAIN=refactored-fiesta-4q4jx7p495cq65q-42110.app.github.dev
      - CSRF_COOKIE_SAMESITE=None
      - CSRF_USE_SESSIONS=True
      - CSRF_COOKIE_NAME=csrftoken
      - CSRF_COOKIE_HTTPONLY=False
      - CSRF_HEADER_NAME=HTTP_X_CSRFTOKEN
      - SESSION_COOKIE_DOMAIN=.refactored-fiesta-4q4jx7p495cq65q-42110.app.github.dev
    command: --host="0.0.0.0" --port=42110 -vv --anonymous-mode --non-interactive
    extra_hosts:
      - "host.docker.internal:host-gateway"

volumes:
  khoj_config:
  khoj_db:
  khoj_models:
  khoj_search:
  ollama_data:

@chenyunlin00
Copy link

I also encountered the same problem.

@debanjum
Copy link
Member

debanjum commented Jan 9, 2025

@baditaflorin that's a pretty intense setup. If I'm reading the config correctly, are you trying to run Khoj from the github.dev remote/cloud editor thing? I'm not familiar with the networking setup on github.dev to comment

  • Can you try with the latest docker-compose.yml in master to see if changes merged from Improve docker-compose.yml #1029 put all the Khoj docker services on the same network?

  • Setting KHOJ_DOMAIN=refactored-fiesta-4q4jx7p495cq65q-42110.app.github.dev should avoid having to set CSRF_COOKIE_DOMAIN and SESSION_COOKIE_DOMAIN manually via your entrypoint.sh and docker-compose.yml updates

  • KHOJ_ALLOWED_HOSTS=https://refactored-fiesta-4q4jx7p495cq65q-42110.app.github.dev isn't used anywhere and shouldn't need to be set

  • CSRF_COOKIE_SECURE and SESSION_COOKIE_SECURE are automatically set to False if KHOJ_NO_HTTPS=True like in your config. So adding these may not be required unless you need it to do COOKIE_SAMESITE = "None" over COOKIE_SAMESITE = "Lax" which is a security risky with HTTPS disabled

  • Why is CSRF_COOKIE_NAME=csrftoken required? Isn't that the default name for CSRF cookies *

Otherwise, with those changes were you able to use Khoj from that github.dev domain?

@debanjum debanjum added the question Further information is requested label Jan 9, 2025
@baditaflorin
Copy link
Author

baditaflorin commented Jan 9, 2025

I was using github codespaces because i had some port issues on my machine.
I was able to use this setup but there are multiple things i need to manually do to have it work with the local Ollama, but they are different from the specific problem that I consider closed now

Like settings the Ollama to the internal ip of ollama because the django admin backend does not allow me to use http://ollama:11434/v1

ID | Name | Api key | Api base url
-- | -- | -- | --
  | Ollama | placeholder | http://172.24.0.3:11434/v1/
image

and for the CSRF things, i added as much as possible even if overkill to be able to login into the backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fix something that isn't working as expected question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants