-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve documentation * Update docs/05-search.md Co-authored-by: Ferran Llamas <[email protected]> --------- Co-authored-by: Ferran Llamas <[email protected]>
- Loading branch information
Showing
14 changed files
with
540 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
## 1.1.18 (unreleased) | ||
|
||
|
||
- Nothing changed yet. | ||
- Improve documentation. | ||
|
||
|
||
## 1.1.17 (2023-11-02) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,41 @@ | ||
# Nuclia CLI/SDK | ||
|
||
This SDK/CLI is designed to facilitate use of the Nuclia API. | ||
This Nuclia SDK/CLI is designed to facilitate use of the Nuclia API. | ||
|
||
There are two developer experiences: | ||
|
||
- CLI: by using the cli `nuclia` you can interact with Nuclia via command line | ||
- SDK: Using python you can replicate each command using the same structure | ||
- SDK: allows to write simple Python scripts to interact with Nuclia | ||
|
||
## Installation | ||
|
||
It requires Python (≥3.8) and can be installed with: | ||
|
||
```sh | ||
pip install nuclia | ||
``` | ||
|
||
## Getting started | ||
## Upgrades | ||
|
||
To know your current version: | ||
|
||
```sh | ||
pip show nuclia | ||
``` | ||
|
||
To upgrade to the latest version: | ||
|
||
```sh | ||
pip install nuclia --upgrade | ||
``` | ||
|
||
First steps should be: | ||
## Usage | ||
|
||
- [Authentication](02-auth.md) | ||
- [Setting KnowledgeBox or NUA key](03-default.md). | ||
|
||
## Use Cases | ||
|
||
- [Upload files](04-upload.md) | ||
- [Upload url](04-upload.md) | ||
- [Upload text](04-upload.md) | ||
- [Upload conversation](07-conversation.md) | ||
- [Search](06-search.md) | ||
- [Extract information from a file](05-extract.md) | ||
- [Import/export knowledge boxes](08-import-export.md) | ||
- Detect Entities | ||
- [Get embedding from text](05-extract.md) | ||
- Get answer from a context | ||
- [Access a Knowledge Box](03-kb.md) | ||
- [Upload contents](04-upload.md) | ||
- [Search and answer generation](05-search.md) | ||
- [Read extracted data](06-read.md) | ||
- [Work with a NUA key](07-nua.md) | ||
- [Import/export a Knowledge Box](08-import-export.md) | ||
- [Manage Knowledge Box configuration & labels](09-manage.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# Access a Knowledge Box | ||
|
||
## Define the default Knowledge Box | ||
|
||
- When using user authentication, you can list all the kbs who have access to: | ||
|
||
- CLI: | ||
```sh | ||
nuclia kbs list | ||
``` | ||
- SDK: | ||
```python | ||
from nuclia import sdk | ||
kbs = sdk.NucliaKBS() | ||
kbs.list() | ||
``` | ||
|
||
And you can set the Knowledge Box you want to work with as your default: | ||
|
||
- CLI: | ||
```sh | ||
nuclia kbs default [KB_ID] | ||
``` | ||
- SDK: | ||
```python | ||
from nuclia import sdk | ||
kbs = sdk.NucliaKBS() | ||
kbs.default(KB_ID) | ||
``` | ||
|
||
- When using an API key, the corresponding Knowledge Box is set as default automatically. | ||
|
||
## List resources | ||
|
||
You can get the list of resources in a Knowledge Box: | ||
|
||
- CLI: | ||
```sh | ||
nuclia kb list | ||
``` | ||
- SDK: | ||
```python | ||
from nuclia import sdk | ||
kb = sdk.NucliaKB() | ||
resources = kb.list() | ||
``` | ||
|
||
## Create a resource | ||
|
||
You can create a resource in a Knowledge Box, setting all the resource metadata, like: | ||
|
||
- `slug`: the slug of the resource | ||
- `title`: the title of the resource | ||
- `summary`: the summary of the resource (if not set, Nuclia will generate it) | ||
- `icon`: the mimetype you want to assign to the resource (by default, Nuclia will assign the mimetype corresponding to the first field added in the resource) | ||
- `metadata`: | ||
- `origin`: the origin metadata of the resource | ||
See [API documenattion](https://docs.nuclia.dev/docs/api#tag/Resources/operation/Create_Resource_kb__kbid__resources_post) | ||
- `usermetadata`: User metadata, mostly used to set labels on the resource | ||
See [API documenattion](https://docs.nuclia.dev/docs/api#tag/Resources/operation/Create_Resource_kb__kbid__resources_post) | ||
- `fieldmetadata`: Field metadata | ||
See [API documenattion](https://docs.nuclia.dev/docs/api#tag/Resources/operation/Create_Resource_kb__kbid__resources_post) | ||
- `origin`: Origin metadata | ||
See [API documenattion](https://docs.nuclia.dev/docs/api#tag/Resources/operation/Create_Resource_kb__kbid__resources_post) | ||
- `extra`: user-defined metadata | ||
|
||
You can also set the contents of the resource, as fields: | ||
|
||
- Text fields in `texts` | ||
- Link fields in `links` | ||
- Conversation fields in `conversations` | ||
|
||
Note: you cannot set File fields when creating a resource, you need to use the [`upload` command](./04-upload.md). | ||
|
||
Examples: | ||
|
||
- CLI: | ||
|
||
```sh | ||
nuclia kb resource create --slug=my-resource | ||
nuclia kb resource create --origin='{"collaborators":["THE_AUTHOR"]}' --usermetadata='{"classifications": [{"labelset": "SOME_CATEGORY", "label": "SOME_VALUE"}]}' | ||
nuclia kb resource create --texts='{"chapter-1": {"body": "here is a test", "format": "PLAIN"}' | ||
``` | ||
|
||
IMPORTANT: when using the CLI on Windows, you need to escape the double quotes in the JSON strings, like: | ||
|
||
```sh | ||
nuclia kb resource create --origin="{\"collaborators\":[\"THE_AUTHOR\"]}" --usermetadata="{\"classifications\": [{\"labelset\": \"SOME_CATEGORY\", \"label\": \"SOME_VALUE\"}]}" | ||
``` | ||
|
||
- SDK: | ||
|
||
```python | ||
from nuclia import sdk | ||
res = sdk.NucliaResource() | ||
res.create( | ||
slug="my-resource", | ||
usermetadata={ | ||
"classifications": [ | ||
{"labelset": "subjects", "label": "<Topic 1>"}, | ||
{"labelset": "subjects", "label": "<Topic 2>"}, | ||
], | ||
}, | ||
texts={"chapter-1": {"body": "here is a test", "format": "PLAIN"}}, | ||
) | ||
``` | ||
|
||
## Delete a resource on a kb | ||
|
||
The existing resource can be identified by its unique id `rid` or its `slug`. | ||
|
||
- CLI: | ||
|
||
```bash | ||
nuclia kb resource delete --rid=RID | ||
nuclia kb resource delete --slug=slug | ||
``` | ||
|
||
- SDK: | ||
```python | ||
from nuclia import sdk | ||
resource = sdk.NucliaResource() | ||
resource.delete(rid=RID) | ||
``` | ||
|
||
## Modify a resource | ||
|
||
The existing resource can be identified by its unique id `rid` or its `slug`. | ||
|
||
- CLI: | ||
|
||
```bash | ||
nuclia kb resource update --rid=RID --origin="{\"collaborators\":[\"AUTHOR_1\",\"AUTHOR_2\"]}" | ||
nuclia kb resource update --slug=slug --texts='{"chapter-1": {"body": "new chapter content", "format": "PLAIN"}' | ||
``` | ||
|
||
- SDK: | ||
|
||
```python | ||
from nuclia import sdk | ||
res = sdk.NucliaResource() | ||
res.create( | ||
slug="my-resource", | ||
usermetadata={ | ||
"classifications": [ | ||
{"labelset": "subjects", "label": "<Topic 1>"}, | ||
{"labelset": "subjects", "label": "<Topic 3>"}, | ||
], | ||
}, | ||
) | ||
``` |
Oops, something went wrong.