* Fetches tag definitions from knowledge base
(knowledgeBaseId: string)
| 96 | * Fetches tag definitions from knowledge base |
| 97 | */ |
| 98 | async function fetchTagDefinitions(knowledgeBaseId: string): Promise<TagDefinition[]> { |
| 99 | try { |
| 100 | const { buildAuthHeaders, buildAPIUrl } = await import('@/executor/utils/http') |
| 101 | |
| 102 | const headers = await buildAuthHeaders() |
| 103 | const url = buildAPIUrl(`/api/knowledge/${knowledgeBaseId}/tag-definitions`) |
| 104 | |
| 105 | logger.info(`Fetching tag definitions for KB ${knowledgeBaseId} from ${url.toString()}`) |
| 106 | |
| 107 | const response = await fetch(url.toString(), { headers }) |
| 108 | if (!response.ok) { |
| 109 | logger.warn(`Failed to fetch tag definitions for KB ${knowledgeBaseId}: ${response.status}`) |
| 110 | return [] |
| 111 | } |
| 112 | |
| 113 | const result = await response.json() |
| 114 | const tagDefinitions = result.data || [] |
| 115 | logger.info(`Found ${tagDefinitions.length} tag definitions for KB ${knowledgeBaseId}`) |
| 116 | return tagDefinitions |
| 117 | } catch (error) { |
| 118 | logger.error('Failed to fetch tag definitions:', error) |
| 119 | return [] |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Fetches KB tag definitions and builds a schema for LLM consumption. |
no test coverage detected