-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_koog_attachments.kt
More file actions
54 lines (46 loc) · 2.36 KB
/
test_koog_attachments.kt
File metadata and controls
54 lines (46 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Test script to verify Koog attachments implementation
import ai.koog.prompt.dsl.prompt
import ai.koog.prompt.executor.llms.all.simpleOpenAIExecutor
import ai.koog.prompt.executor.clients.openai.OpenAIModels
import ai.koog.prompt.markdown.markdown
import kotlinx.io.files.Path
import kotlinx.coroutines.runBlocking
fun main() {
println("Testing Koog attachments implementation...")
// Simulate the new approach used in HomeViewModel
val input = "Can you analyze this image and provide health guidance?"
val imageUri = "test_image.jpg" // Simulated image path
val prompt = prompt("health-assistant-prompt") {
system("""
You are a helpful health assistant for a comprehensive health platform with image analysis capabilities.
Your role is to:
- Provide accurate, evidence-based health information
- Offer wellness guidance and lifestyle recommendations
- Help users understand symptoms (without providing diagnoses)
- Analyze health-related images when provided (skin conditions, medical documents, etc.)
- Suggest when to consult healthcare professionals
- Maintain a caring, professional, and empathetic tone
When users attach images, you can view and analyze them to provide relevant health guidance.
Always prioritize user safety and recommend professional medical consultation for serious concerns.
""".trimIndent())
user {
markdown {
+input
}
// Add image attachment if provided
attachments {
// Convert URI to Path - for Android content URIs, we need to handle them properly
try {
image(Path(imageUri))
println("✓ Image attachment added successfully: $imageUri")
} catch (e: Exception) {
// Fallback: create a temporary file or handle URI conversion
println("✗ Failed to attach image: ${e.message}")
}
}
}
}
println("✓ Prompt created with image attachment support")
println("✓ Using proper Koog DSL approach from notebook example")
println("✓ Implementation matches the reference: user { attachments { image(Path(...)) } }")
}