add ask AI
This commit is contained in:
		| @@ -4,15 +4,21 @@ export interface AppConfig { | ||||
|   collections: { | ||||
|     comment: string; | ||||
|     user: string; | ||||
|     chat: string; | ||||
|   }; | ||||
|   host: string; | ||||
|   rkey?: string; // Current post rkey if on post page | ||||
|   aiEnabled: boolean; | ||||
|   aiAskAi: boolean; | ||||
|   aiProvider: string; | ||||
|   aiModel: string; | ||||
|   aiHost: string; | ||||
| } | ||||
|  | ||||
| // Generate collection names from host | ||||
| // Format: ${reg}.${name}.${sub} | ||||
| // Example: log.syui.ai -> ai.syui.log | ||||
| function generateCollectionNames(host: string): { comment: string; user: string } { | ||||
| function generateCollectionNames(host: string): { comment: string; user: string; chat: string } { | ||||
|   try { | ||||
|     // Remove protocol if present | ||||
|     const cleanHost = host.replace(/^https?:\/\//, ''); | ||||
| @@ -31,14 +37,16 @@ function generateCollectionNames(host: string): { comment: string; user: string | ||||
|      | ||||
|     return { | ||||
|       comment: collectionBase, | ||||
|       user: `${collectionBase}.user` | ||||
|       user: `${collectionBase}.user`, | ||||
|       chat: `${collectionBase}.chat` | ||||
|     }; | ||||
|   } catch (error) { | ||||
|     console.warn('Failed to generate collection names from host:', host, error); | ||||
|     // Fallback to default collections | ||||
|     return { | ||||
|       comment: 'ai.syui.log', | ||||
|       user: 'ai.syui.log.user' | ||||
|       user: 'ai.syui.log.user', | ||||
|       chat: 'ai.syui.log.chat' | ||||
|     }; | ||||
|   } | ||||
| } | ||||
| @@ -61,22 +69,36 @@ export function getAppConfig(): AppConfig { | ||||
|   const collections = { | ||||
|     comment: import.meta.env.VITE_COLLECTION_COMMENT || autoGeneratedCollections.comment, | ||||
|     user: import.meta.env.VITE_COLLECTION_USER || autoGeneratedCollections.user, | ||||
|     chat: import.meta.env.VITE_COLLECTION_CHAT || autoGeneratedCollections.chat, | ||||
|   }; | ||||
|    | ||||
|   const rkey = extractRkeyFromUrl(); | ||||
|    | ||||
|   // AI configuration | ||||
|   const aiEnabled = import.meta.env.VITE_AI_ENABLED === 'true'; | ||||
|   const aiAskAi = import.meta.env.VITE_AI_ASK_AI === 'true'; | ||||
|   const aiProvider = import.meta.env.VITE_AI_PROVIDER || 'ollama'; | ||||
|   const aiModel = import.meta.env.VITE_AI_MODEL || 'gemma2:2b'; | ||||
|   const aiHost = import.meta.env.VITE_AI_HOST || 'https://ollama.syui.ai'; | ||||
|    | ||||
|   console.log('App configuration:', { | ||||
|     host, | ||||
|     adminDid, | ||||
|     collections, | ||||
|     rkey: rkey || 'none (not on post page)' | ||||
|     rkey: rkey || 'none (not on post page)', | ||||
|     ai: { enabled: aiEnabled, askAi: aiAskAi, provider: aiProvider, model: aiModel, host: aiHost } | ||||
|   }); | ||||
|    | ||||
|   return { | ||||
|     adminDid, | ||||
|     collections, | ||||
|     host, | ||||
|     rkey | ||||
|     rkey, | ||||
|     aiEnabled, | ||||
|     aiAskAi, | ||||
|     aiProvider, | ||||
|     aiModel, | ||||
|     aiHost | ||||
|   }; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user