From 7393661b90dcb2da28f99be7fbce80d28b88412a Mon Sep 17 00:00:00 2001 From: Mehfuz Hossain Date: Sat, 8 Feb 2025 19:51:55 -0800 Subject: [PATCH] DEV-60: Moving Project to Agent (#3) * updated references for project => agent * missing file * minor fixes --- README.md | 61 ++++++++++++++++++-------- smartloop/__init__.py | 2 +- smartloop/app.py | 31 +++++++------ smartloop/cmd/__init__.py | 2 +- smartloop/cmd/{project.py => agent.py} | 6 +-- 5 files changed, 65 insertions(+), 37 deletions(-) rename smartloop/cmd/{project.py => agent.py} (98%) diff --git a/README.md b/README.md index 10b7b2e..5b45341 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,33 @@ pip install -U smartloop ``` Once installed, check that everything is setup correctly: -![image](https://github.com/user-attachments/assets/0a4e0221-d2f7-4f87-9fb2-5e4ce7a23f62) +```console +smartloop --help + + Usage: smartloop [OPTIONS] COMMAND [ARGS]... + +╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ --install-completion Install completion for the current shell. │ +│ --show-completion Show completion for the current shell, to copy it or customize the installation. │ +│ --help Show this message and exit. │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ agent Manage agent(s) │ +│ login Authenticate using a token from https://api.smartloop.ai/v1/redoc │ +│ run Starts a chat session with a selected agent │ +│ upload Upload document for the selected agent │ +│ version Version of the cli │ +│ whoami Find out which account you are logged in │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + +``` + ## Setup -First you will need to create a free [account](https://app.smartloop.ai/signup), verify and configure your account. Once verified, copy your [developer token](https://app.smartloop.ai/developer) to the clipboard. You will need a invitation code as of writing this document, please reach out to us at `hello@smartloop.ai` and we should be able to get you started. +First you will need to create a free [account](https://agent.smartloop.ai/signup), verify and configure your account. +Once verified, copy your [developer token](https://agent.smartloop.ai/developer) to the clipboard. If you have any problem setting up your account please reach out to us at `hello@smartloop.ai` and we should be able to get you started. Once you have your token, run the following command in your terminal: @@ -34,27 +56,26 @@ Once you have your token, run the following command in your terminal: smartloop login ``` +## Create an Agent -## Create a Project - -This command will prompt you for your token, copy and pase the token that you have received in your email. Next step it to create a project, you can do so with the following command: +Once you have configured the CLI , you can start creating agent using the following command: ```bash -smartloop project create --name microsoft +smartloop agent create --name microsoft ``` -## Select a Project +## Select an Agent -Use the following command to interactively select a project: +Use the following command to interactively select an agent: ```bash -smartloop project select +smartloop agent select ``` ## Upload Document -Once the project is selected , upload documents from your folder or a specific file, in this case I am uploading the a document describing Microsoft online services form my local machine: +Once the agent is selected , upload documents from your folder or a specific file to personalized your agent, in this case I am uploading the a document describing Microsoft online services form my local machine: ```bash smartloop upload --path=~/document1.pdf @@ -62,17 +83,19 @@ smartloop upload --path=~/document1.pdf ## Run It -Next step, once the project is selected, document(s) you have uploaded are processed, execute the following to start prompting: +Execute the following command to start prompting: ```bash smartloop run ``` -This will bring up the prompt to query your information from your uploaded document(s) +This will bring up the interface to prompt your queries as shown below: ```bash -Current project: Microsoft(microsoft-24-07-2024) -Enter message (Ctrl-C to exit): what the SLA for azure open ai +Microsoft(microsoft-24-07-2024) +====================================== +Enter prompt (Ctrl-C to exit): +what the SLA for azure open ai ⠋ The SLA (Service Level Agreement) for Azure OpenAI is not explicitly mentioned in the provided text. However, it's possible that the SLA for Azure OpenAI might be similar to the one mentioned below: @@ -85,27 +108,27 @@ The SLA (Service Level Agreement) for Azure OpenAI is not explicitly mentioned i Please note that this is not a direct quote from the provided text, but rather an inference based on the format and structure of the SLA mentioned for other Azure services (e.g., SAP HANA on Azure High Availability Pair). To confirm the actual SLA for Azure OpenAI, you should check the official Microsoft documentation or contact their support team. -Enter message (Ctrl-C to exit): +Prompt message (Ctrl-C to exit): ``` In order to set `temperature` of your conversation, which ranges from 0.0 to 1.0, use the following command: ```bash -smartloop project set --id=project_id --temp=0.3 +smartloop agent set --id=project_id --temp=0.3 ``` To enable memory to retain context in the conversation, use the following command: ```bash -smartloop project set --id=project_id --memory +smartloop agent set --id=project_id --memory ``` -To disable, use the following command: +To disable memory, use the following command: ```bash -smartloop project set --id=project_id --no-memory +smartloop agent set --id=project_id --no-memory ``` diff --git a/smartloop/__init__.py b/smartloop/__init__.py index df7fa1e..a872b4c 100644 --- a/smartloop/__init__.py +++ b/smartloop/__init__.py @@ -18,4 +18,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -__version__="1.2.2" +__version__="1.2.3" diff --git a/smartloop/app.py b/smartloop/app.py index 8dc3245..660bd46 100644 --- a/smartloop/app.py +++ b/smartloop/app.py @@ -17,7 +17,7 @@ from smartloop.constants import endpoint, homedir -from smartloop.cmd import Project +from smartloop.cmd import Agent from smartloop.utils import UserProfile from smartloop.services import Projects @@ -26,23 +26,23 @@ console = Console() app = typer.Typer() -app.add_typer(Project.app, name='project' , short_help= "Manage projects") +app.add_typer(Agent.app, name='agent' , short_help= "Manage agent(s)") def select_project() -> dict: profile = UserProfile.current_profile() projects = Projects(profile).get_all() # must have a project created earlier if len(projects) > 0: - return Project.select() + return Agent.select() - raise "No project has been created" + raise "No agent has been created" @app.command(short_help="Authenticate using a token from https://api.smartloop.ai/v1/redoc") def login(): Art = text2art('smartloop.') console.print(Art) - console.print('Please copy your access token using the link https://app.smartloop.ai/developer') + console.print('Please copy your access token using the link https://agent.smartloop.ai/developer') console.print('You will need to complete your authentication process to obtain / generate access token') token = getpass.getpass('Paste your token (Token will be invisible): ') @@ -56,12 +56,12 @@ def login(): current_profile = UserProfile.current_profile() Projects(current_profile).get_all() console.print('[green]Successfully logged in[/green]') - console.print('Next up explore [cyan]project[/cyan] or use [cyan]run[/cyan] to chat with a document') + console.print('Next up, create and [cyan]agent[/cyan] then use the [cyan]run[/cyan] command to start prompting') except: console.print('[red]Invalid login[/red]') -def chat_to_project(project_id: str): - user_input = input('Enter message (Ctrl-C to exit): ') +def chat_with_agent(project_id: str): + user_input = input('Enter prompt (Ctrl-C to exit):\n') url = posixpath.join(endpoint, project_id, 'messages') profile = UserProfile.current_profile() @@ -132,7 +132,7 @@ def _current_project() -> dict: return dict() -@app.command(short_help="Starts a chat session with a selected project") +@app.command(short_help="Starts a chat session with a selected agent") def run(): try: profile = UserProfile.current_profile() @@ -141,10 +141,15 @@ def run(): if 'project' in profile.keys(): project = profile['project'] - console.print(f"[green]Current project: [underline]{project.get('title')}({project['name']})[/green][/underline]") + display_name = f"{project.get('title')}({project['name']})" + dashes = "".join([ '-' for i in range(len(display_name))]) + + console.print(f"[cyan]{display_name}[/cyan]") + console.print(dashes) + # chat till the cancelled while True: - chat_to_project(project['id']) + chat_with_agent(project['id']) time.sleep(1) else: select_project() @@ -154,12 +159,12 @@ def run(): except Exception as ex: console.print(ex) -@app.command(short_help="Upload document for the current project") +@app.command(short_help="Upload document for the selected agent") def upload(path: Annotated[str, typer.Option(help="folder or file path")]): project = _current_project() # check for project id if 'id' in project: - Project.upload(project.get('id'), path) + Agent.upload(project.get('id'), path) @app.command(short_help="Find out which account you are logged in") diff --git a/smartloop/cmd/__init__.py b/smartloop/cmd/__init__.py index 5ce17c6..d2361b7 100644 --- a/smartloop/cmd/__init__.py +++ b/smartloop/cmd/__init__.py @@ -1 +1 @@ -from .project import Project +from .agent import Agent diff --git a/smartloop/cmd/project.py b/smartloop/cmd/agent.py similarity index 98% rename from smartloop/cmd/project.py rename to smartloop/cmd/agent.py index 53af0fd..c936429 100644 --- a/smartloop/cmd/project.py +++ b/smartloop/cmd/agent.py @@ -25,10 +25,10 @@ console = Console() -class Project: +class Agent: app = typer.Typer() - @app.command(short_help="Select a project") + @app.command(short_help="Select an agent") def select() -> dict: profile = UserProfile.current_profile() projects = Projects(profile).get_all() @@ -39,7 +39,7 @@ def select() -> dict: projects_list = [ inquirer.List( "project", - message="Select a project from the options below", + message="Select an agent from the options below", choices=_projects, ), ]