Skip to content

Commit 3a84a36

Browse files
authored
Merge pull request #2 from FOSWLY/2.0.0
v2.0.0
2 parents dceef5a + 5526b6a commit 3a84a36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1285
-1100
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.vscode
2+
.git
3+
.gitignore
4+
.husky
5+
*.env
6+
7+
logs/*
8+
tests/*
9+
10+
Dockerfile
11+
docker-compose.yml
12+
13+
ecosystem.config.json

.example.env

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
API_KEY="" # https://300.ya.ru/ -> API -> Получить токен -> Войти как ...
2-
YANDEX_COOKIE="Session_id=XXXX;" # !!! Required Session_id COOKIE! You can log in to your account and then from any request to yandex catch them. AT YOUR OWN RISK !!!
1+
SERVICE_PORT=3312
2+
USE_WORKER="false"
3+
API_TOKEN="" # For get sharing url
4+
# SESSION_ID_COOKIE="XXXX" # If lib YaHMAC is invalid you can set your cookies and summarize articles/text (video requires valid YaHMAC)

.gitignore

Lines changed: 14 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,14 @@
1-
# Editor
2-
.vscode
3-
4-
# Byte-compiled / optimized / DLL files
5-
__pycache__/
6-
*.py[cod]
7-
*$py.class
8-
9-
# C extensions
10-
*.so
11-
12-
# Distribution / packaging
13-
.Python
14-
build/
15-
develop-eggs/
16-
dist/
17-
downloads/
18-
eggs/
19-
.eggs/
20-
lib/
21-
lib64/
22-
logs/
23-
backups/
24-
parts/
25-
sdist/
26-
var/
27-
wheels/
28-
pip-wheel-metadata/
29-
share/python-wheels/
30-
*.egg-info/
31-
.installed.cfg
32-
*.egg
33-
MANIFEST
34-
35-
# PyInstaller
36-
# Usually these files are written by a python script from a template
37-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
38-
*.manifest
39-
*.spec
40-
41-
# Installer logs
42-
pip-log.txt
43-
pip-delete-this-directory.txt
44-
45-
# Unit test / coverage reports
46-
htmlcov/
47-
.tox/
48-
.nox/
49-
.coverage
50-
.coverage.*
51-
.cache
52-
nosetests.xml
53-
coverage.xml
54-
*.cover
55-
*.py,cover
56-
.hypothesis/
57-
.pytest_cache/
58-
59-
# Translations
60-
*.mo
61-
*.pot
62-
63-
# Django stuff:
64-
*.log
65-
local_settings.py
66-
db.sqlite3
67-
db.sqlite3-journal
68-
69-
# Flask stuff:
70-
instance/
71-
.webassets-cache
72-
73-
# Scrapy stuff:
74-
.scrapy
75-
76-
# Sphinx documentation
77-
docs/_build/
78-
79-
# PyBuilder
80-
target/
81-
82-
# Jupyter Notebook
83-
.ipynb_checkpoints
84-
85-
# IPython
86-
profile_default/
87-
ipython_config.py
88-
89-
# pyenv
90-
.python-version
91-
92-
# pipenv
93-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
95-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
96-
# install all needed dependencies.
97-
#Pipfile.lock
98-
99-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
100-
__pypackages__/
101-
102-
# Celery stuff
103-
celerybeat-schedule
104-
celerybeat.pid
105-
106-
# SageMath parsed files
107-
*.sage.py
108-
109-
# Environments
110-
.env
111-
.venv
112-
env/
113-
venv/
114-
ENV/
115-
env.bak/
116-
venv.bak/
117-
118-
# Spyder project settings
119-
.spyderproject
120-
.spyproject
121-
122-
# Rope project settings
123-
.ropeproject
124-
125-
# mkdocs documentation
126-
/site
127-
128-
# mypy
129-
.mypy_cache/
130-
.dmypy.json
131-
dmypy.json
132-
133-
# Pyre type checker
134-
.pyre/
1+
.vscode
2+
.env
3+
4+
# dependencies
5+
/node_modules
6+
7+
# local env files
8+
.env.local
9+
.env.development.local
10+
.env.test.local
11+
.env.production.local
12+
13+
**/*.log
14+
**/*.bun

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
bunx pretty-quick --staged

.oxlintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/*.d.ts
2+
ecosystem.config.js
3+
eslint.config.js

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"semi": true,
5+
"trailingComma": "all"
6+
}

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM oven/bun:latest AS base
2+
WORKDIR /usr/src/app
3+
4+
FROM base AS release
5+
COPY package.json bun.lock tsconfig.json ./
6+
COPY src src
7+
RUN bun install
8+
9+
ENV SERVICE_PORT=3312
10+
# ENV USE_WORKER="true"
11+
# ENV WORKER_HOST="http://127.0.0.1:7674/browser"
12+
# ENV WORKER_HOST_TH="http://127.0.0.1:7674/th"
13+
# ENV API_TOKEN=""
14+
15+
ENTRYPOINT [ "bun", "run", "start" ]

LICENSE

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
2-
3-
Copyright (c) 2023 FOSWLY
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
MIT License
2+
3+
Copyright (c) 2023 FOSWLY
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 66 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,76 @@
1-
## [FOSWLY] Summarize Backend
1+
## Summarize Backend
22

3-
[![Python Version](https://img.shields.io/badge/Python-3.11-blue?logo=python&style=for-the-badge)](https://www.python.org/)
43
[![GitHub Stars](https://img.shields.io/github/stars/FOSWLY/summarize-backend?logo=github&style=for-the-badge)](https://github.com/FOSWLY/summarize-backend/stargazers)
54
[![GitHub Issues](https://img.shields.io/github/issues/FOSWLY/summarize-backend?style=for-the-badge)](https://github.com/FOSWLY/summarize-backend/issues)
65
[![Current Version](https://img.shields.io/github/v/release/FOSWLY/summarize-backend?style=for-the-badge)](https://github.com/FOSWLY/summarize-backend)
76
[![GitHub License](https://img.shields.io/github/license/FOSWLY/summarize-backend?style=for-the-badge)](https://github.com/FOSWLY/summarize-backend/blob/master/LICENSE)
87

9-
**[FOSWLY] Summarize Backend** - cервер, который реализует Yandex Summarize API для нашего браузерного расширения. Сервер не содержит никакой авторизации и может быть использован для ваших проектов.
8+
**Summarize Backend** - cервер, унифицированные конечные точки для API суммаризации из библиотеки [@toil/neurojs](https://github.com/FOSWLY/neurojs).
109

1110
## 📝 Функционал
12-
- Суммаризатор статей
13-
- Суммаризатор видео
11+
12+
- Суммаризация статей
13+
- Суммаризация текста
14+
- Суммаризация видео
15+
- Получение ссылки на суммаризацию статей (необходимо указать токен к оф. апи)
16+
- Получение суммаризации по токену (`https://300.ya.ru/TOKEN`)
1417

1518
## 📦 Деплой
16-
1. Установите Python 3.11 (на других версиях не тестировался)
17-
2. Клонируйте репозиторий
18-
3. Установите зависимости: `pip install -r requirements.txt`
19-
4. Заполните конфиг: `app/settings.py`
20-
5. Переименуйте `.example.env` --> `.env`
21-
6. Заполните: `.env`
22-
7. Запустите сервер: `python3 -OO main.py`
23-
24-
## ⚙️ Заполнение .env
25-
1. Переименуйте `.example.env` в `.env`
26-
2. Получение `API_KEY`:
27-
1. Перейдите на сайт [300.ya.ru](https://300.ya.ru/)
28-
2. Внизу нажмите на "API"
29-
3. В появившейся панельке нажмите "Получить токен"
30-
4. Авторизуйтесь, если вы не авторизованы
31-
5. Вставьте полученный токен в `.env`
32-
3. Получение `YANDEX_COOKIE`:
33-
1. Перейдите на сайт [300.ya.ru](https://300.ya.ru/)
34-
2. Авторизуйтесь, если вы не авторизованы. Лучше всего использовать не основной аккаунт, поскольку **все действия выполняются на ваш страх и риск**.
35-
3. Откройте DevTools (F12 или Ctrl+Shift+I)
36-
4. Перейдите в Application
37-
38-
P.S. В некоторых браузерах этого пункта нету. В них вы должны сразу перейти в Storage.
39-
5. Выберите Storage
40-
6. Выберите Cookies
41-
7. Найдите куки с именем `Session_id` и скопируйте ее значение
42-
8. Вставьте скопированное значение заместо XXXX в `.env`
43-
44-
## 📖 Зачем нужен свой сервер, почему бы не использовать API напрямую?
45-
В использование API напрямую есть несколько проблемы из-за которых мы от этого отказались:
46-
1. Для работы с Yandex Summarize API нужна авторизация, т.е. необходимо посылать запросы с токеном/куки, которые не хотелось бы лишний раз "палить" на клиенте.
47-
2. У некоторых пользователей могут быть заблокированы сервера Yandex и прямой запрос бы просто не прошёл.
19+
20+
### С Docker
21+
22+
1. Установите Docker
23+
2. Соберите образ
24+
25+
```bash
26+
docker build -t "summarize-backend" .
27+
```
28+
29+
3. Запустите контейнер
30+
31+
```bash
32+
docker run -p 3312:3312 summarize-backend
33+
```
34+
35+
### Вручную
36+
37+
1. Установите [Bun](https://bun.sh/)
38+
2. Клонируйте репозиторий:
39+
40+
```bash
41+
git clone https://github.com/FOSWLY/summarize-backend
42+
```
43+
44+
3. Установите зависимости
45+
46+
```bash
47+
bun install
48+
```
49+
50+
3.1. (опционально) Переименуйте `.example.env` в `.env` и заполните необходимые поля
51+
52+
4. Запустите сервер
53+
54+
```bash
55+
bun start
56+
```
57+
58+
Если вы хотите использовать PM2:
59+
60+
1. Установите зависимости:
61+
62+
```bash
63+
bun install -g pm2-beta && pm2 install pm2-logrotate
64+
```
65+
66+
2. Запустите сервер
67+
68+
```bash
69+
pm2 start ecosystem.config.json
70+
```
71+
72+
## 📖 Кому это будет полезно
73+
74+
1. Если вы хотите использовать логику из [neurojs](https://github.com/FOSWLY/neurojs) с помощью другого языка программирования, но не хотите переносить весь функционал в ваш код
75+
2. Если вы не хотите тянуть зависимости от neurojs
76+
3. Если вы хотите иметь простой унифицированный апи

0 commit comments

Comments
 (0)