Skip to content

Commit

Permalink
Add tests (#277)
Browse files Browse the repository at this point in the history
* tests added

* Tegother AI model dict fixed

* test fix

* some tests added

* tests fixed

* test fixed

* fixed docs
  • Loading branch information
davorrunje authored Sep 25, 2024
1 parent 54d67e3 commit 1fc698e
Show file tree
Hide file tree
Showing 15 changed files with 387 additions and 62 deletions.
6 changes: 4 additions & 2 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ search:
- [get_import_string](api/fastagency/cli/discover/get_import_string.md)
- [get_module_data_from_path](api/fastagency/cli/discover/get_module_data_from_path.md)
- [import_from_string](api/fastagency/cli/discover/import_from_string.md)
- exceptions
- [FastAgencyCLIError](api/fastagency/cli/exceptions/FastAgencyCLIError.md)
- logging
- [setup_logging](api/fastagency/cli/logging/setup_logging.md)
- exceptions
- [FastAgencyCLIError](api/fastagency/exceptions/FastAgencyCLIError.md)
- [FastAgencyCLIPythonVersionError](api/fastagency/exceptions/FastAgencyCLIPythonVersionError.md)
- [FastAgencyError](api/fastagency/exceptions/FastAgencyError.md)
- logging
- [get_logger](api/fastagency/logging/get_logger.md)
- runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ search:
boost: 0.5
---

::: fastagency.cli.exceptions.FastAgencyCLIError
::: fastagency.exceptions.FastAgencyCLIError
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: fastagency.exceptions.FastAgencyCLIPythonVersionError
11 changes: 11 additions & 0 deletions docs/docs/en/api/fastagency/exceptions/FastAgencyError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: fastagency.exceptions.FastAgencyError
9 changes: 7 additions & 2 deletions fastagency/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import typer

from .. import __version__
from ..exceptions import FastAgencyCLIError, FastAgencyCLIPythonVersionError
from .discover import get_import_string
from .exceptions import FastAgencyCLIError
from .logging import setup_logging

app = typer.Typer(rich_markup_mode="rich")
Expand Down Expand Up @@ -57,8 +57,13 @@ def _run_app(
initial_message=initial_message,
single_run=single_run,
)
except FastAgencyCLIPythonVersionError as e:
msg = e.args[0]
typer.echo(msg, err=True)
raise typer.Exit(code=1) # noqa: B904
except FastAgencyCLIError as e:
logger.error(str(e))
msg = e.args[0]
typer.echo(msg, err=True)
raise typer.Exit(code=1) from None


Expand Down
2 changes: 1 addition & 1 deletion fastagency/cli/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from rich.tree import Tree

from .. import FastAgency
from .exceptions import FastAgencyCLIError
from ..exceptions import FastAgencyCLIError

logger = getLogger(__name__)

Expand Down
2 changes: 0 additions & 2 deletions fastagency/cli/exceptions.py

This file was deleted.

10 changes: 10 additions & 0 deletions fastagency/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class FastAgencyError(Exception):
pass


class FastAgencyCLIError(FastAgencyError):
pass


class FastAgencyCLIPythonVersionError(FastAgencyCLIError):
pass
4 changes: 2 additions & 2 deletions fastagency/studio/models/llms/together.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
"Gemma-2 Instruct (9B)": "google/gemma-2-9b-it",
"Meta Llama 3 8B Instruct Reference": "meta-llama/Llama-3-8b-chat-hf",
"Meta Llama 3.1 70B Instruct Turbo": "albert/meta-llama-3-1-70b-instruct-turbo",
"Meta Llama 3.1 8B Instruct Turbo": "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
"WizardLM-2 (8x22B)": "microsoft/WizardLM-2-8x22B",
"Mixtral-8x7B Instruct v0.1": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"Meta Llama 3.1 405B Instruct Turbo": "meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro",
"Meta Llama 3.1 405B Instruct Turbo": "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
"Meta Llama 3 70B Instruct Reference": "meta-llama/Llama-3-70b-chat-hf",
"LLaVa-Next (Mistral-7B)": "llava-hf/llava-v1.6-mistral-7b-hf",
"DBRX Instruct": "databricks/dbrx-instruct",
"Nous Hermes 2 - Mixtral 8x7B-DPO ": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
"Meta Llama 3 8B Instruct Turbo": "meta-llama/Meta-Llama-3-8B-Instruct-Turbo",
"Meta Llama 3 8B Instruct Lite": "meta-llama/Meta-Llama-3-8B-Instruct-Lite",
"Meta Llama 3.1 8B Instruct": "meta-llama/Meta-Llama-3.1-8B-Instruct-Reference",
"Meta Llama 3.1 8B Instruct Turbo": "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
"Mixtral-8x22B Instruct v0.1": "mistralai/Mixtral-8x22B-Instruct-v0.1",
"Gryphe MythoMax L2 Lite (13B)": "Gryphe/MythoMax-L2-13b-Lite",
"Hermes 3 - Llama-3.1 405B": "NousResearch/Hermes-3-Llama-3.1-405B-Turbo",
Expand Down
7 changes: 7 additions & 0 deletions fastagency/ui/mesop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import sys

from ...exceptions import FastAgencyCLIPythonVersionError

if sys.version_info < (3, 10):
raise FastAgencyCLIPythonVersionError("Mesop requires Python 3.10 or higher")

from .base import MesopUI

__all__ = ["MesopUI"]
34 changes: 2 additions & 32 deletions fastagency/ui/mesop/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import threading
from collections.abc import Generator, Iterator
from contextlib import contextmanager
Expand All @@ -9,12 +8,6 @@
from typing import ClassVar, Optional
from uuid import uuid4

import typer

if sys.version_info < (3, 10):
typer.echo("Error: Mesop requires Python 3.10 or higher", err=True)
raise typer.Exit(code=1)

from mesop.bin.bin import FLAGS as MESOP_FLAGS
from mesop.bin.bin import main as mesop_main

Expand Down Expand Up @@ -86,8 +79,8 @@ def app(self) -> Runnable:
@contextmanager
def create(self, app: Runnable, import_string: str) -> Iterator[None]:
logger.info(f"Creating MesopUI with import string: {import_string}")
self._app = app
self._import_string = import_string
MesopUI._app = app
MesopUI._import_string = import_string

start_script = """import fastagency.ui.mesop.main"""

Expand Down Expand Up @@ -290,26 +283,3 @@ def conversation_worker(ui: MesopUI, subconversation: MesopUI) -> None:
thread.start()

return subconversation


# ui.process_message(
# IOMessage.create(
# sender="tester",
# recipient="workflow",
# type="text_input",
# prompt="What is your fvourite fruit",
# suggestions=["Pomegratten", "I do not eat fruit"],
# )
# )

# ui.process_message(
# IOMessage.create(
# sender="tester",
# recipient="workflow",
# type="multiple_choice",
# prompt="Concentrate and choose correct answer. When are you going to write unit tests?",
# choices=["Today", "Tomorrow", "Never", "I already have unit tests"],
# default="Tomorrow",
# single=False,
# )
# )
Loading

0 comments on commit 1fc698e

Please sign in to comment.