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

v1.5.22 #1840

Merged
merged 32 commits into from
Oct 10, 2024
Merged

v1.5.22 #1840

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7be98c0
Merge pull request #1827 from watchdogpolska/develop
PiotrIw Sep 19, 2024
dee3e55
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Oct 8, 2024
4e57f90
Fix .pre-commit-config.yaml update
PiotrIw Oct 8, 2024
2a68315
Update package-lock.json
PiotrIw Oct 8, 2024
c5a88b6
Merge pull request #1830 from watchdogpolska/pre-commit-ci-update-config
PiotrIw Oct 8, 2024
189b8de
chore(deps): update dependency openai to v1.51.1
renovate[bot] Oct 8, 2024
8ecf2ff
Merge pull request #1828 from watchdogpolska/renovate/openai-1.x
PiotrIw Oct 8, 2024
c138ff2
chore(deps): update non-production-dependencies
renovate[bot] Oct 8, 2024
2954f96
Merge pull request #1778 from watchdogpolska/renovate/major-non-produ…
PiotrIw Oct 8, 2024
03be4da
chore(deps): update dependency django-rosetta to v0.10.1
renovate[bot] Oct 8, 2024
6f30ef6
Merge pull request #1832 from watchdogpolska/renovate/django-rosetta-0.x
PiotrIw Oct 8, 2024
190c164
chore(deps): update dependency openai to v1.51.2
renovate[bot] Oct 8, 2024
24f23ae
Merge pull request #1833 from watchdogpolska/renovate/openai-1.x
PiotrIw Oct 8, 2024
f3c1869
chore(deps): update dependency vcrpy to v6.0.2
renovate[bot] Oct 8, 2024
569fccb
Merge pull request #1834 from watchdogpolska/renovate/non-production-…
PiotrIw Oct 8, 2024
60d80b5
chore(deps): update dependency sentry-sdk to v2.16.0
renovate[bot] Oct 8, 2024
3a5277b
Merge pull request #1835 from watchdogpolska/renovate/sentry-sdk-2.x
PiotrIw Oct 8, 2024
5ab9e44
chore(deps): update dependency pre-commit to v4.0.1
renovate[bot] Oct 8, 2024
09ab5d4
Merge pull request #1836 from watchdogpolska/renovate/non-production-…
PiotrIw Oct 8, 2024
ad9a59e
choe: add networks to dev containers
PiotrIw Oct 9, 2024
fd91305
chore: update frontend dependencies
PiotrIw Oct 9, 2024
2950b2f
chore: version bumpup
PiotrIw Oct 9, 2024
36c4ecc
chore: update frontend dependencies
PiotrIw Oct 9, 2024
adcbc46
chore: update langchain dependencies
PiotrIw Oct 9, 2024
41e157d
chore: update azure api version
PiotrIw Oct 9, 2024
ef2bc63
fix: refactor deprecated syntax
PiotrIw Oct 9, 2024
f60da8a
refactor: update for python >=3.9
PiotrIw Oct 10, 2024
8a62954
fix: align attachment visibility with letter visibility for user
PiotrIw Oct 10, 2024
03bb7de
fix: get recipients form gzipped eml as well
PiotrIw Oct 10, 2024
7bde0a1
feat: add field to monitoring form
PiotrIw Oct 10, 2024
0deefe0
Merge pull request #104 from PiotrIw/fix_attachment_scan
PiotrIw Oct 10, 2024
92e5a1f
Merge pull request #1839 from PiotrIw/develop
PiotrIw Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
default_stages: [commit, push]
default_stages: [pre-commit, pre-push]
default_language_version:
# force all unspecified python hooks to run python3
python: python3
Expand Down Expand Up @@ -28,7 +28,7 @@ repos:
- --skip-glob
- "**/migrations/*.py"
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.29.2
rev: 0.29.3
hooks:
- id: check-github-workflows
- id: check-readthedocs
Expand All @@ -39,7 +39,7 @@ repos:
args: [-c, .yamllint.yml]
# exclude: (feder/letters/logs/cassettes/.*|docker-compose.yml)
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
args:
Expand Down
17 changes: 16 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ services:
--max_allowed_packet=1024M
ports:
- "3306:3306"
networks:
- feder-app-network
environment:
MYSQL_ROOT_PASSWORD: "password"
MYSQL_DATABASE: feder # feder_copy
Expand All @@ -25,6 +27,8 @@ services:
dockerfile: .contrib/docker/Dockerfile.gulp
ports:
- "35729:35729"
networks:
- feder-app-network
volumes:
- .:/app

Expand Down Expand Up @@ -70,9 +74,11 @@ services:
OPENAI_API_ENGINE_35_MAX_TOKENS: 16000
OPENAI_API_ENGINE_4_MAX_TOKENS: 100000
OPENAI_API_TEMPERATURE: 0.0
OPENAI_API_VERSION: "2024-05-01-preview"
OPENAI_API_VERSION: "2024-09-01-preview"
ports:
- "8000:8000"
networks:
- feder-app-network
# Following allows to execute `docker attach feder_web_1`
# necessary when using ipdb in development:
stdin_open: true
Expand All @@ -98,6 +104,8 @@ services:
ports:
- "1080:1080"
- "1025:1025"
networks:
- feder-app-network

#
# To use email reception uncomment below section and fill in your dev IMAP
Expand All @@ -112,7 +120,14 @@ services:
# COMPRESS_EML: "True"
# env_file:
# - secrets_imap-to-webhook-url.env
# networks:
# - feder-app-network

volumes:
mysql-data:
maildump_data:

networks:
feder-app-network:
driver: bridge

