stacks-ai 0.1.2 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +0,0 @@
1
- import{g}from"./index-C1agmKFP.js";import{c as h,o as y,a as p}from"./index-C8w_QbzK.js";const r={},m=t=>{const e={anthropic:"anthropic-api-key",openai:"openai-api-key",google:"gemini-api-key"},a=localStorage.getItem(e[t]);return a||{anthropic:r==null?void 0:r.VITE_ANTHROPIC_API_KEY,openai:r==null?void 0:r.VITE_OPENAI_API_KEY,google:r==null?void 0:r.VITE_GEMINI_API_KEY}[t]||""},u=async t=>{const a=await(await fetch(t)).blob();return new Promise((o,c)=>{const n=new FileReader;n.onloadend=()=>{const s=n.result,[,l]=s.split(",");o({data:l,mimeType:a.type})},n.onerror=c,n.readAsDataURL(a)})},A=async(t,e)=>{const a=(e==null?void 0:e.provider)||localStorage.getItem("ai-provider")||"google",o=m(a);if(!o)throw new Error(`${a} API key not configured. Please add your API key in Settings → Providers.`);const{data:c,mimeType:n}=await u(t);let s;switch(a){case"anthropic":s=p((e==null?void 0:e.model)||"claude-sonnet-4-5-20250929",{apiKey:o});break;case"openai":s=y((e==null?void 0:e.model)||"gpt-4o",{apiKey:o});break;case"google":{s=h({apiKey:o})((e==null?void 0:e.model)||"gemini-2.0-flash-exp");break}default:throw new Error(`Unknown provider: ${a}`)}const i=(await g({model:s,messages:[{role:"user",content:[{type:"image",image:`data:${n};base64,${c}`},{type:"text",text:`Analyze this image and provide:
2
- 1. A one-sentence description of what you see
3
- 2. The 6 most dominant colors as hex codes
4
-
5
- Format your response as JSON:
6
- {
7
- "description": "Your one-sentence description",
8
- "colors": ["#hex1", "#hex2", "#hex3", "#hex4", "#hex5", "#hex6"]
9
- }`}]}]})).text.match(/\{[\s\S]*\}/);return i?JSON.parse(i[0]):{description:"Unable to analyze image",colors:[]}};export{A as analyzeImageWithVision};