diff --git a/my-blog/static/oauth/index.html b/my-blog/static/oauth/index.html
index f44febe..7380ee8 100644
--- a/my-blog/static/oauth/index.html
+++ b/my-blog/static/oauth/index.html
@@ -1,3 +1,3 @@
-
+
diff --git a/oauth/src/App.jsx b/oauth/src/App.jsx
index a6fafd8..7c87e75 100644
--- a/oauth/src/App.jsx
+++ b/oauth/src/App.jsx
@@ -31,13 +31,92 @@ export default function App() {
}, 1000)
}
- const handleAIQuestion = (event) => {
+ const handleAIQuestion = async (event) => {
const { question } = event.detail
if (question && adminData && user && agent) {
- // Automatically open Ask AI panel and submit question
- setShowAskAI(true)
- // We'll need to pass this to the AskAI component
- // For now, let's just open the panel
+ try {
+ console.log('Processing AI question:', question)
+
+ // AI設定
+ const aiConfig = {
+ host: import.meta.env.VITE_AI_HOST || 'https://ollama.syui.ai',
+ model: import.meta.env.VITE_AI_MODEL || 'gemma3:1b',
+ systemPrompt: import.meta.env.VITE_AI_SYSTEM_PROMPT || 'あなたは6歳の女の子アイです。明るく元気で、ちょっとおっちょこちょい。自分のことは「アイ」って呼びます。'
+ }
+
+ const prompt = `${aiConfig.systemPrompt}
+
+Question: ${question}
+
+Answer:`
+
+ // Ollamaに直接リクエスト
+ const controller = new AbortController()
+ const timeoutId = setTimeout(() => controller.abort(), 30000)
+
+ const response = await fetch(`${aiConfig.host}/api/generate`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Origin': 'https://syui.ai',
+ },
+ body: JSON.stringify({
+ model: aiConfig.model,
+ prompt: prompt,
+ stream: false,
+ options: {
+ temperature: 0.9,
+ top_p: 0.9,
+ num_predict: 200,
+ repeat_penalty: 1.1,
+ }
+ }),
+ signal: controller.signal
+ })
+
+ clearTimeout(timeoutId)
+
+ if (!response.ok) {
+ throw new Error(`Ollama API error: ${response.status}`)
+ }
+
+ const data = await response.json()
+ const answer = data.response || 'エラーが発生しました'
+
+ console.log('AI response received:', answer)
+
+ // Send response to blog
+ window.dispatchEvent(new CustomEvent('aiResponseReceived', {
+ detail: {
+ question: question,
+ answer: answer,
+ timestamp: new Date().toISOString(),
+ aiProfile: adminData?.profile ? {
+ did: adminData.did,
+ handle: adminData.profile.handle,
+ displayName: adminData.profile.displayName,
+ avatar: adminData.profile.avatar
+ } : null
+ }
+ }))
+
+ } catch (error) {
+ console.error('Failed to process AI question:', error)
+ // Send error response to blog
+ window.dispatchEvent(new CustomEvent('aiResponseReceived', {
+ detail: {
+ question: question,
+ answer: 'エラーが発生しました。もう一度お試しください。',
+ timestamp: new Date().toISOString(),
+ aiProfile: adminData?.profile ? {
+ did: adminData.did,
+ handle: adminData.profile.handle,
+ displayName: adminData.profile.displayName,
+ avatar: adminData.profile.avatar
+ } : null
+ }
+ }))
+ }
}
}