Skip to content
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
23 changes: 21 additions & 2 deletions cllm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,27 @@
import os
import json
import platform
from langchain.chains import LLMChain
import tomllib
from langchain_openai import ChatOpenAI
from langchain_core.prompts import (ChatPromptTemplate, FewShotChatMessagePromptTemplate)

app = typer.Typer(help="Empower your CLI experience with a command search tool driven by LLM magic!")
from typing import Optional
from typing_extensions import Annotated

# version of the CLI
app = typer.Typer(help="Empower your CLI experience with a command search tool driven by LLM magic!",
context_settings={"help_option_names": ["-h", "--help"]}
)

app.add_typer(set_index.set_app, name="set", help="Set up configurations used in cllm")

def version_callback(value: bool):
if value:
with open("./pyproject.toml", "rb") as f:
data = tomllib.load(f)
typer.echo(f"cllm version: {data['tool']['poetry']['version']}")
raise typer.Exit()

@app.command()
def search(query : str):
"""Search a command from the LLM model"""
Expand Down Expand Up @@ -66,5 +79,11 @@ def search(query : str):

typer.echo(output.content)

@app.callback()
def main(
version: Optional[bool] = typer.Option(None, "--version", "-v", callback=version_callback, help="Print cllm version")
):
pass

if __name__ == "__main__":
app()