{"id":23544264,"url":"https://github.com/iodine98/dora-back","last_synced_at":"2026-04-11T06:03:11.064Z","repository":{"id":231505986,"uuid":"734373426","full_name":"Iodine98/dora-back","owner":"Iodine98","description":"A Python backend for Document Retrieval and Analysis (DoRA).","archived":false,"fork":false,"pushed_at":"2024-09-23T12:49:06.000Z","size":231,"stargazers_count":0,"open_issues_count":17,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-15T08:45:10.203Z","etag":null,"topics":["docker","docker-compose","langchain","rag","retrieval-augmented-generation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Iodine98.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-21T14:18:12.000Z","updated_at":"2024-07-18T12:11:18.000Z","dependencies_parsed_at":"2024-04-24T12:40:42.508Z","dependency_job_id":"3f2db4b8-d467-4056-ad34-f521567d0686","html_url":"https://github.com/Iodine98/dora-back","commit_stats":null,"previous_names":["iodine98/dora-back"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Iodine98/dora-back","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iodine98%2Fdora-back","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iodine98%2Fdora-back/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iodine98%2Fdora-back/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iodine98%2Fdora-back/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Iodine98","download_url":"https://codeload.github.com/Iodine98/dora-back/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Iodine98%2Fdora-back/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31670383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","langchain","rag","retrieval-augmented-generation"],"created_at":"2024-12-26T07:14:45.071Z","updated_at":"2026-04-11T06:03:11.022Z","avatar_url":"https://github.com/Iodine98.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dora-back\nThe backend for Document Retrieval and Analysis (DoRA)\n\n## Run using Poetry and Python\n\n### How to install the dependencies\nEither clone this project in VSCode or open a new codespace (if you have not been invited into another one).\n\nThe `devcontainer.json` should contain all the plugins needed to get going including the installation of Poetry (which may need to be done manually).\n\nAdditionally, set the `FILE_PATH` environment variable to where you store the PDF file and include your OpenAI API key in the `OPENAI_API_KEY` environment variable.\n\nSubsequently, run `poetry update` in the terminal to install all the dependencies and create the environment. \n\n### Allow GPU-inference for local models\n\nSet the `CMAKE_ARGS` environment variable according to the [llama-cpp-python documentation](https://pypi.org/project/llama-cpp-python)\n\n### Run the Flask server for the endpoints\n\nMake sure to set all the environment variables like:\n\n- `CHAT_MODEL_VENDOR_NAME`: the name of the chat model vendor [openai, local, huggingface]\n- `CHAT_MODEL_NAME`: the name of the chat model (e.g. gpt-turbo-3.5)\n- `EMBEDDING_MODEL_VENDOR_NAME`: the name of the embeddings model vendor [openai, local, huggingface]\n- `EMBEDDING_MODEL_NAME`: the name of the embeddings model (e.g. text-embedding-ada-002)\n- `CURRENT_ENV`: the current environment [DEV, TST, PROD]. In `DEV` a CORS wrapper is applied to the Flask-server, but not in `TST` or `PROD`. In `PROD`, the server will connect to a defined remote endpoint for the Chroma Vector DB, but in `DEV` and `TST`, it will make use of a persistent client in Python.\n- `CHAT_MODEL_FOLDER_PATH`: the path to the folder of local chat models\n- `EMBEDDING_MODEL_FOLDER_PATH`: the path to the folder of local embedding models\n- `OPENAI_API_KEY`: an OpenAI API key to use an OpenAI model specified in `CHAT_MODEL_NAME`\n- `CURRENT_ENV`: the current environment for the Flask server; defaults to `DEV`\n- `CHUNK_SIZE`: the chunk size in which to partition the chunks from the text extracted from documents; defaults to `512` tokens.\n- `TOP_K_DOCUMENTS`: retrieve the top-k documents; defaults to the top-`5` documents.\n- `MINIMUM_ACCURACY`: the minimum accuracy for the retrieved documents (i.e. chunks of text); defaults to `0.80`\n- `FETCH_K_DOCUMENTS`: fetch `k`-number of documents (only applies if `STRATEGY=mmr`); defaults to `100`\n- `LAMBDA_MULT`: Lambda-multiplier, the lower this number (between 0 and 1) the more diverse the documents ought to be, the higher the less diverse the document selection is; defaults to `0.2`\n- `STRATEGY`: the document ranking strategy to use; for example `similarity`, `similarity_score_threshold` or `mmr` (default)\n- `LAST_N_MESSAGES`: the last n messages to include from the chat history; defaults to `5`.\n- `CHAT_MODEL_FOLDER_PATH`: the folder path to store LOCAL chat models in.\n- `SENTENCE_TRANSFORMERS_HOME`: the folder path to store LOCAL embedding models in.\n- `CHAT_HISTORY_CONNECTION_STRING`: an SQL-connection string pointing towards a SQL-DB where chat history can be stored in. The schema will automatically be created in the database mentioned in the SQL-connection string.\n- `LOGGING_FILE_PATH`: a file path where the logging files will be stored.\n- `MARIADB_USER`: the user name to access the MariaDB instance with for CRUD operations\n- `MARIADB_ROOT_PASSWORD`: the root password for the MariaDB instance\n- `MARIADB_PASSWORD`: the password belonging to `MARIADB_USER`\n- `MARIADB_INSTANCE_URL`: the URI for SQLAlchemy pointing to the MariaDB instance; it is of this format:\n```uri\nmariadb+mariadbconnector://${MARIADB_USER}:${MARIADB_PASSWORD}@dora-mariadb\n```\nThen run `poetry run flask --app server run`\n\n## Run Flask server using Docker container\n\nPlease configure the values in the Dockerfile before proceeding.\n\nBuild the Docker container using \n```bash\ndocker build -t dora-backend --build-arg OPENAI_API_KEY=\u003copenai_api_key\u003e .\n```\nThe `--build-arg` are needed to provide options for local models or API keys. **Please have a look at the Dockerfile** to familiarize yourself with any defaults.\n\nRun the Docker container using:\n```bash\ndocker run --name \u003ccontainer_name\u003e -p 5000:8000 dora-back \\\n-e \u003cenvironment_variable\u003e=\u003cvalue\u003e \\\n-e \u003cenvironment_variable\u003e=\u003cvalue\u003e\n```\nYou can access the server at localhost:5000.\nOverriding the default values for the environment variables is optional.\n\n## Removing CORS and connecting to remote Vector DB\nTo be able to remove the CORS wrapper and connect to a remote vector database, set the `CURRENT_ENV` variable to `PROD`.\n\n## Query the MariaDB \n1. Log in to the MariaDB instance:\n```bash\ndocker exec -it ${CONTAINER_NAME} mariadb -u ${MARIADB_USER} -D final_answer -p \\\n${MARIADB_PASSWORD}\n```\n2. Run the following SQL-statement for the top-5 final answers:\n```sql\nSELECT TOP(5) FROM final_answer;\n```\n\n3. To switch to the `chat_history` database:\n```bash\n\\u chat_history\n```\n\n4. To view the top-5 chat-history items:\n```sql\nSELECT TOP(5) FROM chat_history;\n```\n\n### `init.sql`\nThe purpose of this file is to set grant privileges to the user `main`. I have not figured out how to parameterize this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiodine98%2Fdora-back","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiodine98%2Fdora-back","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiodine98%2Fdora-back/lists"}