技能 人工智能 Glean企业搜索与聊天工作流

Glean企业搜索与聊天工作流

v20260423
glean-core-workflow-a
本工作流展示了使用Glean客户端API构建企业级知识助手的核心流程。它涵盖了带有过滤器和分面的全文本搜索、AI驱动的聊天问答系统,以及自动补全建议。适用于将深度搜索和对话式AI功能集成到企业内部应用。
获取技能
470 次下载
概览

Glean Core Workflow A: Search & Chat

Overview

Build search and chat experiences using the Glean Client API. Covers full-text search with filters, AI-powered chat answers, and autocomplete suggestions.

Instructions

Step 1: Search with Filters and Facets

const results = await fetch(`${GLEAN}/client/v1/search`, {
  method: 'POST', headers: searchHeaders,
  body: JSON.stringify({
    query: 'kubernetes deployment best practices',
    pageSize: 20,
    requestOptions: {
      datasourceFilter: 'confluence,github',
      facetFilters: [{ fieldName: 'author', values: ['engineering-team'] }],
    },
  }),
}).then(r => r.json());

results.results?.forEach((r: any) => {
  console.log(`[${r.datasource}] ${r.title}`);
  console.log(`  ${r.snippets?.[0]?.snippet ?? ''}`);
});

Step 2: AI Chat (Glean Assistant)

const chatResponse = await fetch(`${GLEAN}/client/v1/chat`, {
  method: 'POST', headers: searchHeaders,
  body: JSON.stringify({
    messages: [{ role: 'USER', content: 'What is our deployment process for production?' }],
    applicationId: 'my-app',
  }),
}).then(r => r.json());

console.log('Answer:', chatResponse.messages?.[0]?.content);
console.log('Sources:', chatResponse.citations?.map((c: any) => c.title).join(', '));

Step 3: Autocomplete / Suggestions

const suggestions = await fetch(`${GLEAN}/client/v1/autocomplete`, {
  method: 'POST', headers: searchHeaders,
  body: JSON.stringify({ query: 'deploy', datasourceFilter: 'confluence' }),
}).then(r => r.json());

suggestions.results?.forEach((s: any) => console.log(`  ${s.text}`));

Error Handling

ErrorCauseSolution
Empty resultsQuery too specific or datasource not indexedBroaden query, check datasource status
Chat returns no citationsContent not indexed for chatVerify documents have body text
403 on searchUser permissionsEnsure token has search scope

Resources

Next Steps

For bulk indexing workflow, see glean-core-workflow-b.

信息
分类 人工智能
名称 glean-core-workflow-a
版本 v20260423
大小 2.7KB
更新时间 2026-04-28
语言