2 changes: 1 addition & 1 deletion feder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PEP 396: The __version__ attribute's value SHOULD be a string.
__version__ = "1.5.21"
__version__ = "1.5.22"


# Compatibility to eg. django-rest-framework
Expand Down
6 changes: 3 additions & 3 deletions feder/assets/scss/_milestones.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $milestone-icon-width: $milestone-icon-padding * 2 + $milestone-icon-font-size +

// the <ul .milestones>
list-style-type: none;
padding-left: $milestone-icon-width/2;
padding-left: calc($milestone-icon-width / 2);

// the top and bottom borders
// of the list
Expand Down Expand Up @@ -68,11 +68,11 @@ $milestone-icon-width: $milestone-icon-padding * 2 + $milestone-icon-font-size +
// does the heavy lifting to the icons
& > .fa:first-child,
& > .glyphicon:first-child {
margin-left: -($milestone-offset-larger + ($milestone-icon-width - 2)/2 + 1);
margin-left: -($milestone-offset-larger + calc(($milestone-icon-width - 2px) / 2) + 1);
margin-top: -$milestone-offset-smaller;
float:left;
position: relative;
border-radius: $milestone-icon-width/2;
border-radius: calc($milestone-icon-width / 2);
padding: $milestone-icon-padding;
font-size: $milestone-icon-font-size;
min-width: $milestone-icon-width;
Expand Down
4 changes: 2 additions & 2 deletions feder/cases/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid
from datetime import timedelta
from email.headerregistry import Address
from functools import lru_cache
from functools import cache

from autoslug.fields import AutoSlugField
from django.apps import apps
Expand Down Expand Up @@ -41,7 +41,7 @@ def enforce_quarantined_queryset(queryset, user, path_case):
return queryset.filter(**{f"{path_case}__in": Case.objects.for_user(user).all()})


@lru_cache(maxsize=1) # TODO: use @functools.cache on python>=3.9
@cache
def get_quarantined_perm():
ctype = ContentType.objects.get_for_model(Monitoring)
return Permission.objects.get(content_type=ctype, codename="view_quarantined_case")
Expand Down
26 changes: 20 additions & 6 deletions feder/letters/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import email
import gzip
import json
import logging
import uuid
Expand Down Expand Up @@ -107,9 +108,10 @@ def for_user(self, user):
return self.filter(
record__case__is_quarantined=False,
record__case__monitoring__is_public=True,
)
if user.is_superuser or user.is_authenticated:
).exclude_spam()
if user.is_superuser:
return self
return self.exclude_spam()


class LetterManager(BaseManager.from_queryset(LetterQuerySet)):
Expand Down Expand Up @@ -455,10 +457,20 @@ def get_recipients(self):
Letter eml file.
"""
if not self.eml:
if self.email_to:
return [self.email_to]
return []

with self.eml.open(mode="rb") as f:
msg = email.message_from_binary_file(f)
# Check if the file is a gzip file by reading its magic number
magic_number = f.read(2)
f.seek(0) # Reset file pointer to the beginning

if magic_number == b"\x1f\x8b":
with gzip.open(f, mode="rb") as gz:
msg = email.message_from_binary_file(gz)
else:
msg = email.message_from_binary_file(f)

to_addrs = msg.get_all("To", [])
cc_addrs = msg.get_all("Cc", [])
Expand Down Expand Up @@ -743,9 +755,11 @@ def _enforce_quarantine(self, user):

def for_user(self, user):
if not user.is_superuser:
return self.filter(
letter__is_spam__in=[Letter.SPAM.unknown, Letter.SPAM.non_spam]
)._enforce_quarantine(user)
# Align attachment visibility with letter visibility
# return self.exclude(letter__is_spam=Letter.SPAM.spam)._enforce_quarantine(
# user
# )
return self.filter(letter__in=Letter.objects.for_user(user))
return self

def with_scan_result(self):
Expand Down
21 changes: 18 additions & 3 deletions feder/llm_evaluation/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@
"example": False,
"tool_calls": [],
"invalid_tool_calls": [],
"usage_metadata": {
"input_tokens": 350,
"output_tokens": 240,
"total_tokens": 590,
"input_token_details": {
"audio": 10,
"cache_creation": 200,
"cache_read": 100,
},
"output_token_details": {
"audio": 10,
"reasoning": 200,
},
},
}


Expand All @@ -76,14 +90,15 @@ def test_azure_chat_openai_response_schema_format(self):
deployment_name=settings.OPENAI_API_ENGINE_35,
temperature=settings.OPENAI_API_TEMPERATURE,
)

response_format = model.output_schema.schema()["definitions"]["AIMessage"][
# To debug schema format:
# schema = model.get_output_jsonschema()
response_format = model.get_output_jsonschema()["$defs"]["AIMessage"][
"properties"
]
model_schema_keys = set(response_format.keys())
# TODO: check why schem differs in dev and github test environments
# TEMP fix for the github tests to pass:
expected_schema_keys = set(EXPECTED_RESPONSE_DICT.keys()) | {"usage_metadata"}
expected_schema_keys = set(EXPECTED_RESPONSE_DICT.keys())
print("\n", 20 * "-", " settings.DEBUG:\n", settings.DEBUG)
print("\n", 20 * "-", " model:\n", model)
print("\n", 20 * "-", "response_format:\n", response_format)
Expand Down
2 changes: 2 additions & 0 deletions feder/monitorings/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(self, *args, **kwargs):
"name",
"description",
"notify_alert",
"is_public",
"hide_new_cases",
"use_llm",
),
Expand All @@ -82,6 +83,7 @@ class Meta:
"description",
"notify_alert",
"hide_new_cases",
"is_public",
"use_llm",
"subject",
"template",
Expand Down
Loading
Loading