Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiendil committed Jan 1, 2025
1 parent d3ee768 commit 5756c1c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ffun/ffun/librarian/processors/llm_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from ffun.librarian.entities import TagsExtractor, TextCleaner
from ffun.librarian.processors import base
from ffun.library.entities import Entry
from ffun.llms_framework.domain import call_llm, search_for_api_key
from ffun.llms_framework import errors as llmsf_errors
from ffun.llms_framework.domain import call_llm, search_for_api_key
from ffun.llms_framework.entities import (
ChatResponse,
LLMCollectionApiKey,
Expand Down
5 changes: 2 additions & 3 deletions ffun/ffun/librarian/processors/tests/test_llm_general.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

from pytest_mock import MockerFixture
from ffun.librarian import errors
from ffun.librarian.processors.llm_general import Processor
from ffun.librarian.tag_extractors import dog_tags_extractor
Expand Down Expand Up @@ -76,10 +75,10 @@ async def test_process__has_api_key_found(

@pytest.mark.asyncio
async def test_process__temporary_error_processing(
self, llm_processor: Processor, cataloged_entry: Entry, fake_llm_api_key: LLMApiKey
self, llm_processor: Processor, cataloged_entry: Entry, fake_llm_api_key: LLMApiKey
) -> None:

entry = cataloged_entry.replace(title="@tag-1 @tag-2", body='raise TemporaryError')
entry = cataloged_entry.replace(title="@tag-1 @tag-2", body="raise TemporaryError")

llm_processor.general_api_key = LLMGeneralApiKey(fake_llm_api_key)

Expand Down
31 changes: 27 additions & 4 deletions ffun/ffun/librarian/tests/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
push_entries_and_move_pointer,
)
from ffun.librarian.entities import ProcessorPointer
from ffun.librarian.processors.base import AlwaysConstantProcessor, AlwaysErrorProcessor, AlwaysSkipEntryProcessor, AlwaysTemporaryErrorProcessor
from ffun.librarian.processors.base import (
AlwaysConstantProcessor,
AlwaysErrorProcessor,
AlwaysSkipEntryProcessor,
AlwaysTemporaryErrorProcessor,
)
from ffun.librarian.tests import helpers, make
from ffun.library.entities import Entry
from ffun.library.tests import make as l_make
Expand Down Expand Up @@ -230,7 +235,13 @@ async def test_skip_processing(
entry=cataloged_entry,
)

assert_logs(logs, processor_successed=0, processor_requested_to_skip_entry=1, entry_processed=1, processor_temporary_error=0)
assert_logs(
logs,
processor_successed=0,
processor_requested_to_skip_entry=1,
entry_processed=1,
processor_temporary_error=0,
)

tags = await o_domain.get_tags_ids_for_entries([cataloged_entry.id])

Expand Down Expand Up @@ -260,7 +271,13 @@ async def test_temporary_error_in_processor(
entry=cataloged_entry,
)

assert_logs(logs, processor_successed=0, processor_requested_to_skip_entry=0, entry_processed=1, processor_temporary_error=1)
assert_logs(
logs,
processor_successed=0,
processor_requested_to_skip_entry=0,
entry_processed=1,
processor_temporary_error=1,
)

tags = await o_domain.get_tags_ids_for_entries([cataloged_entry.id])

Expand Down Expand Up @@ -291,7 +308,13 @@ async def test_unexpected_error(
entry=cataloged_entry,
)

assert_logs(logs, processor_successed=0, processor_requested_to_skip_entry=0, entry_processed=0, processor_temporary_error=0)
assert_logs(
logs,
processor_successed=0,
processor_requested_to_skip_entry=0,
entry_processed=0,
processor_temporary_error=0,
)

tags = await o_domain.get_tags_ids_for_entries([cataloged_entry.id])

Expand Down
4 changes: 2 additions & 2 deletions ffun/ffun/llms_framework/provider_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def estimate_tokens(self, config: LLMConfiguration, text: str) -> int:
async def chat_request( # type: ignore
self, config: LLMConfiguration, api_key: str, request: ChatRequestTest
) -> ChatResponseTest:
if 'raise TemporaryError' in request.text:
raise errors.TemporaryError(message='error raise by a test request')
if "raise TemporaryError" in request.text:
raise errors.TemporaryError(message="error raise by a test request")

return ChatResponseTest(content=request.text)

Expand Down

0 comments on commit 5756c1c

Please sign in to comment.