#server #authentication #poc #ragit #self-hosting #front-end #own

app ragit-server

poc server implementation of ragit

7 releases

new 0.3.3 Mar 9, 2025
0.3.2 Mar 1, 2025
0.3.1 Feb 26, 2025
0.2.1 Feb 1, 2025
0.1.1 Nov 13, 2024

#90 in HTTP server

Download history 111/week @ 2024-11-13 8/week @ 2024-11-20 2/week @ 2024-12-04 5/week @ 2024-12-11 102/week @ 2024-12-25 23/week @ 2025-01-01 8/week @ 2025-01-08 121/week @ 2025-01-29 12/week @ 2025-02-05 12/week @ 2025-02-12 102/week @ 2025-02-19 340/week @ 2025-02-26

471 downloads per month

MIT license

51KB
1K SLoC

ragit-server

A bare-minimum server for self-hosting. You can push/clone knowledge-bases.

There's no frontend. You have to write one on your own.

This is not production-ready

You can self-host ragit-server and it must be quite useful. But it's not production-ready!

  • Auth
    • It does not implement any kind of Auth. There is fn auth() -> bool;, but its body is empty.
  • Scalability
    • It does not use any kind of DB. It stores everything on disk. This design makes self-hosting simpler, but not suitable for large-scale services.

Logs

By default, it writes logs to ./ragit-server-logs. I wrote a simple python script that converts the text file to a sqlite db.

Endpoints

It always uses utf-8 for text/plain.

  • GET /{user-name}/{repo-name}/index
    • application/json: index.json
  • GET /{user-name}/{repo-name}/config/{config-name}
    • application/json: {config-name}.json
  • GET /{user-name}/{repo-name}/prompt/{prompt-name}
    • text/plain: {prompt-name}.pdl
  • GET /{user-name}/{repo-name}/chunk-count
    • application/json: an integer
  • GET /{user-name}/{repo-name}/chunk-list/{uid-prefix}
    • application/json: array[string]
    • It returns chunk uids that start with {uid-prefix}.
    • {uid-prefix} must be exactly 2 characters.
  • GET /{user-name}/{repo-name}/chunk-list
    • application/json: array[string]
    • It returns all the chunk uids.
  • GET /{user-name}/{repo-name}/chunk/{chunk-uid}
    • application/json: a chunk
    • chunk::load_from_file() can also deserialize this data.
  • GET /{user-name}/{repo-name}/archive-list
    • application/json: array[string]
  • GET /{user-name}/{repo-name}/archive/{archive-key}
    • application/octet-stream: a file generated by rag archive-create
  • GET /{user-name}/{repo-name}/image-list/{uid-prefix}
    • application/json: array[string]
    • It returns image uids that start with {uid-prefix}.
    • {uid-prefix} must be exactly 2 characters.
  • GET /{user-name}/{repo-name}/image/{image-uid}
    • image/png
  • GET /{user-name}/{repo-name}/image-desc/{image-uid}
    • application/json: { extracted_text: string, explanation: string }
  • GET /{user-name}/{repo-name}/cat-file/{uid}
    • text/plain
    • This is similar to running rag cat-file command on a local knowledge-base.
    • It only works for chunks and images, you can't use API to cat-file an image.
  • GET /{user-name}/{repo-name}/meta
    • application/json: meta.json
  • GET /{user-name}/{repo-name}/version
    • text/plain
    • "{major}.{minor}.{patch}"
    • "{major}.{minor}.{patch}-dev"
  • GET /{user-name}/{repo-name}/chat-list
    • application/json: array[chat]
    • query string
      • ?history=0 if you don't want chat history. ?history=1 if you want chat history (default).
  • GET /{user-name}/{repo-name}/chat/{chat-id}
    • application/json: chat
  • GET /version
    • text/plain
    • "{major}.{minor}.{patch}"
    • "{major}.{minor}.{patch}-dev"
  • GET /user-list
    • application/json: array[string]
  • GET /repo-list/{user-name}
    • application/json: array[string]
  • POST /{user-name}/{repo-name}/begin-push
    • text/plain: a session id
  • POST /{user-name}/{repo-name}/archive
    • request body (multiform): { "session-id": str, "archive-id": str, "archive": bytes }
  • POST /{user-name}/{repo-name}/finalize-push
    • request body (plain text): session-id
  • POST /{user-name}/{repo-name}/chat-list
    • text/plain: a new chat id
    • It creates a new chat and returns its id.
  • POST /{user-name}/{repo-name}/chat/{chat-id}
    • application/json: QueryResponse
    • request body (multiform): { "query": str, "model": optional[str] }

TODO: api for remote ii-build

Dependencies

~34–51MB
~815K SLoC