Skip to content

Commit

Permalink
doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
mehfuzh committed Jul 30, 2024
1 parent ca0c9c4 commit 910ef50
Show file tree
Hide file tree
Showing 12 changed files with 520 additions and 32 deletions.
17 changes: 17 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MIT License
Copyright (c) 2024 Smartloop Inc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
142 changes: 140 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,141 @@
# Documentum Command line interface
# Smartloop Command Line Interface

Smartloop CLI to upload, managed and chat with documents fine-tuned using foundational LLM models. It uses the smartloop API to manage projects and documents and gives you the power to quickly process contents using LLM and reason based on them

## Requirements

- Python 3.11

## Getting Started

Install the CLI with the following command:

```
pip install -U smartloop-cli
```
Once installed, check that everything is setup correclty:


```
$ smartloop-cli --help
Usage: main.py [OPTIONS] COMMAND [ARGS]...
│ login Login using a token from https://api.smartloop.ai/v1/redoc │
│ project │
│ run Starts a chat session with a selected project │
│ upload Upload documents for a slected project │
│ whoami Find out which account you are logged in
```

## Creating Account

First create an account using the `curl` command below, in Linux / macOS / WSL 2.0 / Ubuntu:


```
curl --location --request PUT 'https://api.smartloop.ai/v1/users' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
"email": "<string>",
"password": "<string>",
"name": "<string>"
}'
```

You will receive an email with the `token` that is needed to login into the CLI.

## Setting up the CLI

Login to the CLI in the follwoing way using the token recevied in email:

```
smartloop-cli login
```

This command will prompt you for your token, copy and pase the token that you have recevied in your email

```
$ python main.py login
_ _
___ _ __ __ _ _ _ | |_ | | ___ ___ _ __
(_-<| ' \ / _` || '_|| _|| |/ _ \/ _ \| '_ \ _
/__/|_|_|_|\__,_||_| \__||_|\___/\___/| .__/(_)
|_|
You can generatate your token from /users/token endpoint
Enter your token (Token will be invisitble):
```


Next step it to create a project, you can do so with the following command:

```
smartloop-cli project create --name Lexic
```

## Upload Document

Once the project is created , 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

```
smartloop-cli upload --path=~/OnlineSvcsConsolidatedSLA\(WW\)\(English\)\(June2024\)\(CR\).docx
```

## Run It

Finally, once the document is uploaded and processed, run the CLI to query:

```
smartloop-cli run
```

This will bring up the following interface:

```
$ smartloop-cli run
Current project: Microsoft(microsoft-24-07-2024)
Enter message (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:
"Uptime Percentage"
* Service Credit:
+ < 99.9%: 10%
+ < 99%: 25%
+ < 95%: 100%
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):
```


In order to switch a default project, use the following command:

```
smartloop-cli project select
```


## Contributing

Contributions are welcome! Please create a pull request with your changes.


## Contact

If you have any questions or suggestions, please feel free to reach out to hello@smartloop.ai


## References

* [Smartloop API Documentation](https://api.smartloop.ai/v1/redoc)

Handy tool to chat with documentum platform
1 change: 1 addition & 0 deletions apps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .project import Project
83 changes: 83 additions & 0 deletions apps/project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from typing import Annotated
import typer
import requests
import posixpath
import os
import re
import json

import inquirer
from inquirer.themes import GreenPassion

from services import Projects
from constants import endpoint
from utils import UserProfile

from rich.console import Console

console = Console()

class Project:
app = typer.Typer()

@app.command(short_help="Select a project")
def select() -> dict:
profile = UserProfile.load()
projects = Projects(profile).get_all()
_projects = [f"{proj['title']}({proj['name']})" for proj in projects]

projects_list = [
inquirer.List(
"project",
message="Select a project from the options below",
choices=_projects,
),
]
answer = inquirer.prompt(projects_list, theme=GreenPassion())
name = re.findall('\(([^)]+)\)', answer['project'])[0]

selected = [project for project in projects if project.get('name') == name][0]

profile['project'] = selected

UserProfile.save(profile)

console.print(f"Default project set to: [underline]{selected['name']}[/underline]")

return selected

@app.command(short_help="List all projects")
def list():
profile = UserProfile.load()
project = profile.get('project', None)
projects = Projects(profile).get_all()
_ = [
console.print(f"{ '*' if project is not None and proj['id'] == project['id']else ' '} {proj['title']}({proj['name']})")
for proj in projects
]


@app.command(short_help="Create a new project")
def create(name: Annotated[str, typer.Option(help="The name of the project")]):
url = posixpath.join(endpoint, 'projects')
profile = UserProfile.load()
try:
resp = requests.put(url, headers={'x-api-key': profile['token']}, json=dict(title=name))
resp.raise_for_status()

print("Project created successfully")
except Exception as ex:
print(ex)

@app.command(short_help="Set the default project")
def set(id: Annotated[str, typer.Option(help="project Id to use")]):
profile = UserProfile.load()
projects = Projects(profile).get_all()
project = [project for project in projects if project.get('id') == id]

if len(project) > 0:
profile['project'] = project[0]
console.print(f"{project[0]['title']} as set as default project")
UserProfile.save(profile)
else:
console.print("No project found")
4 changes: 4 additions & 0 deletions constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

endpoint= os.getenv('BASE_URL', 'https://api.smartloop.ai/v1')
homedir = os.getenv('SLP_HOME', os.path.expanduser('~/.slp'))
Loading

0 comments on commit 910ef50

Please sign in to comment.