Skip to content

Commit

Permalink
WIP: Start fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NickyHavoc committed Feb 21, 2024
1 parent f55b162 commit 5da9a12
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 4 additions & 6 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
AlephAlphaClientProtocol,
LimitedConcurrencyClient,
)
from intelligence_layer.core.model import AlephAlphaModel
from intelligence_layer.core.model import AlephAlphaModel, LuminousControlModel
from intelligence_layer.core.tracer import NoOpTracer
from intelligence_layer.use_cases.classify.classify import (
ClassifyInput,
Expand All @@ -23,16 +23,14 @@
load_dotenv()


def client() -> AlephAlphaClientProtocol:
token = os.getenv("AA_TOKEN")
assert token is not None, "Define AA_TOKEN in your .env file"
return LimitedConcurrencyClient.from_token(token=token)
def model() -> AlephAlphaModel:
return LuminousControlModel("luminous-base-control-20240215")


@app.post("/classify")
async def classify(
classify_input: ClassifyInput,
luminous_control_model: AlephAlphaModel = Depends(client),
luminous_control_model: AlephAlphaModel = Depends(model),
) -> SingleLabelClassifyOutput:
classify = PromptBasedClassify(luminous_control_model)
classify_output = classify.run(classify_input, NoOpTracer())
Expand Down
18 changes: 14 additions & 4 deletions tests/core/test_text_highlight.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
from aleph_alpha_client import Image
from pytest import fixture, raises

from intelligence_layer.core.model import LuminousControlModel
from intelligence_layer.core.prompt_template import PromptTemplate
from intelligence_layer.core.model import AlephAlphaModel, LuminousControlModel
from intelligence_layer.core.prompt_template import PromptTemplate, RichPrompt
from intelligence_layer.core.text_highlight import TextHighlight, TextHighlightInput
from intelligence_layer.core.tracer import NoOpTracer


class AlephAlphaVanillaModel(AlephAlphaModel):
def to_instruct_prompt(self, instruction: str, input: str | None = None, response_prefix: str | None = None) -> RichPrompt:
raise NotImplementedError()


@fixture
def aleph_alpha_vanilla_model() -> AlephAlphaVanillaModel:
return AlephAlphaVanillaModel("luminous-base")


@fixture
def text_highlight(luminous_control_model: LuminousControlModel) -> TextHighlight:
return TextHighlight(luminous_control_model)
def text_highlight(aleph_alpha_vanilla_model: AlephAlphaVanillaModel) -> TextHighlight:
return TextHighlight(aleph_alpha_vanilla_model)


def test_text_highlight(text_highlight: TextHighlight) -> None:
Expand Down

0 comments on commit 5da9a12

Please sign in to comment.