devjas1 commited on
Commit
f2b471a
·
1 Parent(s): 03e744b

(FIX)[CLI-ErrorHandling]: improve error handling and clarify server placeholder

Browse files

- Enhanced error handling in CLI command for commit message generation.
- Added clearer placeholder and messaging for the serve command.
- Removed unused code and improved code comments for maintainability.

Files changed (1) hide show
  1. cli.py +19 -8
cli.py CHANGED
@@ -51,13 +51,26 @@ def ask(query: str):
51
  prompt = "\n".join(context) + f"\n\nUser question: {query}"
52
  try:
53
  response = generate_commit_message(prompt, config)
54
- except (
55
- RuntimeError
56
- ): # Replace with the specific exception type raised by generate_commit_message
57
  response = fallback_commit_message([])
58
  typer.echo(response)
59
 
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  # `commit` — Git Diff + Message Generation
62
  @app.command()
63
  def commit(preview: bool = True, apply: bool = False, dry_run: bool = False):
@@ -93,8 +106,6 @@ def commit(preview: bool = True, apply: bool = False, dry_run: bool = False):
93
  subprocess.run(["git", "commit", "-m", message])
94
 
95
 
96
- from sentence_transformers import SentenceTransformer
97
-
98
- model = SentenceTransformer("./models/embeddinggemma-300m")
99
- emb = model.encode("Test string")
100
- print("Embedding shape:", emb.shape) # Should be (768,)
 
51
  prompt = "\n".join(context) + f"\n\nUser question: {query}"
52
  try:
53
  response = generate_commit_message(prompt, config)
54
+ except Exception as e:
55
+ typer.echo(f"Generation failed: {e}")
 
56
  response = fallback_commit_message([])
57
  typer.echo(response)
58
 
59
 
60
+ # `serve` — Start local API server (placeholder)
61
+ @app.command()
62
+ def serve(port: int = 8000):
63
+ """
64
+ Start a local API server for integrations.
65
+
66
+ Args:
67
+ port (int): Port number to serve on. Defaults to 8000.
68
+ """
69
+ typer.echo(f"API server functionality not implemented yet.")
70
+ typer.echo(f"Would start server on port {port}")
71
+ raise typer.Exit(1)
72
+
73
+
74
  # `commit` — Git Diff + Message Generation
75
  @app.command()
76
  def commit(preview: bool = True, apply: bool = False, dry_run: bool = False):
 
106
  subprocess.run(["git", "commit", "-m", message])
107
 
108
 
109
+ # Entry point for CLI application
110
+ if __name__ == "__main__":
111
+ app()