SharePoint
SharePoint サイトのドキュメントを、Squid AI agents の検索可能な knowledge としてインデックス化する
SharePoint connector の機能
SharePoint connector は、組織の SharePoint document libraries からドキュメントを knowledge base に読み込み、Squid AI agents がその内容を使用して質問に回答できるようにします。
- インデックス化するドキュメントまたはフォルダを選択します。フォルダをインデックス化すると、その中のすべてのファイルが再帰的にインデックス化されます。
- Squid はインデックス化されたコンテンツを自動的に同期し、変更、追加、削除されたファイルを 10 分ごとに取得します。
- SharePoint connector に接続された AI agents は、インデックス化されたコンテンツを semantic search し、インデックス化されたドキュメントを一覧表示できます。
- アクセスは read-only です。Squid が SharePoint サイトに書き込むことはありません。
Microsoft Entra app registration の作成
connector は、application permissions を持つ app registration を使用して認証します(ユーザーごとのサインインは不要です)。
-
Azure Portal で App registrations に移動し、New registration をクリックします。
-
作成後、Overview タブから Application (client) ID と Directory (tenant) ID を控えます。
-
Certificates & secrets で新しい client secret を作成し、その値を保存します。client secret には有効期限があり(デフォルトは 6 か月、最大 24 か月)、失効すると同期は通知なく停止します。追跡できる有効期限を選び、失効前に Squid Console で connector を新しい secret に更新してください。
-
API permissions で、サイトとファイルへの読み取りアクセスを付与する Microsoft Graph application permissions(
Sites.Read.AllとFiles.Read.All)を追加し、admin consent を付与します。
SharePoint connector を Squid application に追加する
-
Squid Console の Connectors タブに移動します。
-
Available Connectors をクリックします。
-
SharePoint connector を見つけて、Add Connector を選択します。
-
次の構成詳細を入力します。
Connector ID: コード内で connector を一意に識別する文字列です。これは後で変更できません。
Client ID: app registration の Application (client) ID です。
Tenant ID: app registration の Directory (tenant) ID です。
Client Secret: 作成した client secret です。これは Squid secret として安全に保存されます。
ドキュメントのインデックス化
ドキュメントは @squidcloud/sharepoint-client package を使用してプログラムでインデックス化します。ドキュメントまたはフォルダは、SharePoint の site ID、drive ID、item ID によって指定されます。
npm install @squidcloud/sharepoint-client
import { SharePointClient, encodeSharePointLocation } from '@squidcloud/sharepoint-client';
const sharepoint = new SharePointClient(squid, 'SHAREPOINT_CONNECTOR_ID');
// Index a document or an entire folder (recursive)
const errors = await sharepoint.indexDocumentOrFolder({
siteId: 'SITE_ID',
driveId: 'DRIVE_ID',
itemId: 'ITEM_ID',
});
// List everything that has been indexed
const documents = await sharepoint.listIndexedDocuments();
// Remove a document or folder from the index by its listed ID...
await sharepoint.unindexDocumentOrFolder(documents[0].id);
// ...or address it directly by encoding its location
await sharepoint.unindexDocumentOrFolder(encodeSharePointLocation('SITE_ID', 'DRIVE_ID', 'ITEM_ID'));
インデックス化されたドキュメントは、background sync によって自動的に最新の状態に保たれます。
SharePoint connector を AI agent で使用する
No-code Studio
-
Squid Console の Studio タブに移動します。
-
Create AI Agent をクリックします。
-
agent ID と description を入力します。例: "docs-agent" と "This agent answers questions using our SharePoint documents"。
-
Add Abilities をクリックし、Storage セクションまでスクロールして、先ほど作成した SharePoint connector を選択します。
-
agent がこの接続をどのように使用すべきかについて説明を入力します。例: "Call this when a user asks about content stored in SharePoint."
-
Test をクリックし、インデックス化されたドキュメントに関する質問を agent に試してみます。
Squid SDK の使用
Squid SDK で AI agent を作成している場合は、ask() function の connectedIntegrations option に追加することで SharePoint connector を接続します。
- TypeScript
- Python
await this.squid
.ai()
.agent('AGENT_ID')
.ask('What does our expense policy say about travel?', {
connectedIntegrations: [
{
integrationId: 'SHAREPOINT_CONNECTOR_ID',
integrationType: 'sharepoint',
description: 'Call this connector to search our SharePoint documents',
},
],
});
await squid.ai().agent('AGENT_ID').ask(
'What does our expense policy say about travel?',
options={
'connectedIntegrations': [
{
'integrationId': 'SHAREPOINT_CONNECTOR_ID',
'integrationType': 'sharepoint',
'description': 'Call this connector to search our SharePoint documents',
}
]
},
)