Skip to content

Commit

Permalink
♻️ move services into service folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhomer committed Oct 1, 2024
1 parent 822a494 commit 7b334a2
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 23 deletions.
19 changes: 9 additions & 10 deletions ask/ask.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import signal
import threading
import sys
import threading
from typing import Optional


from .config import default_parse_args, load_config
from .handler import InputHandler
from .input import (
AbstractInputter,
InputInterrupt,
PromptInputter,
)
from .prompt import get_prompt
from .renderer import AbstractRenderer, RichRenderer
from .services.anthropic import AnthropicService
from .services.bot_service import BotService
from .services.gemini import Gemini
from .services.ollama import Ollama
from .transcribe import register_transcribed_text, stop_transcribe
from .config import load_config, default_parse_args
from .gemini import Gemini
from .anthropic import AnthropicService
from .ollama import Ollama
from .renderer import RichRenderer, AbstractRenderer
from .bot_service import BotService
from .handler import InputHandler

transcribe_thread: Optional[threading.Thread] = None

Expand All @@ -41,7 +40,7 @@ def run(
Service: Optional[type[BotService]] = None,
Renderer: type[AbstractRenderer] = RichRenderer,
parse_args=default_parse_args,
config_file_name="~/.config/ask/ask.ini"
config_file_name="~/.config/ask/ask.ini",
) -> AbstractRenderer:
global transcribe_thread

Expand Down
2 changes: 1 addition & 1 deletion ask/anthropic.py → ask/services/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from anthropic.types import TextBlock
from .bot_service import BotService
from .renderer import AbstractRenderer
from ..renderer import AbstractRenderer

ANTHROPIC_API_KEY_NAME = "ANTHROPIC_API_KEY"

Expand Down
2 changes: 1 addition & 1 deletion ask/bot_service.py → ask/services/bot_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import abstractmethod
from typing import Optional

from .renderer import AbstractRenderer
from ..renderer import AbstractRenderer


class BotService:
Expand Down
2 changes: 1 addition & 1 deletion ask/gemini.py → ask/services/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from google.generativeai.types import content_types
from typing import Optional

from .renderer import AbstractRenderer
from ..renderer import AbstractRenderer
from .bot_service import BotService


Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions ask/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from ..gemini import API_KEY_NAME
from ..anthropic import ANTHROPIC_API_KEY_NAME
from ..services.gemini import API_KEY_NAME
from ..services.anthropic import ANTHROPIC_API_KEY_NAME

# Safety check to ensure that API_KEY is not passed into unit tests since this
# could have unintended side effect from environment leaking in
Expand Down
3 changes: 1 addition & 2 deletions ask/tests/test_ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from typing import Optional
from unittest.mock import patch

from ask.bot_service import BotService

from ..ask import run
from ..services.bot_service import BotService
from .e2e_utils import MockInputter, mock_parse_args


Expand Down
10 changes: 4 additions & 6 deletions ask/tests/test_ask_transcribe.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import Optional

from ask.tests.transcribe_prompt_inputter import TranscribePromptInputter
import argparse
import os

from ask.bot_service import BotService
from typing import Optional

from ..ask import run
from ..services.bot_service import BotService
from .e2e_utils import CapturingRenderer
from .transcribe_prompt_inputter import TranscribePromptInputter

TESTS_DIRECTORY = os.path.dirname(__file__)

Expand Down Expand Up @@ -47,7 +45,7 @@ def test_ask_transcribe(tmp_path):
Service=MockBotService,
Renderer=CapturingRenderer,
parse_args=create_parse_args_with_transcribe_filename(transcribe_filename),
config_file_name=f"{TESTS_DIRECTORY}/config/empty.ini"
config_file_name=f"{TESTS_DIRECTORY}/config/empty.ini",
)
assert renderer.messages[0] == "..."
assert renderer.messages[1] == "OK:mock input 1"
Expand Down

0 comments on commit 7b334a2

Please sign in to comment.