edoardo 1.0.11 → 1.0.12
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.
|
@@ -74,19 +74,17 @@ ${c}
|
|
|
74
74
|
|
|
75
75
|
[Click to view video](${b.url})`:"").filter(Boolean).join(`
|
|
76
76
|
|
|
77
|
-
`)||"Video generated but no URL returned",finishReason:"stop"}}const m=Jo(),h=60,p=5e3;for(let g=0;g<h;g++){await new Promise(x=>setTimeout(x,p));try{const x=await fetch(`${m}/xai/video/status?
|
|
77
|
+
`)||"Video generated but no URL returned",finishReason:"stop"}}const m=Jo(),h=60,p=5e3;for(let g=0;g<h;g++){await new Promise(x=>setTimeout(x,p));try{const x=await fetch(`${m}/xai/video/status?requestId=${f}`,{method:"GET",headers:{Authorization:`Bearer ${a}`}});if(!x.ok){console.log(`[Grok Video] Status check failed (attempt ${g+1}): ${x.status}`);continue}const b=await x.json();console.log(`[Grok Video] Status (attempt ${g+1}):`,b);const w=b.status,S=b.video?.url||b.video_url||b.url||b.output?.url;if(S){const N=b.video?.duration;return{content:`🎬 **Video generated successfully!**${N?` (${N}s)`:""}
|
|
78
78
|
|
|
79
|
-
[Click to view video](${S})`,finishReason:"stop"}
|
|
79
|
+
[Click to view video](${S})`,finishReason:"stop"}}if(w==="done")return{content:`🎬 **Video completed!**
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
Check the [xAI Console](https://console.x.ai/) for your video.`,finishReason:"stop"};if(w==="expired")return{content:`⏰ **Video request expired**
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Error: ${b.error||b.message||"Unknown error"}`,finishReason:"stop"}}catch(x){console.log(`[Grok Video] Polling error (attempt ${g+1}):`,x)}}return{content:`🎬 **Video is still being generated...**
|
|
83
|
+
The video generation request has expired. Please try again.`,finishReason:"stop"}}catch(x){console.log(`[Grok Video] Polling error (attempt ${g+1}):`,x)}}return{content:`🎬 **Video is still being generated...**
|
|
86
84
|
|
|
87
85
|
The video is taking longer than expected. Check the status manually:
|
|
88
86
|
|
|
89
|
-
**
|
|
87
|
+
**Request ID:** \`${f}\`
|
|
90
88
|
|
|
91
89
|
Visit: [xAI Console](https://console.x.ai/)`,finishReason:"stop"}}async function Xj(a,o,r,i="grok-3",c=!1){const f=()=>[...o].reverse().find(S=>S.role==="user")?.content||"";if(Gj(i)){const w=f();return w?qj(a,w,i):{content:"Please provide a prompt for image generation",finishReason:"stop"}}if(Vj(i)){const w=f();return w?Yj(a,w,i):{content:"Please provide a prompt for video generation",finishReason:"stop"}}const m=o.map(w=>w.role==="tool"?{role:"tool",tool_call_id:w.toolCallId,content:w.content}:w.role==="assistant"&&w.toolCalls&&w.toolCalls.length>0?{role:"assistant",content:w.content||null,tool_calls:w.toolCalls.map(S=>({id:S.id,type:"function",function:{name:S.name,arguments:JSON.stringify(S.arguments)}}))}:{role:w.role,content:w.content}),h={model:i,messages:m,stream:c};r&&r.length>0&&(h.tools=r,h.tool_choice="auto");const p=await fetch("https://api.x.ai/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(h)});if(!p.ok){const w=await p.json().catch(()=>({}));throw new Error(w.error?.message||`Grok API error: ${p.status}`)}if(c){const w=p.body?.getReader(),S=new TextDecoder;if(!w)throw new Error("No response body reader available");let N="",E=new Map,A="stop";try{for(;;){const{done:O,value:R}=await w.read();if(O)break;const V=S.decode(R,{stream:!0}).split(`
|
|
92
90
|
`).filter(K=>K.trim()!=="");for(const K of V)if(K.startsWith("data: ")){const J=K.slice(6);if(J==="[DONE]")continue;try{const Y=JSON.parse(J).choices?.[0];if(!Y)continue;const ee=Y.delta;if(ee?.content&&(N+=ee.content),ee?.tool_calls)for(const ae of ee.tool_calls){const ne=ae.index,ue=E.get(ne)||{arguments:""};ae.id&&(ue.id=ae.id),ae.function?.name&&(ue.name=ae.function.name),ae.function?.arguments&&(ue.arguments+=ae.function.arguments),E.set(ne,ue)}Y.finish_reason&&(A=Y.finish_reason==="tool_calls"?"tool_calls":"stop")}catch(k){console.warn("[Grok SSE] Failed to parse line:",K,k)}}}}finally{w.releaseLock()}if(A==="tool_calls"&&E.size>0){const O=[];return E.forEach(R=>{R.id&&R.name&&O.push({id:R.id,name:R.name,arguments:JSON.parse(R.arguments||"{}")})}),{content:N||"",toolCalls:O,finishReason:"tool_calls"}}return{content:N||"No response from Grok",finishReason:"stop"}}const x=(await p.json()).choices[0],b=x?.message;return x?.finish_reason==="tool_calls"&&b?.tool_calls?{content:b.content||"",toolCalls:b.tool_calls.map(w=>({id:w.id,name:w.function.name,arguments:JSON.parse(w.function.arguments||"{}")})),finishReason:"tool_calls"}:{content:b?.content||"No response from Grok",finishReason:"stop"}}async function Kj(a,o,r,i,c=!1){const f=r.map(w=>w.role==="tool"?{role:"tool",tool_call_id:w.toolCallId,content:w.content}:w.role==="assistant"&&w.toolCalls&&w.toolCalls.length>0?{role:"assistant",content:w.content||null,tool_calls:w.toolCalls.map(S=>({id:S.id,type:"function",function:{name:S.name,arguments:S.arguments}}))}:{role:w.role,content:w.content}),m={model:o,messages:f,stream:c};i&&i.length>0&&(m.tools=i,m.tool_choice="auto"),console.log("[Ollama Request]",{model:o,hasTools:!!(i&&i.length>0),toolCount:i?.length||0,messageCount:f.length});const h=await fetch(`${a}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)});if(!h.ok){const w=await h.text().catch(()=>"Unknown error");throw console.error("[Ollama Error Response]",{status:h.status,error:w,endpoint:a,model:o}),new Error(`Ollama API error: ${h.status} - ${w}`)}const p=await h.text();let g;try{g=JSON.parse(p)}catch{console.log("[Ollama] Response appears to be NDJSON, parsing line by line");const S=p.trim().split(`
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Edoardo</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-rTeu2Xlj.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-Cp6s2BCA.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
package/server/standalone.js
CHANGED
|
@@ -672,11 +672,11 @@ app.post('/oauth/token', async (req, res) => {
|
|
|
672
672
|
// Proxies video status requests to avoid browser CORS issues
|
|
673
673
|
|
|
674
674
|
app.get('/xai/video/status', async (req, res) => {
|
|
675
|
-
const
|
|
675
|
+
const requestId = req.query.requestId;
|
|
676
676
|
const apiKey = req.headers['authorization']?.replace('Bearer ', '');
|
|
677
677
|
|
|
678
|
-
if (!
|
|
679
|
-
return res.status(400).json({ error: 'Missing
|
|
678
|
+
if (!requestId) {
|
|
679
|
+
return res.status(400).json({ error: 'Missing requestId parameter' });
|
|
680
680
|
}
|
|
681
681
|
|
|
682
682
|
if (!apiKey) {
|
|
@@ -684,18 +684,18 @@ app.get('/xai/video/status', async (req, res) => {
|
|
|
684
684
|
}
|
|
685
685
|
|
|
686
686
|
try {
|
|
687
|
-
console.log(`[xAI Video] Checking status for
|
|
687
|
+
console.log(`[xAI Video] Checking status for requestId: ${requestId}`);
|
|
688
688
|
|
|
689
|
-
|
|
689
|
+
// Correct endpoint: GET https://api.x.ai/v1/videos/{request_id}
|
|
690
|
+
const response = await fetch(`https://api.x.ai/v1/videos/${requestId}`, {
|
|
690
691
|
method: 'GET',
|
|
691
692
|
headers: {
|
|
692
693
|
'Authorization': `Bearer ${apiKey}`,
|
|
693
|
-
'Content-Type': 'application/json',
|
|
694
694
|
},
|
|
695
695
|
});
|
|
696
696
|
|
|
697
697
|
const data = await response.json();
|
|
698
|
-
console.log(`[xAI Video] Status response:`, JSON.stringify(data).substring(0,
|
|
698
|
+
console.log(`[xAI Video] Status response:`, JSON.stringify(data).substring(0, 500));
|
|
699
699
|
|
|
700
700
|
res.status(response.status).json(data);
|
|
701
701
|
} catch (error) {
|