Skip to content

Commit

Permalink
Wording and order updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bszwarc committed Nov 5, 2024
1 parent 4ad31ee commit 6c60b48
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The `items` array can have exactly one element.
This example shows you how to extract metadata from a sample invoice in a structured way.
Let's assume you want to extract the vendor name, invoice number, and a few more details.

![sample invoice](./images/sample-invoice.png)
![sample invoice](../images/sample-invoice.png)

### Create the request

Expand Down
70 changes: 35 additions & 35 deletions content/guides/box-ai/ai-tutorials/extract-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,38 @@ To get the response from Box AI, call `POST /2.0/ai/extract` endpoint with the f

Depending on the use case and the level of detail, you can construct various prompts.

#### Use keywords
#### Use plain text

Because this endpoint allows freeform prompts, you can use plain text to get the information.

```bash
curl --location 'https://api.box.com/2.0/ai/extract' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--data '{
"prompt": "find the document type (invoice or po), vendor, total, and po number",
"items": [
{
"type": "file",
"id": "1443721424754"
}
]
}'
```

In such a case, the response will be based on the keywords included in the text:

```bash
{
"answer": "{\"Document Type\": \"Invoice\", \"Vendor\": \"Quasar Innovations\", \"Total\": \"$1,050\", \"PO Number\": \"003\"}",
"created_at": "2024-05-31T10:30:51.223-07:00",
"completion_reason": "done"
}
```

#### Use specific terms

The prompt can include a list of keywords that you expect to find in an invoice:
If you don't want to write the entire sentence, the prompt can consist of terms that you expect to find in an invoice:

```bash
curl --location 'https://api.box.com/2.0/ai/extract' \
Expand All @@ -82,7 +111,7 @@ The prompt can include a list of keywords that you expect to find in an invoice:
}'
```

Using this approach results in a list of keywords provided in the request and their values:
Using this approach results in a list of terms provided in the request and their values:

```bash
{
Expand All @@ -92,9 +121,9 @@ Using this approach results in a list of keywords provided in the request and th
}
```

### Using key-value pairs
#### Use key-value pairs

The prompt can be a list of key-value pairs that helps Box AI to come up with the metadata structure:
The prompt can also be a list of key-value pairs that helps Box AI to come up with the metadata structure. This approach requires listing the key-value pairs within a `fields` array.

```bash
curl --location 'https://api.box.com/2.0/ai/extract' \
Expand All @@ -111,7 +140,7 @@ curl --location 'https://api.box.com/2.0/ai/extract' \
}'
```

The response includes the fields present in the file, along with their values:
The response includes the `fields` present in the file, along with their values:

```bash
{
Expand All @@ -121,35 +150,6 @@ The response includes the fields present in the file, along with their values:
}
```

#### Use plain text

You can also use plain text:

```bash
curl --location 'https://api.box.com/2.0/ai/extract' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--data '{
"prompt": "find the document type (invoice or po), vendor, total, and po number",
"items": [
{
"type": "file",
"id": "1443721424754"
}
]
}'
```

In such a case, the response will be based on the keywords included in the query:

```bash
{
"answer": "{\"Document Type\": \"Invoice\", \"Vendor\": \"Quasar Innovations\", \"Total\": \"$1,050\", \"PO Number\": \"003\"}",
"created_at": "2024-05-31T10:30:51.223-07:00",
"completion_reason": "done"
}
```

[prereq]: g://box-ai/ai-tutorials/prerequisites
[agent]: e://get_ai_agent_default
[model-param]: r://ai_agent_text_gen#param_basic_gen_model
Expand Down
4 changes: 2 additions & 2 deletions content/guides/box-ai/ai-tutorials/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ To add a scope:
2. Go to **Configuration** > **Application Scopes** > **Content Actions**
3. Select the **Manage AI** scope. Box Platform will automatically include the scope when making the call. If you are added as an collaborator for a given app, but do not have Box AI API access, you will see the **Manage AI** scope checked and grayed out. This means the app owner has the AI scope enabled but you cannot change this setting.

![box ai scopes](./images/box-ai-app-scopes.png)
![box ai scopes](../images/box-ai-app-scopes.png)

4. Submit your app for [authorization or enablement][authorization]. If you want to enable Box AI API for an existing application, you must [re-authorize][reauthorization] it.

Expand All @@ -66,7 +66,7 @@ To generate a token:
2. Click the **Options menu** button (…) on the right.
3. Select **Generate Developer Token**. The token will be automatically generated and saved to clipboard.

![generate token](./images/developer-token.png)
![generate token](../images/developer-token.png)

You can also open your app, go to
**Configuration** > **Developer Token**
Expand Down

0 comments on commit 6c60b48

Please sign in to comment.