Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
{
"title": "AI_CLASSIFY",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## Description

Used to classify text into a specified set of labels.

## Syntax

```sql
AI_CLASSIFY([<resource_name>], <text>, <labels>)
```

## Parameters

| Parameter | Description |
| ----------------- | ------------------------------------------- |
| `<resource_name>` | The specified resource name, optional |
| `<text>` | The text to be classified |
| `<labels>` | Array of classification labels |

## Return Value

Returns the single label that best matches the text.

If any input is NULL, returns NULL.

The result is generated by a large language model, so the output may vary.

## Examples

```sql
SET default_ai_resource = 'resource_name';
SELECT AI_CLASSIFY('Apache Doris is a databases system.', ['useage', 'introduce']) AS Result;
```
```text
+-----------+
| Result |
+-----------+
| introduce |
+-----------+
```

```sql
SELECT AI_CLASSIFY('resource_name', 'Apache Doris is developing rapidly.', ['science', 'sport']) AS Result;
```
```text
+---------+
| Result |
+---------+
| science |
+---------+
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
{
"title": "AI_EXTRACT",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## Description

Used to extract information corresponding to specific labels from text.

## Syntax

```sql
AI_EXTRACT([<resource_name>], <text>, <labels>)
```

## Parameters

| Parameter | Description |
| ----------------- | -------------------------------------------- |
| `<resource_name>` | The specified resource name, optional |
| `<text>` | The text from which to extract information |
| `<labels>` | Array of labels to extract |

## Return Value

Returns a string containing all extracted labels and their corresponding values.

If any input is NULL, returns NULL.

The result is generated by a large language model, so the output may vary.

## Examples

```sql
SET default_ai_resource = 'resource_name';
SELECT AI_EXTRACT('Apache Doris is an MPP-based real-time data warehouse known for its high query speed.',
['product_name', 'architecture', 'key_feature']) AS Result;
```
```text
+---------------------------------------------------------------------------------------+
| Result |
+---------------------------------------------------------------------------------------+
| product_name="Apache Doris", architecture="MPP-based", key_feature="high query speed" |
+---------------------------------------------------------------------------------------+
```

```sql
SELECT AI_EXTRACT('resource_name', 'Apache Doris began in 2008 as an internal project named Palo.',
['original name', 'founding time']) AS Result;
```
```text
+----------------------------------------+
| Result |
+----------------------------------------+
| original name=Palo, founding time=2008 |
+----------------------------------------+
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
{
"title": "AI_FILTER",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## Description

Filters text based on given conditions.

## Syntax

```sql
AI_FILTER([<resource_name>], <text>)
```

## Parameters

| Parameter | Description |
|-------------------|-----------------------------------|
| `<resource_name>` | The specified resource name, optional |
| `<text>` | The information to be evaluated |

## Return Value

Returns a boolean value.

If any input is NULL, returns NULL.

The result is generated by the large language model, so the output may not be fixed.

## Example

Suppose you have the following table representing comments received by a courier company:
```sql
CREATE TABLE user_comments (
id INT,
comment VARCHAR(500)
) DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 10
PROPERTIES (
"replication_num" = "1"
);
```

If you want to query the positive comments, you can use:
```sql
SELECT id, comment FROM user_comments
WHERE AI_FILTER('resource_name', CONCAT('This is a positive comment: ', comment));
```

The result may look like:
```text
+------+--------------------------------------------+
| id | comment |
+------+--------------------------------------------+
| 1 | Absolutely fantastic, highly recommend it. |
| 3 | This product is amazing and I love it. |
+------+--------------------------------------------+
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
{
"title": "AI_FIXGRAMMAR",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## Description

Used to correct grammatical errors in text.

## Syntax

```sql
AI_FIXGRAMMAR([<resource_name>], <text>)
```

## Parameters

| Parameter | Description |
| ----------------- | ------------------------------------------- |
| `<resource_name>` | The specified resource name, optional |
| `<text>` | The text to be grammar-corrected |

## Return Value

Returns the text string after grammar correction.

If any input is NULL, returns NULL.

The result is generated by a large language model, so the output may vary.

## Examples

```sql
SET default_ai_resource = 'resource_name';
SELECT AI_FIXGRAMMAR('Apache Doris a great system DB') AS Result;
```
```text
+------------------------------------------+
| Result |
+------------------------------------------+
| Apache Doris is a great database system. |
+------------------------------------------+
```

```sql
SELECT AI_FIXGRAMMAR('resource_name', 'I am like to using Doris') AS Result;
```
```text
+--------------------+
| Result |
+--------------------+
| I like using Doris |
+--------------------+
```
Loading