feat: implement service management API for VLM control

- Add /api/v1/mbe/health endpoint for status checks
- Add /api/v2/service/start to start llama-server
- Add /api/v2/service/stop to stop llama-server
- Use TCP connection test for port detection (more reliable than lsof)
- Add ps aux fallback for PID detection
- Implement structured bilingual VLM tags
- Add VLM integration documentation for Studio team

Endpoints tested and working with Momentry Studio AdminView UI.
This commit is contained in:
Accusys
2026-10-24 02:37:53 +08:00
parent d14cd9f3de
commit c151b49334
33 changed files with 3175 additions and 229 deletions
@@ -0,0 +1,930 @@
---
title: VLM API Integration Guide
version: "1.0"
date: 2026-10-23
author: Core Team
status: active
---
# VLM API Integration Guide
## Overview
This guide explains how the Studio team can retrieve Vision Language Model (VLM) scene analysis data from Momentry Core API. VLM provides automated scene understanding including descriptions, objects detection, and searchable tags in multiple languages.
## Key Features
- **Bilingual Scene Tags**: Structured tags with both English and localized versions
- **Scene Descriptions**: Automatic English description with translation
- **Object Detection**: Key objects identified in each scene
- **Search Integration**: Tags optimized for scene search functionality
## API Endpoints
### 1. Get Scene Profile
Retrieve complete scene analysis for a video file.
```http
GET /api/v1/file/{file_uuid}/scenes
```
**Response:**
```json
{
"version": "1.0",
"file_uuid": "9c77a341a1194167e8ff6a06816f1ff6",
"total_scenes": 1,
"status": "ready",
"scenes": [
{
"index": 0,
"filename": "scene_000.jpg",
"timestamp_sec": 1.5,
"frame_number": 45,
"vlm_status": "completed",
"vlm_description": "A smartphone is propped up on a green cushion...",
"vlm_description_localized": "デスクの上の緑色のクッションに...",
"vlm_objects": ["smartphone", "mechanical keyboard", "yellow figurine"],
"vlm_tags": [
{
"en": "smartphone",
"local": "スマートフォン"
},
{
"en": "desk setup",
"local": "デスクセットアップ"
}
]
}
]
}
```
### 2. Get Scene Thumbnail
Retrieve the actual scene image file.
```http
GET /api/v1/file/{file_uuid}/scenes/{filename}
```
Example:
```http
GET /api/v1/file/9c77a341a1194167e8ff6a06816f1ff6/scenes/scene_000.jpg
```
Returns: `image/jpeg`
### 3. Search Scenes by Tags
Search for scenes matching specific tags.
```http
POST /api/v1/search/vlm/scenes
Content-Type: application/json
```
**Request Body:**
```json
{
"query": "smartphone",
"filters": {
"vlm_tags": ["smartphone", "indoor"]
},
"page": 1,
"page_size": 20,
"min_score": 0.7
}
```
**Response:**
```json
{
"results": [
{
"file_uuid": "9c77a341a1194167e8ff6a06816f1ff6",
"file_name": "004.mp4",
"scene_index": 0,
"timestamp_sec": 1.5,
"thumbnail_url": "/api/v1/file/9c77a341a1194167e8ff6a06816f1ff6/scenes/scene_000.jpg",
"vlm_description": "A smartphone is propped up...",
"vlm_description_localized": "デスクの上の緑色のクッションに...",
"vlm_tags": [
{
"en": "smartphone",
"local": "スマートフォン"
}
],
"score": 0.95
}
],
"total": 1,
"page": 1,
"page_size": 20
}
```
## Data Structures
### TypeScript Types (Shared)
Create a shared types file for your Vue 3 project:
**`src/types/vlm.ts`:**
```typescript
export interface VlmTag {
en: string; // English tag
local: string; // Localized tag
}
export interface Scene {
index: number;
filename: string;
timestamp_sec: number;
frame_number: number;
vlm_status: 'pending' | 'processing' | 'completed' | 'failed';
vlm_description: string;
vlm_description_localized: string | null;
vlm_objects: string[];
vlm_tags: VlmTag[];
}
export interface SceneSearchResult {
file_uuid: string;
file_name: string;
scene_index: number;
timestamp_sec: number;
thumbnail_url: string;
vlm_description: string;
vlm_description_localized: string | null;
vlm_tags: VlmTag[];
score: number;
}
```
**Examples:**
- Japanese (`ja`): `{ "en": "smartphone", "local": "スマートフォン" }`
- Traditional Chinese (`zh-TW`): `{ "en": "smartphone", "local": "智慧型手機" }`
- English (`en`): `{ "en": "smartphone", "local": "smartphone" }`
### Tag Categories
VLM tags prioritize search-relevant terms:
1. **Environment type**: `indoor`, `outdoor`, `city street`, `resort`, `nature`
2. **Key objects**: `smartphone`, `mechanical keyboard`, `Ferris wheel`
3. **Scene characteristics**: `aerial view`, `desk setup`, `tech accessories`
4. **Activities**: `driving`, `walking`, `static scene`
## Usage Examples
### Vue 3 + Tauri
```vue
<template>
<div class="scene-tags">
<h3>Scene {{ scene?.index }}</h3>
<div v-if="loading">Loading scene analysis...</div>
<div v-else-if="scene?.vlm_status === 'completed'">
<p class="description">
{{ scene.vlm_description_localized || scene.vlm_description }}
</p>
<div class="tags">
<span
v-for="(tag, i) in scene.vlm_tags"
:key="i"
class="tag"
>
{{ tag.local }}
</span>
</div>
<div class="objects">
<strong>Objects:</strong>
{{ scene.vlm_objects.join(', ') }}
</div>
</div>
<div v-else-if="scene?.vlm_status === 'failed'" class="error">
Scene analysis failed
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue';
interface VlmTag {
en: string;
local: string;
}
interface Scene {
index: number;
filename: string;
timestamp_sec: number;
vlm_status: string;
vlm_description: string;
vlm_description_localized: string | null;
vlm_objects: string[];
vlm_tags: VlmTag[];
}
const props = defineProps<{
fileUuid: string;
sceneIndex: number;
}>();
const scene = ref<Scene | null>(null);
const loading = ref(true);
const fetchScene = async () => {
loading.value = true;
try {
// Option 1: Direct HTTP call (recommended)
const response = await fetch(
`http://localhost:3002/api/v1/file/${props.fileUuid}/scenes`,
{
headers: {
'X-API-Key': 'YOUR_API_KEY'
}
}
);
const data = await response.json();
scene.value = data.scenes.find(
(s: Scene) => s.index === props.sceneIndex
);
// Option 2: Via Tauri backend
// import { invoke } from '@tauri-apps/api/tauri';
// scene.value = await invoke('get_scene', {
// fileUuid: props.fileUuid,
// sceneIndex: props.sceneIndex
// });
} catch (error) {
console.error('Failed to fetch scene:', error);
} finally {
loading.value = false;
}
};
onMounted(fetchScene);
watch(() => props.fileUuid, fetchScene);
</script>
<style scoped>
.tags {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.tag {
background: #e2e8f0;
padding: 0.25rem 0.5rem;
border-radius: 0.25rem;
font-size: 0.875rem;
}
</style>
```
### Tauri Backend Integration (Optional)
If you prefer to route API calls through Tauri backend:
**Rust side (`src-tauri/src/main.rs`):**
```rust
use tauri::command;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct VlmTag {
pub en: String,
pub local: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Scene {
pub index: usize,
pub vlm_status: String,
pub vlm_description: String,
pub vlm_description_localized: Option<String>,
pub vlm_objects: Vec<String>,
pub vlm_tags: Vec<VlmTag>,
}
#[command]
async fn get_scene(file_uuid: String, scene_index: usize) -> Result<Scene, String> {
let url = format!(
"http://localhost:3002/api/v1/file/{}/scenes",
file_uuid
);
let response = reqwest::get(&url)
.await
.map_err(|e| e.to_string())?;
let data: serde_json::Value = response
.json()
.await
.map_err(|e| e.to_string())?;
let scene = data["scenes"]
.as_array()
.and_then(|scenes| scenes.get(scene_index))
.ok_or("Scene not found")?;
let scene: Scene = serde_json::from_value(scene.clone())
.map_err(|e| e.to_string())?;
Ok(scene)
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![get_scene])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
```
**Vue 3 side:**
```vue
<script setup lang="ts">
import { invoke } from '@tauri-apps/api/tauri';
import type { Scene } from './types';
const fetchScene = async () => {
try {
scene.value = await invoke<Scene>('get_scene', {
fileUuid: props.fileUuid,
sceneIndex: props.sceneIndex
});
} catch (error) {
console.error('Failed to fetch scene via Tauri:', error);
}
};
</script>
```
### Search Integration
```vue
<template>
<div class="scene-search">
<input
v-model="searchQuery"
@keyup.enter="searchScenes"
placeholder="Search scenes..."
/>
<div v-if="loading">Searching...</div>
<div v-else class="results">
<div
v-for="result in results"
:key="result.file_uuid + result.scene_index"
class="result-item"
>
<img :src="result.thumbnail_url" />
<div class="info">
<p>{{ result.vlm_description }}</p>
<div class="tags">
<span
v-for="tag in result.vlm_tags"
:key="tag.en"
class="tag"
>
{{ tag.local }}
</span>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
interface SearchResult {
file_uuid: string;
file_name: string;
scene_index: number;
thumbnail_url: string;
vlm_description: string;
vlm_tags: Array<{ en: string; local: string }>;
score: number;
}
const searchQuery = ref('');
const results = ref<SearchResult[]>([]);
const loading = ref(false);
const searchScenes = async () => {
if (!searchQuery.value.trim()) return;
loading.value = true;
try {
const response = await fetch('http://localhost:3002/api/v1/search/vlm/scenes', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY'
},
body: JSON.stringify({
query: searchQuery.value,
page_size: 20
})
});
const data = await response.json();
results.value = data.results;
} catch (error) {
console.error('Search failed:', error);
} finally {
loading.value = false;
}
};
</script>
```
## Localization Support
### Supported Languages
The `local` field in tags uses the language configured in `admin_config.search.vlm_output_language`:
| Language Code | Display Name |
|---------------|--------------|
| `en` | English |
| `ja` | 日本語 (Japanese) |
| `zh-TW` | 繁體中文 (Traditional Chinese) |
| `zh-CN` | 简体中文 (Simplified Chinese) |
| `ko` | 한국어 (Korean) |
| `es` | Español (Spanish) |
| `fr` | Français (French) |
| `de` | Deutsch (German) |
### Changing Output Language
Admin users can change the output language via:
```http
POST /api/v1/admin/config
Content-Type: application/json
{
"search": {
"vlm_output_language": "zh-TW"
}
}
```
## Best Practices
1. **Always check `vlm_status`** before displaying tags or descriptions
- Only display if `vlm_status === 'completed'`
- Show loading state for `pending` or `processing`
- Handle `failed` gracefully
2. **Use localized version** when available
- Prefer `vlm_description_localized` over `vlm_description`
- Display `tag.local` for user-facing UI
- Use `tag.en` for search/filter functionality
3. **Combine with thumbnail**
- Always fetch thumbnail via `/api/v1/file/{file_uuid}/scenes/{filename}`
- Display image alongside tags for better context
4. **Handle missing data**
- `vlm_description_localized` can be `null` if translation failed
- `vlm_tags` can be empty array `[]` if VLM processing failed
- Provide fallback to `vlm_description` (English)
5. **Performance considerations**
- Cache scene data to avoid repeated API calls
- Lazy-load thumbnails when scrolling
- Use pagination for search results
## Error Handling
```vue
<template>
<div class="scene-loader">
<div v-if="loading" class="loading">
Loading scene analysis...
</div>
<div v-else-if="error" class="error">
Failed to load: {{ error }}
<button @click="retry">Retry</button>
</div>
<div v-else-if="scene?.vlm_status === 'completed'" class="scene-content">
<!-- Display scene content -->
</div>
<div v-else-if="scene?.vlm_status === 'processing'" class="processing">
Scene analysis in progress...
</div>
<div v-else-if="scene?.vlm_status === 'failed'" class="failed">
Scene analysis failed
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
const props = defineProps<{ fileUuid: string }>();
const scene = ref<any>(null);
const loading = ref(true);
const error = ref<string | null>(null);
const getScene = async () => {
loading.value = true;
error.value = null;
try {
const response = await fetch(
`http://localhost:3002/api/v1/file/${props.fileUuid}/scenes`
);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
scene.value = data.scenes[0];
// Check if VLM processing is complete
if (scene.value?.vlm_status === 'processing') {
// Wait and retry
setTimeout(getScene, 2000);
}
} catch (err: any) {
error.value = err.message || 'Unknown error';
} finally {
loading.value = false;
}
};
const retry = () => {
getScene();
};
onMounted(getScene);
</script>
```
### Error Handling with Composables (Vue 3 Best Practice)
```vue
<script setup lang="ts">
import { useSceneData } from '@/composables/useSceneData';
const props = defineProps<{
fileUuid: string;
sceneIndex: number;
}>();
const { scene, loading, error, retry } = useSceneData(
props.fileUuid,
props.sceneIndex
);
</script>
```
**Composable (`src/composables/useSceneData.ts`):**
```typescript
import { ref, watch, onMounted } from 'vue';
export function useSceneData(fileUuid: string, sceneIndex: number) {
const scene = ref<any>(null);
const loading = ref(true);
const error = ref<string | null>(null);
const fetchScene = async () => {
loading.value = true;
error.value = null;
try {
const response = await fetch(
`http://localhost:3002/api/v1/file/${fileUuid}/scenes`
);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
scene.value = data.scenes[sceneIndex];
// Retry if still processing
if (scene.value?.vlm_status === 'processing') {
setTimeout(fetchScene, 2000);
}
} catch (err: any) {
error.value = err.message;
} finally {
loading.value = false;
}
};
const retry = () => {
fetchScene();
};
onMounted(fetchScene);
watch(() => [fileUuid, sceneIndex], fetchScene);
return {
scene,
loading,
error,
retry
};
}
```
## Common Use Cases
### 1. Display Scene Tags in Video Player (Vue 3)
```vue
<template>
<div class="video-player">
<video
ref="videoRef"
@timeupdate="updateCurrentScene"
:src="videoUrl"
/>
<div v-if="currentScene" class="scene-overlay">
<h4>Scene {{ currentScene.index }}</h4>
<div class="tags">
<span
v-for="tag in currentScene.vlm_tags"
:key="tag.en"
class="tag"
>
{{ tag.local }}
</span>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
interface Scene {
index: number;
timestamp_sec: number;
vlm_tags: Array<{ en: string; local: string }>;
}
const props = defineProps<{
videoUrl: string;
fileUuid: string;
}>();
const videoRef = ref<HTMLVideoElement>();
const scenes = ref<Scene[]>([]);
const currentScene = ref<Scene | null>(null);
onMounted(async () => {
const response = await fetch(
`http://localhost:3002/api/v1/file/${props.fileUuid}/scenes`
);
const data = await response.json();
scenes.value = data.scenes;
});
const updateCurrentScene = () => {
if (!videoRef.value) return;
const currentTime = videoRef.value.currentTime;
// Find scene matching current time
currentScene.value = scenes.value.find((scene, index) => {
const sceneTime = scene.timestamp_sec;
const nextSceneTime = scenes.value[index + 1]?.timestamp_sec || Infinity;
return currentTime >= sceneTime && currentTime < nextSceneTime;
});
};
</script>
```
### 2. Filter Videos by Tag (Vue 3 + Pinia)
```vue
<template>
<div class="video-filter">
<input
v-model="searchTag"
@keyup.enter="filterVideos"
placeholder="Enter tag to filter..."
/>
<div v-if="loading">Loading...</div>
<div v-else class="video-list">
<div
v-for="video in filteredVideos"
:key="video.fileUuid"
class="video-item"
>
<h4>{{ video.file_name }}</h4>
<p>{{ video.matchingScenes.length }} matching scenes</p>
<div
v-for="scene in video.matchingScenes"
:key="scene.scene_index"
class="scene-preview"
>
<img :src="scene.thumbnail_url" />
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const searchTag = ref('');
const filteredVideos = ref<any[]>([]);
const loading = ref(false);
const filterVideos = async () => {
if (!searchTag.value.trim()) return;
loading.value = true;
try {
const response = await fetch('http://localhost:3002/api/v1/search/vlm/scenes', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY'
},
body: JSON.stringify({
query: searchTag.value,
page_size: 100
})
});
const data = await response.json();
// Group by file_uuid
const fileMap = new Map<string, any[]>();
data.results.forEach((result: any) => {
if (!fileMap.has(result.file_uuid)) {
fileMap.set(result.file_uuid, []);
}
fileMap.get(result.file_uuid)!.push(result);
});
filteredVideos.value = Array.from(fileMap.entries()).map(
([fileUuid, scenes]) => ({
fileUuid,
file_name: scenes[0].file_name,
matchingScenes: scenes
})
);
} catch (error) {
console.error('Filter failed:', error);
} finally {
loading.value = false;
}
};
</script>
```
### 3. Generate Tag Cloud (Vue 3)
```vue
<template>
<div class="tag-cloud">
<h3>Popular Tags</h3>
<div v-if="loading">Loading tag cloud...</div>
<div v-else class="tags">
<span
v-for="{ tag, count } in tagCloud"
:key="tag"
:style="{ fontSize: `${Math.min(count * 2, 24)}px` }"
class="tag"
>
{{ tag }}
</span>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
const tagCloud = ref<Array<{ tag: string; count: number }>>([]);
const loading = ref(true);
onMounted(async () => {
// Fetch all files
const filesRes = await fetch(
'http://localhost:3002/api/v1/files?page_size=100',
{ headers: { 'X-API-Key': 'YOUR_API_KEY' } }
);
const { files } = await filesRes.json();
const tagCounts = new Map<string, number>();
// Fetch scenes for each file (limit to 20 for performance)
for (const file of files.slice(0, 20)) {
const scenesRes = await fetch(
`http://localhost:3002/api/v1/file/${file.file_uuid}/scenes`
);
const { scenes } = await scenesRes.json();
scenes.forEach((scene: any) => {
scene.vlm_tags.forEach((tag: any) => {
const key = tag.local; // Use localized tag
tagCounts.set(key, (tagCounts.get(key) || 0) + 1);
});
});
}
// Sort by count and take top 20
tagCloud.value = Array.from(tagCounts.entries())
.map(([tag, count]) => ({ tag, count }))
.sort((a, b) => b.count - a.count)
.slice(0, 20);
loading.value = false;
});
</script>
<style scoped>
.tag-cloud .tags {
display: flex;
flex-wrap: wrap;
gap: 1rem;
align-items: center;
}
.tag {
transition: font-size 0.3s ease;
}
</style>
```
## Support
For questions or issues regarding VLM API integration:
1. Check API documentation: `http://localhost:3002/api/v1/docs` (Swagger UI)
2. Review Core API reference: `/docs_v1.0/API_WORKSPACE/`
3. Contact Core team via internal communication channels
## Version History
| Version | Date | Changes |
|---------|------|---------|
| 1.0 | 2026-10-23 | Initial release with structured bilingual tags |
---
**Note**: This guide assumes you have a valid API key and the Core API is running on `http://localhost:3002` (production) or `http://localhost:3003` (playground). Adjust the base URL as needed for your environment.
## Related Documentation
- **Scene VLM Status**: `/docs_v1.0/INTEGRATIONS/Scene_VLM_API_Integration.md` - For checking VLM processing status
- **Frontend Integration**: `/docs_v1.0/INTEGRATIONS/Scene_VLM_Frontend_Integration.md` - General frontend integration guide
- **API Reference**: `/docs_v1.0/GUIDES/` - Complete API documentation
## Updates Since v1.0
**2026-10-23 - Structured Bilingual Tags:**
- `vlm_tags` changed from `string[]` to `{ en: string, local: string }[]`
- Added `vlm_description_localized` field
- VLM now generates search-optimized tags with translations
- Backward compatible: Old format `["tag1", "tag2"]` still supported for existing data
@@ -0,0 +1,172 @@
---
title: VLM Documentation Index
version: "1.0"
date: 2026-10-23
author: Core Team
status: active
---
# VLM Documentation Index
Complete guide to Vision Language Model (VLM) integration with Momentry Core.
## Quick Start
**Start Here:** [VLM Quick Start](./VLM_Quick_Start.md) - 5-minute integration guide
## Documentation
### For Developers
1. **[VLM API Integration Guide](./VLM_API_Integration_Guide.md)**
- Complete API reference
- Data structures and TypeScript interfaces
- Code examples (React, JavaScript)
- Best practices and error handling
- **Updated 2026-10-23**: Structured bilingual tags
2. **[Scene VLM API Integration](./Scene_VLM_API_Integration.md)**
- Check VLM processing status
- Progress tracking
- Status endpoints
3. **[Scene VLM Frontend Integration](./Scene_VLM_Frontend_Integration.md)**
- General frontend integration patterns
- UI components
- State management
## Key Features
### Structured Bilingual Tags (NEW - 2026-10-23)
VLM now generates search-optimized tags in both English and localized language:
```json
{
"vlm_tags": [
{ "en": "smartphone", "local": "スマートフォン" },
{ "en": "indoor", "local": "屋内" }
]
}
```
**Benefits:**
- 5-10 search-relevant tags per scene
- Bilingual support (English + local language)
- Optimized for scene search functionality
### Scene Descriptions
- English description (1-2 sentences)
- Localized translation (based on `admin_config.search.vlm_output_language`)
- 3-5 key objects detected
### Supported Languages
| Code | Language |
|------|----------|
| `en` | English |
| `ja` | 日本語 |
| `zh-TW` | 繁體中文 |
| `zh-CN` | 简体中文 |
| `ko` | 한국어 |
| `es` | Español |
| `fr` | Français |
| `de` | Deutsch |
## API Endpoints
### Core Endpoints
| Endpoint | Purpose |
|----------|---------|
| `GET /api/v1/file/{file_uuid}/scenes` | Get scene data with VLM tags |
| `GET /api/v1/file/{file_uuid}/scenes/{filename}` | Get scene thumbnail image |
| `POST /api/v1/search/vlm/scenes` | Search scenes by tags/description |
### Status Endpoints
| Endpoint | Purpose |
|----------|---------|
| `GET /api/v1/stats/file/{file_uuid}` | Check VLM processing status |
## Data Structure
### Scene Object
```typescript
interface Scene {
index: number;
filename: string;
timestamp_sec: number;
frame_number: number;
vlm_status: 'pending' | 'processing' | 'completed' | 'failed';
vlm_description: string;
vlm_description_localized: string | null;
vlm_objects: string[];
vlm_tags: VlmTag[];
}
interface VlmTag {
en: string; // English tag
local: string; // Localized tag
}
```
## Common Use Cases
1. **Display scene tags in video player** - Show tags at current playback position
2. **Filter videos by tag** - Search across all videos
3. **Generate tag cloud** - Show most common tags
4. **Thumbnail gallery** - Display scenes with descriptions
See [Integration Guide](./VLM_API_Integration_Guide.md#common-use-cases) for code examples.
## Examples
### Minimal Integration
```javascript
// Fetch and display tags
const { scenes } = await fetch(
`/api/v1/file/${fileUuid}/scenes`,
{ headers: { 'X-API-Key': API_KEY } }
).then(r => r.json());
scenes[0].vlm_tags.forEach(tag => {
console.log(tag.local); // Display localized tag
});
```
### Search Integration
```javascript
// Search scenes by tag
const results = await fetch('/api/v1/search/vlm/scenes', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: "smartphone",
filters: { vlm_tags: ["smartphone"] }
})
}).then(r => r.json());
```
## Support
- **API Docs**: `http://localhost:3002/api/v1/docs` (Swagger UI)
- **Core Team**: Contact via internal channels
- **Issues**: Report to Core team for investigation
## Changelog
### 2026-10-23
- ✅ Added structured bilingual tags (`{ en, local }`)
- ✅ Added `vlm_description_localized` field
- ✅ Tags now 5-10 items, search-optimized
- ✅ Backward compatible with old format
### 2026-09-22
- Initial VLM API release
- Scene description in English only
- Tags as simple string array
+173
View File
@@ -0,0 +1,173 @@
---
title: VLM API Quick Start
version: "1.0"
date: 2026-10-23
author: Core Team
status: active
---
# VLM API Quick Start
## 5-Minute Integration
### Step 1: Get Scene Data
```bash
curl -H "X-API-Key: YOUR_API_KEY" \
"http://localhost:3002/api/v1/file/{file_uuid}/scenes"
```
### Step 2: Parse Response
```javascript
const response = await fetch(
`/api/v1/file/${fileUuid}/scenes`,
{ headers: { 'X-API-Key': 'YOUR_API_KEY' } }
);
const { scenes } = await response.json();
// Each scene has:
scenes[0] = {
index: 0,
filename: "scene_000.jpg",
timestamp_sec: 1.5,
vlm_description: "English description...",
vlm_description_localized: "日本語の説明...",
vlm_objects: ["smartphone", "keyboard"],
vlm_tags: [
{ en: "smartphone", local: "スマートフォン" },
{ en: "indoor", local: "屋内" }
]
}
```
### Step 3: Display Tags
```vue
<!-- Vue 3 Composition API example -->
<template>
<div v-if="scene.vlm_status === 'completed'">
<p>{{ scene.vlm_description_localized || scene.vlm_description }}</p>
<span
v-for="(tag, i) in scene.vlm_tags"
:key="i"
class="tag"
>
{{ tag.local }}
</span>
</div>
<div v-else>Loading...</div>
</template>
<script setup lang="ts">
import { defineProps } from 'vue';
interface VlmTag {
en: string;
local: string;
}
interface Scene {
vlm_status: string;
vlm_description: string;
vlm_description_localized: string | null;
vlm_tags: VlmTag[];
}
defineProps<{
scene: Scene;
}>();
</script>
```
## Key Points
1. **Bilingual Tags**: `tag.en` + `tag.local` (use `local` for display, `en` for search)
2. **Status Check**: Only show if `vlm_status === 'completed'`
3. **Fallback**: Use `vlm_description` if `vlm_description_localized` is null
4. **Thumbnail**: GET `/api/v1/file/{file_uuid}/scenes/{filename}`
## Search Example
```vue
<script setup lang="ts">
import { ref } from 'vue';
const searchQuery = ref('');
const searchScenes = async () => {
const response = await fetch('http://localhost:3002/api/v1/search/vlm/scenes', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY'
},
body: JSON.stringify({
query: searchQuery.value,
filters: { vlm_tags: [searchQuery.value] }
})
});
const { results } = await response.json();
// Use results in your component
};
</script>
```
## Tauri Integration (Optional)
If you prefer routing API calls through Rust backend:
**Rust (`src-tauri/src/main.rs`):**
```rust
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct Scene {
index: usize,
vlm_tags: Vec<VlmTag>,
}
#[derive(Serialize, Deserialize)]
struct VlmTag {
en: String,
local: String,
}
#[tauri::command]
async fn get_scenes(file_uuid: String) -> Result<Vec<Scene>, String> {
let url = format!("http://localhost:3002/api/v1/file/{}/scenes", file_uuid);
let response = reqwest::get(&url).await.map_err(|e| e.to_string())?;
let data: serde_json::Value = response.json().await.map_err(|e| e.to_string())?;
let scenes: Vec<Scene> = serde_json::from_value(data["scenes"].clone()).map_err(|e| e.to_string())?;
Ok(scenes)
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![get_scenes])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
```
**Vue:**
```vue
<script setup lang="ts">
import { invoke } from '@tauri-apps/api/tauri';
const scenes = await invoke('get_scenes', { fileUuid: props.fileUuid });
</script>
```
## Complete Example
See: `/docs_v1.0/INTEGRATIONS/VLM_API_Integration_Guide.md`
## API Reference
- Full docs: `http://localhost:3002/api/v1/docs`
- Scene search: `POST /api/v1/search/vlm/scenes`
- Get scenes: `GET /api/v1/file/{file_uuid}/scenes`
- Get thumbnail: `GET /api/v1/file/{file_uuid}/scenes/{filename}`