Skip to content

Commit

Permalink
make prints prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
areibman committed Sep 17, 2024
1 parent b295281 commit 0cba46b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "spellcaster"
version = "0.0.2"
version = "0.0.3"
authors = [
{ name="Alex Reibman", email="areibman@gmail.com" }
]
Expand Down
25 changes: 11 additions & 14 deletions spellcaster/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,33 @@ def main():
)

args = parser.parse_args()
path = ""
if args.url:
path = args.url
current_dir = Path.cwd()
repo_name = args.url.rstrip('/').split("/")[-1].replace(".git", "")
org = args.url.rstrip('/').split("/")[-2]
print(repo_name)
console.print(f"[bold cyan]Repository:[/bold cyan] {repo_name}")
directory = current_dir / "spellcaster" / "samples" / org / repo_name
print(f"Using directory: {directory}")
console.print(f"[bold green]Using directory:[/bold green] {directory}")
if directory.exists():
print(f"Repository already exists at {directory}")
console.print(f"[bold yellow]Repository already exists at[/bold yellow] {directory}")
else:
print(f"Cloning repository from {args.url}...")
console.print(f"[bold blue]Cloning repository from[/bold blue] {args.url}...")
directory.mkdir(parents=True, exist_ok=True) # Ensure the directory is created
clone_repository(args.url, str(directory))
print(f"Repository cloned successfully to {directory}")
console.print(f"[bold green]Repository cloned successfully to[/bold green] {directory}")
elif args.directory:
path = args.directory
directory = args.directory
print(f"Using existing directory: {directory}")
console.print(f"[bold green]Using existing directory:[/bold green] {directory}")
else:
parser.error("Either --directory or --url must be provided")
parser.error("[bold red]Either --directory or --url must be provided[/bold red]")

llm_provider = args.llm_provider
print(f"Using LLM provider: {llm_provider}")
console.print(f"[bold magenta]Using LLM provider:[/bold magenta] {llm_provider}")

file_paths = get_file_paths(directory, args.file_types, args.max_files)
print(f"Found {len(file_paths)} files to scan")
console.print(f"[bold cyan]Found {len(file_paths)} files to scan[/bold cyan]")

print("Starting grammar check...")
console.print("[bold green]Starting grammar check...[/bold green]")

agentops.init(os.environ.get("AGENTOPS_API_KEY"), default_tags=["spellcaster", 'cursor', 'Cerebras', 'gpt4o'])
results = []
Expand All @@ -100,7 +97,7 @@ def main():

console.print(f"[bold red]Total errors in the docs found: {total}[/bold red]")

print("Grammar check completed.")
console.print("[bold green]Grammar check completed.[/bold green]")
agentops.end_session("Success")


Expand Down
5 changes: 1 addition & 4 deletions spellcaster/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Grammar(BaseModel):
spelling: list[Error]
punctuation: list[Error]
grammar: list[Error]
# corrected: str
file_path: str


Expand Down Expand Up @@ -92,9 +91,7 @@ def check_grammar(file_path: str, proper_nouns: str, model: str = MODEL) -> Gram
text_response = resp.choices[0].message.content
resp = Grammar.model_validate_json(text_response)

# Double check step
console.print("[bold blue]Double check step[/bold blue]")

# Double check reasoning
validated_response = validate_reasoning(resp.json(), model=model)

if validated_response is False:
Expand Down

0 comments on commit 0cba46b

Please sign in to comment.