Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
yanxi0830 committed Nov 22, 2024
1 parent e9ef5af commit c8302cd
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 27 deletions.
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ repos:
- torchfix
args: ['--config=.flake8']

- repo: https://github.com/omnilib/ufmt
rev: v2.7.0
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: ufmt
files: ^src/llama_stack_client/lib/.* # Only run on files in specific-folder
additional_dependencies:
- black == 24.4.2
- usort == 1.0.8
- id: isort
files: ^src/llama_stack_client/lib/.*
5 changes: 4 additions & 1 deletion src/llama_stack_client/lib/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
from typing import List, Optional, Tuple, Union

from llama_stack_client import LlamaStackClient
from llama_stack_client.types import Attachment, ToolResponseMessage, UserMessage
from llama_stack_client.types import (Attachment, ToolResponseMessage,
UserMessage)
from llama_stack_client.types.agent_create_params import AgentConfig

from .custom_tool import CustomTool


class Agent:
def __init__(self, client: LlamaStackClient, agent_config: AgentConfig, custom_tools: Tuple[CustomTool] = ()):
self.client = client
Expand Down
8 changes: 4 additions & 4 deletions src/llama_stack_client/lib/agents/custom_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# the root directory of this source tree.

import json

from abc import abstractmethod
from typing import Dict, List, Union

from llama_stack_client.types import FunctionCallToolDefinition, ToolResponseMessage, UserMessage

from llama_stack_client.types.tool_param_definition_param import ToolParamDefinitionParam
from llama_stack_client.types import (FunctionCallToolDefinition,
ToolResponseMessage, UserMessage)
from llama_stack_client.types.tool_param_definition_param import \
ToolParamDefinitionParam


class CustomTool:
Expand Down
2 changes: 1 addition & 1 deletion src/llama_stack_client/lib/agents/event_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,4 @@ def log(self, event_generator):
for chunk in event_generator:
for log_event in self._get_log_event(chunk, previous_event_type, previous_step_type):
yield log_event
previous_event_type, previous_step_type = self._get_event_type_step_type(chunk)
previous_event_type, previous_step_type = self._get_event_type_step_type(chunk)
5 changes: 3 additions & 2 deletions src/llama_stack_client/lib/cli/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from functools import wraps

from rich.console import Console
from rich.table import Table
from rich.panel import Panel
from functools import wraps
from rich.table import Table


def create_bar_chart(data, labels, title=""):
Expand Down
3 changes: 2 additions & 1 deletion src/llama_stack_client/lib/cli/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from prompt_toolkit import prompt
from prompt_toolkit.validation import Validator

from llama_stack_client.lib.cli.constants import get_config_file_path, LLAMA_STACK_CLIENT_CONFIG_DIR
from llama_stack_client.lib.cli.constants import (
LLAMA_STACK_CLIENT_CONFIG_DIR, get_config_file_path)


def get_config():
Expand Down
1 change: 0 additions & 1 deletion src/llama_stack_client/lib/cli/eval_tasks/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from rich.console import Console
from rich.table import Table


from ..common.utils import handle_client_errors


Expand Down
3 changes: 1 addition & 2 deletions src/llama_stack_client/lib/cli/llama_stack_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
import yaml

from llama_stack_client import LlamaStackClient
from .configure import configure

from .configure import configure
from .constants import get_config_file_path
from .datasets import datasets
from .eval import eval
from .eval_tasks import eval_tasks
from .inference import inference
from .memory_banks import memory_banks
from .models import models

from .providers import providers
from .scoring_functions import scoring_functions
from .shields import shields
Expand Down
2 changes: 2 additions & 0 deletions src/llama_stack_client/lib/cli/providers/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from rich.table import Table

from ..common.utils import handle_client_errors


@click.command("list")
@click.pass_context
@handle_client_errors("list providers")
Expand Down
14 changes: 6 additions & 8 deletions src/llama_stack_client/lib/direct/direct.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import inspect
import yaml
from typing import Any, cast, get_args, get_origin, Type
from typing import Any, Type, cast, get_args, get_origin

from rich.console import Console
import yaml
from llama_stack.distribution.datatypes import StackRunConfig
from llama_stack.distribution.distribution import get_provider_registry
from llama_stack.distribution.resolver import resolve_impls
from llama_stack.distribution.server.endpoints import get_all_api_endpoints
from llama_stack.distribution.server.server import is_streaming_request
from llama_stack.distribution.stack import (
get_stack_run_config_from_template,
)
from llama_stack.distribution.stack import construct_stack
from llama_stack.distribution.stack import (construct_stack,
get_stack_run_config_from_template)
from pydantic import BaseModel
from rich.console import Console

from ..._base_client import ResponseT
from ..._client import LlamaStackClient
from ..._streaming import Stream
from ..._types import Body, NOT_GIVEN, RequestFiles, RequestOptions
from ..._types import NOT_GIVEN, Body, RequestFiles, RequestOptions


class LlamaStackDirectClient(LlamaStackClient):
Expand Down
1 change: 1 addition & 0 deletions src/llama_stack_client/lib/direct/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import yaml
from llama_stack.distribution.configure import parse_and_maybe_upgrade_config

from llama_stack_client.lib.direct.direct import LlamaStackDirectClient
from llama_stack_client.types import UserMessage

Expand Down

0 comments on commit c8302cd

Please sign in to comment.