Did you know that GitHub supports table of contents by default 🤔
This API powers the search functionality within the InNoHassle ecosystem — a unified digital platform designed to simplify daily life for students of Innopolis University.
The search service acts as a smart assistant, helping users quickly find information across various Innopolis University services.
search- search by keywords. Provides answers in the form of cards linking to resource websites with the ability to preview.ask- search by queries in free form. Provides answers generated by LLM with links to resource data.act- dialogue with action-based assistant. Provides the ability to perform actions in other Innopolis services on behalf of the user.
- Campus life - general knowledge about the university for quick adaptation
- Eduwiki - reference book on the educational process
- Hotel - information about dormitories
- Residents - list of resident companies in Innopolis
- InNoHassle - an ecosystem that collects the functionality of Innopolis services in one place or links to them
- My University - a system for performing administrative requests
- Python 3.11 & uv
- FastAPI
- Database and ORM: MongoDB & Beanie
- Formatting and linting: Ruff, pre-commit
- Deployment: Docker, Docker Compose, GitHub Actions
- Set up project settings file (check settings.schema.yaml for more info).
Put your
cp settings.example.yaml settings.yaml
openrouter_api_keyinsettings.yaml. - Start all services:
uv run -m src.ml_service docker compose up
Now you can find API docs on http://localhost:8004/docs.
- Install uv and Docker
- Install dependencies:
uv sync
- Check that your
settings.yamllooks like:$schema: "./settings.schema.yaml" api_settings: db_url: "mongodb://mongoadmin:secret@localhost:27017/localhost?authSource=admin" minio: access_key: "minioadmin" secret_key: "password" ml_service: # infinity_url: http://127.0.0.1:7997 api_key: "secret_token" mongo_url: "mongodb://mongoadmin:secret@db:27017/localhost?authSource=admin" openrouter_api_key: "your openrouter api key" timeout: 180.0
- Set up a MongoDB and Minio instances.
- Run the database instance:
docker compose up -d db minio
- Make sure to set up the actual database connection in
settings.yaml.
- Run the database instance:
- Choose the way to run models: either use Infinity or local models.
- If you want to use local models, just not set
infinity_urlinsettings.yaml - If you want to use Infinity, set
infinity_urlinsettings.yamlto the url of deployed Infinity engine. You can run Infinity engine locally:Or use deployed Infinity engine provided by someone else.uv run --no-project --with "infinity_emb[all]" --with "transformers<4.49" infinity_emb v2 --model-id intfloat/multilingual-e5-large-instruct --model-id BAAI/bge-reranker-v2-m3
- If you want to use local models, just not set
- Run ml client
uv run -m src.ml_service
- Run the ASGI server
Check API docs on http://127.0.0.1:8001/docs.
uv run -m src.api
Set up PyCharm integrations
- Run configurations (docs).
Right-click the
__main__.pyfile in the project explorer, selectRun '__main__'from the context menu. - Ruff (plugin).
It will lint and format your code. Make sure to enable
Use ruff formatoption in plugin settings. - Pydantic (plugin). It will fix PyCharm issues with type-hinting.
- Conventional commits (plugin). It will help you to write conventional commits.
We use our own IAM service for
authentication - InNoHassle Accounts.
To authenticate the user, you need to pass the Authorization header with the Bearer: <jwt_token>.
How to get token:
- First of all, go to innohassle.ru and log in if you are not logged in (or register). That will add cookie with account secret needed for the next step.
- Go to Accounts API and execute the
the method
GET /tokens/generate-my-token, copy the token from the response. - Go to the Swagger of API you want to authenticate and click on the
Authorizebutton in the top right corner, paste the token in theValuefield and clickAuthorize. Now you can use protected endpoints from the Swagger.
For testing we use pytest.
- To run tests enter in your terminal:
uv run pytest tests - To generate test coverage report run:
You can change coverage ignored folders/files in
uv run pytest --cov-config=.coveragerc --cov=src/ tests/.coveragerc. - To run evaluation script:
uv run --script scripts/search_result_metrics.py
We use Docker with Docker Compose plugin to run the service on servers.
- Change environment variables in the
.envfile - Copy the file with settings:
cp settings.example.yaml settings.yaml - Change settings in the
settings.yamlfile according to your needs (check settings.schema.yaml for more info) - Install Docker with Docker Compose
- Run the containers:
docker compose up --build --wait - Check the logs:
docker compose logs -f
Check https://github.com/one-zero-eight/fastapi-template for updates once in a while.
- Run
uv sync --upgradeto update uv.lock file and install the latest versions of the dependencies. - Run
uv tree --outdated --depth=1will show what package versions are installed and what are the latest versions. - Run
uv run pre-commit autoupdate
Also, Dependabot will help you to keep your dependencies up-to-date, see dependabot.yaml.
- Dump:
docker compose exec db sh -c 'mongodump "mongodb://$MONGO_INITDB_ROOT_USERNAME:[email protected]:27017/db?authSource=admin" --db=db --out=dump/'
- Restore:
docker compose exec db sh -c 'mongorestore "mongodb://$MONGO_INITDB_ROOT_USERNAME:[email protected]:27017/db?authSource=admin" --drop /dump/db'
We are open to contributions of any kind. You can help us with code, bugs, design, documentation, media, new ideas, etc. If you are interested in contributing, please read our contribution guide.