Skip to content

Commit

Permalink
DEV-60: Moving Project to Agent (#3)
Browse files Browse the repository at this point in the history
* updated references for project => agent

* missing file

* minor fixes
  • Loading branch information
mehfuzh authored Feb 9, 2025
1 parent 0b8e767 commit 7393661
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 37 deletions.
61 changes: 42 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,57 +22,80 @@ 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:

```bash
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
```

## 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:
Expand All @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion smartloop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
31 changes: 18 additions & 13 deletions smartloop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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): ')
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion smartloop/cmd/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .project import Project
from .agent import Agent
6 changes: 3 additions & 3 deletions smartloop/cmd/project.py → smartloop/cmd/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand 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,
),
]
Expand Down

0 comments on commit 7393661

Please sign in to comment.