PageSourceSearch

https://dev-room-three.vercel.app/assets/ChatGPTApi-Dnw7fk3c.js

js dev-room-three.vercel.app collected 2026-10-03 06:42:03 UTC 4,590 bytes, 1 lines download raw bytes

1import{r as g,w as k,i as w,b as o,d as l,e as t,f as m,j as r,E as p,v as y,l as f,F as I,m as A,t as b,h as S}from"./index-CBtR9Ccp.js";const C={class:"flex flex-col h-full w-full p-4 bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 rounded-lg shadow-lg",id:"chatgptapi-main"},V={class:"mb-4 flex flex-col gap-2 bg-gray-800/80 p-4 rounded-lg border border-gray-700",id:"chatgptapi-config"},E={for:"chatgptapi-key",class:"font-semibold text-blue-300 flex items-center gap-2"},P={class:"flex items-center gap-2 text-xs text-gray-400 mt-1"},N={class:"flex-1 w-full overflow-auto rounded border border-gray-700 bg-gray-900 p-4 mb-3",id:"chatgptapi-messages"},O={key:0,class:"text-gray-400 text-center mt-8"},T={key:0,class:"flex items-start gap-2 mb-1"},B={class:"whitespace-pre-line bg-blue-950/60 rounded px-3 py-2 mt-1"},M={key:1,class:"flex items-start gap-2 mb-1"},j={class:"whitespace-pre-line bg-green-950/60 rounded px-3 py-2 mt-1"},D={key:1,class:"text-gray-400 flex items-center gap-2"},q={key:2,class:"text-red-400 mt-2"},F=["disabled"],K=["disabled"],L=["disabled"],G={__name:"ChatGPTApi",setup(U){const n=g(localStorage.getItem("chatgpt_api_key")||""),u=g(""),i=g([]),c=g(!1),d=g("");k(n,v=>{localStorage.setItem("chatgpt_api_key",v)});async function x(){if(!(!u.value.trim()||!n.value)){d.value="",c.value=!0,i.value.push({role:"user",content:u.value});try{const e=await(await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${n.value}`,"Content-Type":"application/json"},body:JSON.stringify({model:"gpt-3.5-turbo",messages:i.value.map(a=>({role:a.role,content:a.content})),max_tokens:512,temperature:.7})})).json();e.choices&&e.choices[0]&&e.choices[0].message?i.value.push({role:"assistant",content:e.choices[0].message.content.trim()}):e.error&&e.error.message?d.value="Erro: "+e.error.message:d.value="Erro ao obter resposta da IA."}catch{d.value="Erro de conexão com a API."}u.value="",c.value=!1}}function h(){i.value=[],d.value=""}return(v,e)=>{const a=w("font-awesome-icon");return l(),o("div",C,[t("div",V,[t("label",E,[r(a,{icon:"fa-solid fa-key",class:"text-blue-400"}),e[2]||(e[2]=p(" Sua chave da OpenAI (API Key) "))]),m(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>n.value=s),type:"password",placeholder:"Cole sua chave secreta da OpenAI aqui...",class:"px-3 py-2 rounded bg-gray-900 text-gray-100 border border-gray-700 focus:outline-none",id:"chatgptapi-key",autocomplete:"off"},null,512),[[y,n.value]]),t("div",P,[r(a,{icon:"fa-solid fa-circle-info",class:"text-blue-400"}),e[3]||(e[3]=t("span",null,[p(" Sua chave nunca é enviada para terceiros. "),t("a",{href:"https://platform.openai.com/api-keys",target:"_blank",class:"underline text-blue-300"},"Obtenha sua chave aqui"),p(". ")],-1))])]),t("div",N,[i.value.length===0?(l(),o("div",O,[r(a,{icon:"fa-solid fa-robot",class:"text-4xl mb-2 text-blue-400"}),e[4]||(e[4]=t("div",null,"Converse com a IA! Digite sua pergunta abaixo.",-1))])):f("",!0),(l(!0),o(I,null,A(i.value,(s,_)=>(l(),o("div",{key:_,class:"mb-6"},[s.role==="user"?(l(),o("div",T,[r(a,{icon:"fa-solid fa-user-astronaut",class:"text-blue-300 mt-1"}),t("div",null,[e[5]||(e[5]=t("div",{class:"font-bold text-blue-300"},"Você:",-1)),t("div",B,b(s.content),1)])])):f("",!0),s.role==="assistant"?(l(),o("div",M,[r(a,{icon:"fa-solid fa-robot",class:"text-green-400 mt-1"}),t("div",null,[e[6]||(e[6]=t("div",{class:"font-bold text-green-300"},"IA:",-1)),t("div",j,b(s.content),1)])])):f("",!0)]))),128)),c.value?(l(),o("div",D,[r(a,{icon:"fa-solid fa-spinner",spin:""}),e[7]||(e[7]=p(" Pensando... "))])):f("",!0),d.value?(l(),o("div",q,b(d.value),1)):f("",!0)]),t("form",{onSubmit:S(x,["prevent"]),class:"flex gap-2",id:"chatgptapi-form"},[m(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>u.value=s),type:"text",placeholder:"Pergunte algo para a IA...",class:"flex-1 px-3 py-2 rounded bg-gray-800 text-gray-100 border border-gray-700 focus:outline-none",id:"chatgptapi-input",autocomplete:"off",disabled:!n.value},null,8,F),[[y,u.value]]),t("button",{type:"submit",class:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded transition font-bold",disabled:c.value||!u.value.trim()||!n.value,id:"chatgptapi-send-btn"},[r(a,{icon:"fa-solid fa-paper-plane"}),e[8]||(e[8]=p(" Enviar "))],8,K),t("button",{type:"button",class:"bg-gray-700 hover:bg-gray-800 text-gray-200 px-4 py-2 rounded transition font-bold",onClick:h,disabled:c.value||i.value.length===0,id:"chatgptapi-clear-btn"}
1,[r(a,{icon:"fa-solid fa-trash"}),e[9]||(e[9]=p(" Limpar "))],8,L)],32)])}}};export{G as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.