Skip to content

Commit 92028fa

Browse files
committed
fix:introduced gracefull handling
1 parent 0989f9e commit 92028fa

4 files changed

Lines changed: 45 additions & 12 deletions

File tree

lambda_agent/cli_setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def run_setup() -> tuple[str, str]:
1717
if not api_key:
1818
print("API Key cannot be empty. Please try again.")
1919

20-
default_model = "gemini-3.1-flash-lite-preview"
20+
default_model = "gemini-3.1-pro-preview"
2121
model_name = input(f"Enter model name (default: {default_model}): ").strip()
2222
if not model_name:
2323
model_name = default_model
@@ -37,7 +37,7 @@ def run_setup() -> tuple[str, str]:
3737

3838
print(f"\n✅ Setup complete! Configuration saved to {config_file}\n")
3939
except Exception as e:
40-
print(f"\n Error saving configuration: {e}")
40+
print(f"\n Error saving configuration: {e}")
4141
print("Continuing with in-memory configuration for this session.\n")
4242

4343
return api_key, model_name

lambda_agent/config.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
)
1818

1919
API_KEY = os.getenv("API_KEY")
20-
MODEL_NAME = os.getenv("MODEL_NAME", "gemini-3.1-flash-lite-preview")
20+
MODEL_NAME = os.getenv("MODEL_NAME", "gemini-3.1-pro-preview")
2121

2222
# Models available for /models switching
2323
AVAILABLE_MODELS = [
24+
"gemini-3.1-pro-preview",
25+
"gemini-3-flash-preview",
2426
"gemini-3.1-flash-lite-preview",
27+
"gemini-2.5-pro",
2528
"gemini-2.5-flash",
26-
"gemini-3.1-pro-preview",
27-
"gemini-2.5-pro-preview-05-06",
28-
"gemini-2.0-flash",
29-
"gemini-2.0-flash-lite",
29+
"gemini-2.5-flash-lite",
30+
"gemma-4-26b-a4b-it",
31+
"gemma-4-31b-it",
3032
]

lambda_agent/main.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,43 @@ def main():
238238
)
239239

240240
while True:
241+
# Inner loop logic to handle prompt input vs command execution
241242
try:
242-
# Styled prompt — uses plain input to keep cursor on same line
243243
user_input = Prompt.ask(
244244
"\n[bold bright_yellow] You[/bold bright_yellow]",
245245
console=console,
246246
)
247+
except KeyboardInterrupt:
248+
console.print()
249+
# Show session token summary before quitting
250+
if agent.token_usage.total > 0:
251+
console.print(
252+
Panel(
253+
Text.assemble(
254+
("Session token usage\n", "bold white"),
255+
(" Prompt (in): ", "dim"),
256+
(f"{agent.token_usage.prompt:>10,}\n", "cyan"),
257+
(" Completion (out): ", "dim"),
258+
(f"{agent.token_usage.completion:>10,}\n", "cyan"),
259+
(" Total: ", "dim"),
260+
(f"{agent.token_usage.total:>10,}", "bold cyan"),
261+
),
262+
border_style="cyan",
263+
box=box.ROUNDED,
264+
title="[bold cyan]⚡ Token Summary[/bold cyan]",
265+
title_align="left",
266+
)
267+
)
268+
console.print(
269+
Panel(
270+
"[bold cyan]Goodbye! Lambda signing off.[/bold cyan]",
271+
border_style="cyan",
272+
box=box.ROUNDED,
273+
)
274+
)
275+
break
247276

277+
try:
248278
if user_input.lower() in ["exit", "quit"]:
249279
console.print()
250280
# Show session token summary before quitting
@@ -300,9 +330,10 @@ def main():
300330
print_token_stats(turn_usage, agent.token_usage)
301331

302332
except KeyboardInterrupt:
303-
console.print()
304-
console.print("[bold cyan]\nGoodbye![/bold cyan]")
305-
break
333+
console.print(
334+
"\n [bold yellow]⚠ Action cancelled by user.[/bold yellow]"
335+
)
336+
continue
306337

307338
except Exception as e:
308339
console.print(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "lambda-agent"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
description = "Lambda - A minimal AI coding agent"
99
readme = "README.md"
1010
requires-python = ">=3.10"

0 commit comments

Comments
 (0)