Skip to content

Commit

Permalink
style: fix ruff issues and enforce in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Dec 6, 2024
1 parent f709344 commit 70255a0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libertai_agents/libertai_agents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logging

# Disables the error about frameworks not installed
logging.getLogger("transformers").disabled = True
logging.getLogger("transformers").disabled = True
4 changes: 2 additions & 2 deletions libertai_agents/libertai_agents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import inspect
import json
from http import HTTPStatus
from typing import Awaitable, Any, AsyncIterable
from typing import Any, AsyncIterable, Awaitable

import aiohttp
from aiohttp import ClientSession
Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(
if tools is None:
tools = []

if len(set(map(lambda x: x.name, tools))) != len(tools):
if len({x.name for x in tools}) != len(tools):
raise ValueError("Tool functions must have different names")
self.model = model
self.system_prompt = system_prompt
Expand Down
2 changes: 1 addition & 1 deletion libertai_agents/libertai_agents/interfaces/tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Any, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Callable

from pydantic.json_schema import GenerateJsonSchema, JsonSchemaMode, JsonSchemaValue
from pydantic.v1 import BaseModel
Expand Down
6 changes: 3 additions & 3 deletions libertai_agents/libertai_agents/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from libertai_agents.interfaces.messages import (
Message,
ToolCallFunction,
MessageRoleEnum,
ToolCallFunction,
)
from libertai_agents.interfaces.tools import Tool

Expand Down Expand Up @@ -74,13 +74,13 @@ def generate_prompt(
if self.include_system_message and system_prompt is not None
else []
)
raw_messages = list(map(lambda x: x.dict(), messages))
raw_messages = [x.dict() for x in messages]

for i in range(len(raw_messages)):
included_messages: list = system_messages + raw_messages[i:]
prompt = self.tokenizer.apply_chat_template(
conversation=included_messages,
tools=list(map(lambda x: x.args_schema, tools)),
tools=[x.args_schema for x in tools],
tokenize=False,
add_generation_prompt=True,
)
Expand Down
2 changes: 1 addition & 1 deletion libertai_agents/libertai_agents/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TypeVar, Callable
from typing import Callable, TypeVar

T = TypeVar("T")

Expand Down
4 changes: 4 additions & 0 deletions libertai_agents/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ pytest-cov = "^6.0.0"
[tool.poetry.extras]
langchain = ["langchain-community"]

[tool.ruff]
lint.select = ["C", "E", "F", "I", "W"]
lint.ignore = ["E501"]

[tool.pytest.ini_options]
addopts = "--cov=libertai_agents"
testpaths = ["tests"]
Expand Down

0 comments on commit 70255a0

Please sign in to comment.