Skip to content

Commit

Permalink
Merge branch 'main' of github.com:plasma-umass/ChatDBG
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenfreund committed Apr 13, 2024
2 parents 937f2da + 4fe6d37 commit ceef87a
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: install test dependencies
run: |
python3 -m pip install pytest pytest-asyncio pytest-forked hypothesis
python3 -m pip install pytest pytest-asyncio pytest-forked hypothesis pytest-mock
python3 -m pip install -r test/requirements.txt
python3 -m pip install .
Expand Down
2 changes: 1 addition & 1 deletion src/chatdbg/pdb_util/locals.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _repr_if_defined(obj: Any) -> bool:
return result


def _format_limited(value: Any, limit: int = 10, depth: int = 3) -> str:
def _format_limited(value: Union[int, np.ndarray], limit: int = 10, depth: int = 3) -> str:
def format_tuple(t, depth):
return tuple([helper(x, depth) for x in t])

Expand Down
4 changes: 2 additions & 2 deletions src/chatdbg/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@


def _chatdbg_get_env(
option_name: str, default_value: Union[int, bool, str]
) -> Union[int, bool, str]:
option_name: str, default_value: Union[bool, int, str]
) -> Union[bool, int, str]:
env_name = "CHATDBG_" + option_name.upper()
v = os.getenv(env_name, str(default_value))
if type(default_value) == int:
Expand Down
3 changes: 1 addition & 2 deletions src/chatdbg/util/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import os
from chatdbg.util.config import chatdbg_config
from .text import truncate_proportionally
from types import NoneType
from typing import Any, Callable, List, Union, Optional


def _wrap_it(
before: str, text: Optional[str], after: str = "", maxlen: int = 2048
before: str, text: str, after: str = "", maxlen: int = 2048
) -> str:
if text:
text = truncate_proportionally(text, maxlen, 0.5)
Expand Down
2 changes: 1 addition & 1 deletion src/chatdbg/util/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def strip_ansi(s: str) -> str:


def truncate_proportionally(
text: str, maxlen: int = 32000, top_proportion: float = 0.5
text: str, maxlen: int = 32000, top_proportion: Union[float, int] = 0.5
) -> str:
"""Omit part of a string if needed to make it fit in a maximum length."""
if len(text) > maxlen:
Expand Down
4 changes: 2 additions & 2 deletions src/chatdbg/util/trim.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def _chunkify(messages, model):


def trim_messages(
messages: List[Dict], # list of JSON objects encoded as dicts
messages: List[Dict[str, str]], # list of JSON objects encoded as dicts
model: str,
trim_ratio: float = 0.75,
) -> List[Dict]:
) -> list:
"""
Strategy:
- chunk messages:
Expand Down

0 comments on commit ceef87a

Please sign in to comment.