Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
penguine-ip committed Feb 5, 2025
1 parent 5e86f78 commit 1c5cb34
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
3 changes: 1 addition & 2 deletions deepeval/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"a_send_feedback",
"send_feedback",
"evaluate",
"auto_evaluate"
"assert_test",
"auto_evaluate" "assert_test",
"on_test_run_end",
"trace_langchain",
"trace_llama_index",
Expand Down
6 changes: 4 additions & 2 deletions deepeval/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
app.add_typer(recommend_app, name="recommend")



def generate_pairing_code():
"""Generate a random pairing code."""
return "".join(random.choices(string.ascii_uppercase + string.digits, k=6))


@app.command()
def login(
api_key: str = typer.Option(
Expand Down Expand Up @@ -67,7 +67,9 @@ def login(
if api_key:
break
else:
print("API Key cannot be empty. Please try again.\n")
print(
"API Key cannot be empty. Please try again.\n"
)

KEY_FILE_HANDLER.write_key(KeyValues.API_KEY, api_key)
print("Congratulations! Login successful :raising_hands: ")
Expand Down
18 changes: 13 additions & 5 deletions deepeval/cli/recommend.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ def ask_yes_no(question: str) -> bool:
if answer in ("y", "n"):
return answer == "y"
else:
print("[red]Invalid input.[/red] Please enter '[rgb(5,245,141)]Y[/rgb(5,245,141)]' for Yes or '[rgb(5,245,141)]N[/rgb(5,245,141)]' for No.")
print(
"[red]Invalid input.[/red] Please enter '[rgb(5,245,141)]Y[/rgb(5,245,141)]' for Yes or '[rgb(5,245,141)]N[/rgb(5,245,141)]' for No."
)


@app.command()
def metrics():
print("\n[bold]Welcome to [cyan]DeepEval[/cyan]! Let's find the best evaluation metrics for you.[/bold] :sparkles:\n")
print(
"\n[bold]Welcome to [cyan]DeepEval[/cyan]! Let's find the best evaluation metrics for you.[/bold] :sparkles:\n"
)

is_last_question = False
question_index = 0
Expand All @@ -70,16 +74,20 @@ def metrics():
user_answers.append(answer)

if is_last_question:
print("\n[bold rgb(5,245,141)]:rocket: Generating your recommended metrics...[/bold rgb(5,245,141)]\n")
print(
"\n[bold rgb(5,245,141)]:rocket: Generating your recommended metrics...[/bold rgb(5,245,141)]\n"
)
response: RecommendMetricsResponseData = get_recommended_metrics(
question_index + 1, user_answers
)

print("[bold cyan]Recommended Metrics:[/bold cyan]")
for metric in response.recommendedMetrics:
print(f" - {metric}")

print("\n:clap: [bold]You're all set![/bold] Run '[bold cyan]deepeval login[/bold cyan]' to start evaluating and analyzing metric scores on Confident AI.\n")
print(
"\n:clap: [bold]You're all set![/bold] Run '[bold cyan]deepeval login[/bold cyan]' to start evaluating and analyzing metric scores on Confident AI.\n"
)
break

question_index += 1
7 changes: 5 additions & 2 deletions deepeval/cli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

LOGGED_IN_WITH = "logged_in_with"


def start_server(pairing_code: str, prod_url: str) -> str:

class PairingHandler(http.server.SimpleHTTPRequestHandler):
Expand Down Expand Up @@ -49,8 +50,10 @@ def do_POST(self):
with socketserver.TCPServer(("localhost", 0), PairingHandler) as httpd:
port = httpd.server_address[1]
login_url = f"{prod_url}/pair?code={pairing_code}&port={port}"
print(f"Login and grab your API key here: [link={prod_url}]{prod_url}[/link] ")
print(
f"Login and grab your API key here: [link={prod_url}]{prod_url}[/link] "
)
webbrowser.open(login_url)
thread = threading.Thread(target=httpd.serve_forever, daemon=True)
thread.start()
thread.join()
thread.join()

0 comments on commit 1c5cb34

Please sign in to comment.