Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnl committed Apr 2, 2024
1 parent 6e50514 commit 8a28d7e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion examples/middleware/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class PrintLastUserMessage(instructor.MessageMiddleware):

log: bool = False

def __call__(
Expand Down
1 change: 1 addition & 0 deletions instructor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"Instructor",
"MessageMiddleware",
"AsyncMessageMiddleware",
"messages_middleware",
"from_openai",
"from_anthropic",
"from_litellm",
Expand Down
11 changes: 7 additions & 4 deletions instructor/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,13 @@ def from_anthropic(
mode: instructor.Mode = instructor.Mode.ANTHROPIC_JSON,
**kwargs,
) -> Instructor | AsyncInstructor:
assert mode in {
instructor.Mode.ANTHROPIC_JSON,
instructor.Mode.ANTHROPIC_TOOLS,
}, "Mode be one of {instructor.Mode.ANTHROPIC_JSON, instructor.Mode.ANTHROPIC_TOOLS}"
assert (
mode
in {
instructor.Mode.ANTHROPIC_JSON,
instructor.Mode.ANTHROPIC_TOOLS,
}
), "Mode be one of {instructor.Mode.ANTHROPIC_JSON, instructor.Mode.ANTHROPIC_TOOLS}"

assert isinstance(
client, (anthropic.Anthropic, anthropic.AsyncAnthropic)
Expand Down
3 changes: 0 additions & 3 deletions instructor/messages_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class MessageMiddleware(BaseModel, ABC):

@abstractmethod
def __call__(
self, messages: List[ChatCompletionMessageParam]
Expand All @@ -14,7 +13,6 @@ def __call__(


class AsyncMessageMiddleware(MessageMiddleware):

@abstractmethod
async def __call__(
self, messages: List[ChatCompletionMessageParam]
Expand All @@ -23,7 +21,6 @@ async def __call__(


def messages_middleware(func: Callable) -> MessageMiddleware:

class _Middleware(MessageMiddleware):
def __call__(
self, messages: List[ChatCompletionMessageParam]
Expand Down
1 change: 0 additions & 1 deletion tests/llm/test_openai/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class QuestionAnswerNoEvil(BaseModel):

@pytest.mark.parametrize("model", models)
def test_runmodel_validator_default_openai_client(model, client):

client = instructor.from_openai(client)

class QuestionAnswerNoEvil(BaseModel):
Expand Down

0 comments on commit 8a28d7e

Please sign in to comment.