Skip to content

Commit

Permalink
version reporting added through ai
Browse files Browse the repository at this point in the history
  • Loading branch information
apurvakhatri committed Mar 2, 2024
1 parent 642ac53 commit 74d5ea3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/jupyter-ai-magics/jupyter_ai_magics/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from langchain.chains import LLMChain
from langchain.schema import HumanMessage

from ._version import __version__


from .parsers import (
CellArgs,
DeleteArgs,
Expand All @@ -24,6 +27,7 @@
ListArgs,
RegisterArgs,
UpdateArgs,
VersionArgs,
cell_magic_parser,
line_magic_parser,
)
Expand Down Expand Up @@ -473,6 +477,9 @@ def handle_list(self, args: ListArgs):
self._ai_list_command_markdown(args.provider_id),
)

def handle_version(self, args: VersionArgs):
return __version__

def run_ai_cell(self, args: CellArgs, prompt: str):
provider_id, local_model_id = self._decompose_model_id(args.model_id)

Expand Down Expand Up @@ -588,6 +595,8 @@ def ai(self, line, cell=None):
return self.handle_delete(args)
if args.type == "update":
return self.handle_update(args)
if args.type == "version":
return self.handle_version(args)
except ValueError as e:
print(e, file=sys.stderr)
return
Expand Down
9 changes: 9 additions & 0 deletions packages/jupyter-ai-magics/jupyter_ai_magics/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class ErrorArgs(BaseModel):
class HelpArgs(BaseModel):
type: Literal["help"] = "help"

class VersionArgs(BaseModel):
type: Literal["version"] = "version"

class ListArgs(BaseModel):
type: Literal["list"] = "list"
Expand Down Expand Up @@ -214,6 +216,13 @@ def error_subparser(**kwargs):
"""
return ErrorArgs(**kwargs)

@line_magic_parser.command(name="version")
def version_subparser(**kwargs):
"""
Prints Jupyter-AI version
"""
return VersionArgs(**kwargs)


@line_magic_parser.command(name="help")
def help_subparser():
Expand Down

0 comments on commit 74d5ea3

Please sign in to comment.