text stringlengths 0 59.1k |
|---|
return await prompts.getPrompt({ |
promptName: "primary-prompt", |
timeout: 5000, |
}); |
} catch (error) { |
console.error("Prompt fetch failed:", error); |
return "You are a helpful assistant."; // Fallback |
} |
}; |
``` |
### Common Errors |
#### Prompt Not Found |
```typescript |
// Error: Prompt 'weather-prompt' not found |
// Solution: Verify prompt name exists in VoltOps console |
instructions: async ({ prompts }) => { |
try { |
return await prompts.getPrompt({ promptName: "weather-prompt" }); |
} catch (error) { |
console.error("Prompt fetch failed:", error); |
return "Fallback instructions"; |
} |
}; |
``` |
#### Missing Variables |
```typescript |
// Error: Variable 'userName' not found in template |
// Solution: Provide all required variables with defaults |
return await prompts.getPrompt({ |
promptName: "greeting-prompt", |
variables: { |
userName: context.get("userName") || "Guest", |
currentTime: new Date().toISOString(), |
}, |
}); |
``` |
#### Authentication Failed |
```typescript |
// Error: Authentication failed |
// Solution: Verify environment variables |
console.log("Public Key:", process.env.VOLTAGENT_PUBLIC_KEY?.substring(0, 8) + "..."); |
console.log("Secret Key:", process.env.VOLTAGENT_SECRET_KEY ? "Set" : "Missing"); |
``` |
#### Stale Cache |
```typescript |
// Problem: Old prompt version still in use after update |
// Solution 1: Clear cache |
voltOpsClient.prompts.clearCache(); |
// Solution 2: Disable cache temporarily |
return await prompts.getPrompt({ |
promptName: "urgent-prompt", |
promptCache: { enabled: false }, |
}); |
// Solution 3: Wait for TTL expiration |
``` |
## Debugging |
Test prompt fetching independently: |
```typescript |
const voltOpsClient = new VoltOpsClient({ |
publicKey: process.env.VOLTAGENT_PUBLIC_KEY, |
secretKey: process.env.VOLTAGENT_SECRET_KEY, |
}); |
try { |
const prompt = await voltOpsClient.prompts.getPrompt({ |
promptName: "test-prompt", |
}); |
console.log("Success:", prompt); |
} catch (error) { |
console.error("Failed:", error); |
} |
``` |
## Complete Example |
```typescript |
import { openai } from "@ai-sdk/openai"; |
import { Agent, VoltAgent, VoltOpsClient } from "@voltagent/core"; |
const voltOpsClient = new VoltOpsClient({ |
publicKey: process.env.VOLTAGENT_PUBLIC_KEY, |
secretKey: process.env.VOLTAGENT_SECRET_KEY, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.