Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix small benchmark bugs #1826

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions letta/benchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import time
import uuid
from typing import Annotated
from typing import Annotated, Union

import typer

from letta import create_client
from letta import LocalClient, RESTClient, create_client
from letta.benchmark.constants import HUMAN, PERSONA, PROMPTS, TRIES
from letta.config import LettaConfig

Expand All @@ -17,11 +17,13 @@
app = typer.Typer()


def send_message(message: str, agent_id, turn: int, fn_type: str, print_msg: bool = False, n_tries: int = TRIES):
def send_message(
client: Union[LocalClient, RESTClient], message: str, agent_id, turn: int, fn_type: str, print_msg: bool = False, n_tries: int = TRIES
):
try:
print_msg = f"\t-> Now running {fn_type}. Progress: {turn}/{n_tries}"
print(print_msg, end="\r", flush=True)
response = client.user_message(agent_id=agent_id, message=message, return_token_count=True)
response = client.user_message(agent_id=agent_id, message=message)

if turn + 1 == n_tries:
print(" " * len(print_msg), end="\r", flush=True)
Expand Down Expand Up @@ -65,7 +67,7 @@ def bench(

agent_id = agent.id
result, msg = send_message(
message=message, agent_id=agent_id, turn=i, fn_type=fn_type, print_msg=print_messages, n_tries=n_tries
client=client, message=message, agent_id=agent_id, turn=i, fn_type=fn_type, print_msg=print_messages, n_tries=n_tries
)

if print_messages:
Expand Down
Loading