Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tj202/pr add qol #39

Merged
merged 14 commits into from
Jan 23, 2025
Merged
18 changes: 18 additions & 0 deletions libs/agentc_cli/agentc_cli/cmds/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@
import datetime
import jinja2
import logging
import os
import pathlib
import platform
import subprocess
import typing

from ..models.context import Context
from agentc_core.record.descriptor import RecordKind

logger = logging.getLogger(__name__)

if os.environ.get("EDITOR"):
default_editor = os.environ.get("EDITOR")
elif os.environ.get("VISUAL"):
default_editor = os.environ.get("VISUAL")
elif platform.system() == "Windows":
default_editor = "notepad"
else:
default_editor = "vi"


def _get_name_and_description() -> tuple[str, str]:
name = click.prompt("Name", type=str)
Expand Down Expand Up @@ -37,6 +49,7 @@ def add_jinja_prompt(output: pathlib.Path, template_env: jinja2.Environment):
with output_file.open("w") as fp:
fp.write(rendered)
click.secho(f"Jinja prompt written to: {output_file}", fg="green")
subprocess.run([default_editor, f"{output_file}"])


def add_raw_prompt(output: pathlib.Path, template_env: jinja2.Environment):
Expand All @@ -56,6 +69,7 @@ def add_raw_prompt(output: pathlib.Path, template_env: jinja2.Environment):
with output_file.open("w") as fp:
fp.write(rendered)
click.secho(f"Raw prompt written to: {output_file}", fg="green")
subprocess.run([default_editor, f"{output_file}"])


def add_http_request(output: pathlib.Path, template_env: jinja2.Environment):
Expand All @@ -82,6 +96,7 @@ def add_http_request(output: pathlib.Path, template_env: jinja2.Environment):
with output_file.open("w") as fp:
fp.write(rendered)
click.secho(f"HTML request tool written to: {output_file}", fg="green")
subprocess.run([default_editor, f"{output_file}"])


def add_python_function(output: pathlib.Path, template_env: jinja2.Environment):
Expand All @@ -99,6 +114,7 @@ def add_python_function(output: pathlib.Path, template_env: jinja2.Environment):
with output_file.open("w") as fp:
fp.write(rendered)
click.secho(f"Python (function) tool written to: {output_file}", fg="green")
subprocess.run([default_editor, f"{output_file}"])


def add_semantic_search(output: pathlib.Path, template_env: jinja2.Environment):
Expand Down Expand Up @@ -133,6 +149,7 @@ def add_semantic_search(output: pathlib.Path, template_env: jinja2.Environment):
with output_file.open("w") as fp:
fp.write(rendered)
click.secho(f"Semantic search tool written to: {output_file}", fg="green")
subprocess.run([default_editor, f"{output_file}"])


def add_sqlpp_query(output: pathlib.Path, template_env: jinja2.Environment):
Expand All @@ -150,6 +167,7 @@ def add_sqlpp_query(output: pathlib.Path, template_env: jinja2.Environment):
with output_file.open("w") as fp:
fp.write(rendered)
click.secho(f"SQL++ query tool written to: {output_file}", fg="green")
subprocess.run([default_editor, f"{output_file}"])


def cmd_add(
Expand Down
2 changes: 1 addition & 1 deletion libs/agentc_cli/agentc_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def click_main(ctx, catalog, activity, verbose, interactive):
)
@click.pass_context
def add(ctx, output: pathlib.Path, record_kind: RecordKind):
"""Interactively create a new tool or prompt and save it to the filesystem (output)."""
"""Interactively create a new tool or prompt and save it to the filesystem (output). You MUST edit the generated file as per your requirements!"""
ctx_obj: Context = ctx.obj
if not ctx_obj.interactive:
click.secho(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
""" This file has been generated automatically by AGENT_CATALOG at {{ time }} as a http_request tool. """
from __future__ import annotations

import requests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
""" This file has been generated automatically by AGENT_CATALOG at {{ time }} as a semantic_search tool. """
from __future__ import annotations

import couchbase.auth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
""" This file has been generated automatically by AGENT_CATALOG at {{ time }} as a sqlpp_query tool. """
from __future__ import annotations

import couchbase.auth
Expand Down
Loading