fix
Some checks failed
Deploy ailog / build-and-deploy (push) Failing after 11m6s

This commit is contained in:
2025-06-13 15:31:32 +09:00
parent 2e0fe0edfc
commit ac4c3f2ad3
2 changed files with 27 additions and 3 deletions

View File

@ -21,4 +21,4 @@ VITE_AI_PROVIDER=ollama
VITE_AI_MODEL=gemma3:4b
VITE_AI_HOST=https://ollama.syui.ai
VITE_AI_SYSTEM_PROMPT="You are a helpful AI assistant trained on this blog's content. You can answer questions about the articles, provide insights, and help users understand the topics discussed."
VITE_AI_DID=did:plc:uqzpqmrjnptsxezjx4xuh2mn
VITE_AI_DID=did:plc:4hqjfn7m6n5hno3doamuhgef

View File

@ -28,12 +28,18 @@ export const AIChat: React.FC<AIChatProps> = ({ user, isEnabled }) => {
// Fetch AI profile on load
useEffect(() => {
const fetchAIProfile = async () => {
if (!aiConfig.aiDid) return;
if (!aiConfig.aiDid) {
console.log('No AI DID configured');
return;
}
try {
// Try with agent first
const agent = atprotoOAuthService.getAgent();
if (agent) {
console.log('Fetching AI profile with agent for DID:', aiConfig.aiDid);
const profile = await agent.getProfile({ actor: aiConfig.aiDid });
console.log('AI profile fetched successfully:', profile.data);
setAiProfile({
did: aiConfig.aiDid,
handle: profile.data.handle || 'ai-assistant',
@ -41,9 +47,26 @@ export const AIChat: React.FC<AIChatProps> = ({ user, isEnabled }) => {
avatar: profile.data.avatar || null,
description: profile.data.description || null
});
return;
}
// Fallback to public API
console.log('No agent available, trying public API for AI profile');
const response = await fetch(`https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(aiConfig.aiDid)}`);
if (response.ok) {
const profileData = await response.json();
console.log('AI profile fetched via public API:', profileData);
setAiProfile({
did: aiConfig.aiDid,
handle: profileData.handle || 'ai-assistant',
displayName: profileData.displayName || 'AI Assistant',
avatar: profileData.avatar || null,
description: profileData.description || null
});
return;
}
} catch (error) {
console.log('Failed to fetch AI profile, using defaults');
console.log('Failed to fetch AI profile, using defaults:', error);
setAiProfile({
did: aiConfig.aiDid,
handle: 'ai-assistant',
@ -187,6 +210,7 @@ ${chatHistoryText ? `履歴: ${chatHistoryText}` : ''}
}
// 4. Immediately dispatch event to update UI
console.log('Dispatching AI response with profile:', aiProfile);
window.dispatchEvent(new CustomEvent('aiResponseReceived', {
detail: {
answer: aiAnswer,