Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7962a7492 | ||
|
|
1b639d0d4f | ||
|
|
2e919d24c3 | ||
|
|
d6ee6dd79d | ||
|
|
cad27eb98b | ||
|
|
c17cea3a6e | ||
|
|
90d8efa767 | ||
|
|
34a4484eee | ||
|
|
9292f678e8 | ||
|
|
1d4b726c47 | ||
|
|
b739c823ca | ||
|
|
41ded53e45 | ||
|
|
b67c3735c0 |
160
package-lock.json
generated
160
package-lock.json
generated
@ -31,6 +31,7 @@
|
||||
"autoprefixer": "^10.4.20",
|
||||
"clsx": "^2.1.1",
|
||||
"dexie": "^4.0.8",
|
||||
"ethers": "^6.13.5",
|
||||
"file-saver": "^2.0.5",
|
||||
"filepond": "^4.31.4",
|
||||
"filepond-plugin-file-validate-type": "^1.2.9",
|
||||
@ -10394,6 +10395,12 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/aes-js": {
|
||||
"version": "4.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||
@ -14021,6 +14028,91 @@
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/ethers": {
|
||||
"version": "6.13.5",
|
||||
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.5.tgz",
|
||||
"integrity": "sha512-+knKNieu5EKRThQJWwqaJ10a6HE9sSehGeqWN65//wE7j47ZpFhKAnHB/JJFibwwg61I/koxaPsXbXpD/skNOQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/ethers-io/"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://www.buymeacoffee.com/ricmoo"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@adraffy/ens-normalize": "1.10.1",
|
||||
"@noble/curves": "1.2.0",
|
||||
"@noble/hashes": "1.3.2",
|
||||
"@types/node": "22.7.5",
|
||||
"aes-js": "4.0.0-beta.5",
|
||||
"tslib": "2.7.0",
|
||||
"ws": "8.17.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ethers/node_modules/@adraffy/ens-normalize": {
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz",
|
||||
"integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ethers/node_modules/@noble/curves": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
|
||||
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@noble/hashes": "1.3.2"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/ethers/node_modules/@noble/hashes": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
|
||||
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 16"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/ethers/node_modules/tslib": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
|
||||
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/ethers/node_modules/ws": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
|
||||
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/event-target-shim": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||
@ -25400,6 +25492,17 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.22.4",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
|
||||
"integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
},
|
||||
"node_modules/zustand": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.0.tgz",
|
||||
@ -32593,6 +32696,11 @@
|
||||
"integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==",
|
||||
"devOptional": true
|
||||
},
|
||||
"aes-js": {
|
||||
"version": "4.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q=="
|
||||
},
|
||||
"agent-base": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||
@ -35290,6 +35398,51 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ethers": {
|
||||
"version": "6.13.5",
|
||||
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.5.tgz",
|
||||
"integrity": "sha512-+knKNieu5EKRThQJWwqaJ10a6HE9sSehGeqWN65//wE7j47ZpFhKAnHB/JJFibwwg61I/koxaPsXbXpD/skNOQ==",
|
||||
"requires": {
|
||||
"@adraffy/ens-normalize": "1.10.1",
|
||||
"@noble/curves": "1.2.0",
|
||||
"@noble/hashes": "1.3.2",
|
||||
"@types/node": "22.7.5",
|
||||
"aes-js": "4.0.0-beta.5",
|
||||
"tslib": "2.7.0",
|
||||
"ws": "8.17.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@adraffy/ens-normalize": {
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz",
|
||||
"integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw=="
|
||||
},
|
||||
"@noble/curves": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
|
||||
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
|
||||
"requires": {
|
||||
"@noble/hashes": "1.3.2"
|
||||
}
|
||||
},
|
||||
"@noble/hashes": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
|
||||
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ=="
|
||||
},
|
||||
"tslib": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
|
||||
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA=="
|
||||
},
|
||||
"ws": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
|
||||
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
|
||||
"requires": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"event-target-shim": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||
@ -43434,6 +43587,13 @@
|
||||
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="
|
||||
},
|
||||
"zod": {
|
||||
"version": "3.22.4",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
|
||||
"integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"zustand": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.0.tgz",
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"autoprefixer": "^10.4.20",
|
||||
"clsx": "^2.1.1",
|
||||
"dexie": "^4.0.8",
|
||||
"ethers": "^6.13.5",
|
||||
"file-saver": "^2.0.5",
|
||||
"filepond": "^4.31.4",
|
||||
"filepond-plugin-file-validate-type": "^1.2.9",
|
||||
|
||||
BIN
public/connect_logo.png
Normal file
BIN
public/connect_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
220
src/components/arbiusModelProcess.tsx
Normal file
220
src/components/arbiusModelProcess.tsx
Normal file
@ -0,0 +1,220 @@
|
||||
import React, { useState, useEffect, useContext } from 'react';
|
||||
import {
|
||||
CheckCircleIcon,
|
||||
ArrowPathIcon,
|
||||
ArrowUpTrayIcon,
|
||||
Cog6ToothIcon,
|
||||
ArrowDownTrayIcon,
|
||||
CheckBadgeIcon
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ArbiusState } from '@/features/arbius/arbius';
|
||||
import { useAccount } from 'wagmi';
|
||||
import { BigNumberish, ethers } from 'ethers';
|
||||
import erc20 from "@/features/arbius/abis/erc20.json"
|
||||
import Image from 'next/image';
|
||||
import arbiusBWlogo from '../../public/connect_logo.png';
|
||||
import { AlertContext } from '@/features/alert/alertContext';
|
||||
import { updateConfig } from '@/utils/config';
|
||||
|
||||
export const arbiusProcessSteps = [
|
||||
{
|
||||
icon: <ArrowUpTrayIcon className="h-5 w-5" />,
|
||||
title: "Submit Task",
|
||||
description: (arbiusState: ArbiusState) =>
|
||||
arbiusState.taskId ? (
|
||||
<a
|
||||
href={`https://arbius.ai/task/${arbiusState.taskId}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-emerald-300 underline hover:text-emerald-400"
|
||||
>
|
||||
Task Status
|
||||
</a>
|
||||
) : (
|
||||
"Submitting the task to Arbius engine..."
|
||||
),
|
||||
color: "text-emerald-400",
|
||||
bgColor: "bg-emerald-500/20"
|
||||
},
|
||||
{
|
||||
icon: <Cog6ToothIcon className="h-5 w-5" />,
|
||||
title: "Mining",
|
||||
description: "Miner is working on the task",
|
||||
color: "text-blue-400",
|
||||
bgColor: "bg-blue-500/20"
|
||||
},
|
||||
{
|
||||
icon: <ArrowDownTrayIcon className="h-5 w-5" />,
|
||||
title: "Fetching Result",
|
||||
description: (arbiusState: ArbiusState) =>
|
||||
arbiusState.ipfs ? (
|
||||
<a
|
||||
href={`${arbiusState.ipfs}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-amber-300 underline hover:text-amber-400"
|
||||
>
|
||||
IPFS result
|
||||
</a>
|
||||
) : (
|
||||
"Fetching results from IPFS..."
|
||||
),
|
||||
color: "text-amber-400",
|
||||
bgColor: "bg-amber-500/20"
|
||||
},
|
||||
{
|
||||
icon: <CheckBadgeIcon className="h-5 w-5" />,
|
||||
title: "Complete",
|
||||
description: "Process successfully completed.",
|
||||
color: "text-orange-400",
|
||||
bgColor: "bg-orange-500/20"
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
export default function ArbiusProcessIndicator({
|
||||
arbiusState,
|
||||
signer
|
||||
}: {
|
||||
arbiusState: ArbiusState;
|
||||
signer: ethers.JsonRpcSigner | undefined;
|
||||
}) {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const { alert } = useContext(AlertContext);
|
||||
const MIN_REQUIRED_BALANCE = 0.05;
|
||||
|
||||
// Get current step info
|
||||
const currentStepInfo = arbiusProcessSteps[arbiusState.currentStep];
|
||||
const isCompleted = arbiusState.currentStep === arbiusProcessSteps.length - 1 &&
|
||||
arbiusState.completedSteps.includes(arbiusProcessSteps.length - 1);
|
||||
|
||||
const { isConnected, address } = useAccount();
|
||||
const [walletBalance, setWalletBalance] = useState(0);
|
||||
const [hasInsufficientBalance, setHasInsufficientBalance] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (hasInsufficientBalance) {
|
||||
alert.error(`Insufficient AIUS tokens.`,`Minimum ${MIN_REQUIRED_BALANCE} required.`);
|
||||
updateConfig("insufficient_aius", "true");
|
||||
}
|
||||
}, [alert, hasInsufficientBalance]);
|
||||
|
||||
useEffect(() => {
|
||||
async function walletBalance() {
|
||||
try {
|
||||
const aiusTokenAddress = process.env.NEXT_PUBLIC_AIUS_TOKEN_ADDRESS as `0x${string}`;
|
||||
console.log(aiusTokenAddress, "AIUS Token Address")
|
||||
const aiusTokenContract = new ethers.Contract(
|
||||
aiusTokenAddress,
|
||||
erc20.abi,
|
||||
signer
|
||||
);
|
||||
const balance = await aiusTokenContract.balanceOf(address)
|
||||
const _walletBalance = Number(formatBalance(ethers.formatEther(balance as BigNumberish)));
|
||||
console.log("AIUS Token Balance", _walletBalance)
|
||||
setWalletBalance(_walletBalance)
|
||||
setHasInsufficientBalance(_walletBalance <= MIN_REQUIRED_BALANCE ? true : false);
|
||||
} catch (err) {
|
||||
console.log(err, "Error at AIUS wallet balance")
|
||||
setWalletBalance(0)
|
||||
}
|
||||
}
|
||||
|
||||
if (address && signer) {
|
||||
walletBalance();
|
||||
}
|
||||
}, [signer]);
|
||||
|
||||
function formatBalance(num: string) {
|
||||
if (Number.isInteger(num)) {
|
||||
return num.toString().split('.')[0];
|
||||
} else {
|
||||
const numStr = num.toString().split('.')[0];
|
||||
return numStr.length < 3 ? Number(num).toFixed(2) : numStr;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fixed top-1 right-4 flex flex-col items-end lg:items-start lg:flex-row gap-4 w-full max-w-[400px] lg:max-w-none lg:w-auto">
|
||||
|
||||
{/* AIUS Wallet Balance */}
|
||||
<div className="flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
className="group relative flex items-center gap-3 rounded-full bg-black-background px-4 py-2 transition-colors hover:bg-gray-800"
|
||||
>
|
||||
<div className="absolute inset-0 rounded-full bg-buy-hover opacity-30 group-hover:opacity-50 transition-opacity"></div>
|
||||
<div className="lato-bold relative z-10 flex items-center gap-2 text-white">
|
||||
<Image
|
||||
className="h-4 w-auto filter invert"
|
||||
src={arbiusBWlogo}
|
||||
height={20}
|
||||
alt="connected"
|
||||
/>
|
||||
<span className="text-sm font-semibold">{walletBalance}</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Arbius Model Steps */}
|
||||
<div className="flex-1 bg-gray-900/80 text-white rounded overflow-hidden shadow-md">
|
||||
{expanded && (
|
||||
<div className="mt-2 space-y-2 p-2">
|
||||
{arbiusProcessSteps.map((step, index) => {
|
||||
const isActive = index === arbiusState.currentStep;
|
||||
const isDone = arbiusState.completedSteps.includes(index);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className={`flex items-center justify-between ${isActive ? 'border-l-4 border-blue-500 bg-gray-800/50' : 'border-l-4 border-green-500 bg-gray-800/30'
|
||||
} p-2 rounded-r transition-all duration-300`}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={`p-2 rounded-full ${step.bgColor}`}>
|
||||
{step.icon}
|
||||
</div>
|
||||
<div>
|
||||
<div className={`font-medium ${step.color}`}>
|
||||
{step.title}
|
||||
</div>
|
||||
<div className="text-xs text-gray-300 max-h-[300px] overflow-auto">
|
||||
{typeof step.description === 'function'
|
||||
? step.description(arbiusState)
|
||||
: step.description}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{isActive && arbiusState.isProcessing ? (
|
||||
<ArrowPathIcon className="h-5 w-5 text-blue-400 animate-spin" />
|
||||
) : (
|
||||
isDone && <CheckCircleIcon className="h-5 w-5 text-green-500" />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Progress bar and toggle */}
|
||||
<div>
|
||||
<div className="h-1 bg-gray-800 w-full">
|
||||
<div
|
||||
className="h-full bg-gradient-to-r from-emerald-500 via-blue-500 to-orange-500 transition-all duration-500"
|
||||
style={{ width: `${(arbiusState.currentStep / (arbiusProcessSteps.length - 1)) * 100}%` }}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="py-1 px-2 bg-gray-800/80 text-xs font-mono border-t border-gray-700 cursor-pointer"
|
||||
onClick={() => setExpanded(prev => !prev)}
|
||||
>
|
||||
<span className={isCompleted ? "text-orange-500" : "text-blue-400"}>
|
||||
Status: {isCompleted ? "Completed" : arbiusState.isProcessing ? "Processing..." : hasInsufficientBalance ? "Insufficient AIUS tokens" : "Ready"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -268,7 +268,7 @@ export default function MessageInput({
|
||||
iconName="24/Send"
|
||||
className="ml-2 bg-secondary hover:bg-secondary-hover active:bg-secondary-press disabled:bg-secondary-disabled"
|
||||
isProcessing={isChatProcessing || transcriber.isBusy}
|
||||
disabled={isChatProcessing || !userMessage || transcriber.isModelLoading || config("chatbot_backend") === "moshi"}
|
||||
disabled={isChatProcessing || !userMessage || transcriber.isModelLoading || config("chatbot_backend") === "moshi" || config("insufficient_aius") === "true"}
|
||||
onClick={clickedSendButton}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -74,6 +74,8 @@ import { OpenRouterSettings } from "./settings/OpenRouterSettingsPage";
|
||||
import { ExternalAPIPage } from "./settings/ExternalAPIPage";
|
||||
import { KokoroSettingsPage } from "./settings/KokoroSettingsPage";
|
||||
|
||||
import { ConnectButton } from "@rainbow-me/rainbowkit";
|
||||
import { useAccount } from "wagmi";
|
||||
|
||||
export const Settings = ({
|
||||
onClickClose,
|
||||
@ -220,6 +222,8 @@ export const Settings = ({
|
||||
[viewer]
|
||||
);
|
||||
|
||||
const { isConnected } = useAccount();
|
||||
|
||||
function handleChangeBgImgFile(event: React.ChangeEvent<HTMLInputElement>) {
|
||||
const files = event.target.files;
|
||||
if (!files) return;
|
||||
@ -255,9 +259,18 @@ export const Settings = ({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// Change the chatbot to 'llamacpp' if Amica Life is enabled and previous chatbot was 'echo'
|
||||
if (amicaLifeEnabled && ["echo", "moshi"].includes(config("chatbot_backend"))) {
|
||||
// Set the amica life to unable if the chatbot is whether `echo` or `arbius_llm` or `moshi`
|
||||
if (amicaLifeEnabled && ["echo", "moshi", "arbius_llm"].includes(config("chatbot_backend"))) {
|
||||
setAmicaLifeEnabled(false);
|
||||
updateConfig("amica_life_enabled", "false");
|
||||
setSettingsUpdated(true);
|
||||
}
|
||||
|
||||
// Set the chatbot backend to `echo` if the wallet is not connected and the chatbot backend is `arbius_llm`
|
||||
if (["arbius_llm"].includes(config("chatbot_backend")) && !isConnected) {
|
||||
setChatbotBackend("echo");
|
||||
updateConfig("chatbot_backend", "echo");
|
||||
setSettingsUpdated(true);
|
||||
}
|
||||
}, [chatbotBackend, amicaLifeEnabled]);
|
||||
|
||||
@ -766,7 +779,7 @@ export const Settings = ({
|
||||
ref={topMenuRef}
|
||||
>
|
||||
|
||||
<nav aria-label="Breadcrumb" className="inline-block ml-4">
|
||||
<nav aria-label="Breadcrumb" className="flex ml-4 justify-between items-center">
|
||||
<ol role="list" className="flex items-center space-x-4">
|
||||
<li className="flex">
|
||||
<div className="flex items-center">
|
||||
@ -811,6 +824,7 @@ export const Settings = ({
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
<ConnectButton />
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ export function AmicaLifePage({
|
||||
<SwitchBox
|
||||
value={amicaLifeEnabled}
|
||||
label={`${t("Amica Life")} ${t("Enabled")} ${t("(Disable to improve performance)")}`}
|
||||
disabled={["echo", "moshi"].includes(config("chatbot_backend")) }
|
||||
disabled={["arbius_llm","echo", "moshi"].includes(config("chatbot_backend")) }
|
||||
onChange={(value: boolean) => {
|
||||
setAmicaLifeEnabled(value);
|
||||
updateConfig("amica_life_enabled", value.toString());
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useContext, useEffect, useState } from 'react';
|
||||
import { getWindowAI } from "window.ai";
|
||||
import { BasicPage, Link, FormRow, getLinkFromPage } from './common';
|
||||
import { updateConfig } from "@/utils/config";
|
||||
import { isTauri } from "@/utils/isTauri";
|
||||
import { AlertContext } from '@/features/alert/alertContext';
|
||||
import { useAccount } from "wagmi";
|
||||
import { Alert } from '@/features/alert/alert';
|
||||
|
||||
const chatbotBackends = [
|
||||
{key: "echo", label: "Echo"},
|
||||
@ -37,6 +40,8 @@ export function ChatbotBackendPage({
|
||||
setBreadcrumbs: (breadcrumbs: Link[]) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { alert } = useContext(AlertContext) ;
|
||||
const { isConnected } = useAccount();
|
||||
const [windowAiDetected, setWindowAiDetected] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@ -52,6 +57,19 @@ export function ChatbotBackendPage({
|
||||
})();
|
||||
}, []);
|
||||
|
||||
const handleBackendChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const selected = event.target.value;
|
||||
|
||||
if (selected === "arbius_llm" && !isConnected) {
|
||||
alert?.error("You need to connect your wallet to use", "Arbius LLM.");
|
||||
return;
|
||||
}
|
||||
|
||||
setChatbotBackend(selected);
|
||||
updateConfig("chatbot_backend", selected);
|
||||
setSettingsUpdated(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<BasicPage
|
||||
title={t("Chatbot Backend")}
|
||||
@ -63,11 +81,7 @@ export function ChatbotBackendPage({
|
||||
<select
|
||||
className="mt-2 block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-indigo-600 sm:text-sm sm:leading-6"
|
||||
value={chatbotBackend}
|
||||
onChange={(event: React.ChangeEvent<any>) => {
|
||||
setChatbotBackend(event.target.value);
|
||||
updateConfig("chatbot_backend", event.target.value);
|
||||
setSettingsUpdated(true);
|
||||
}}
|
||||
onChange={handleBackendChange}
|
||||
>
|
||||
{chatbotBackends.map((engine) => (
|
||||
<option key={engine.key} value={engine.key}>{t(engine.label)}</option>
|
||||
@ -108,3 +122,4 @@ export function ChatbotBackendPage({
|
||||
</BasicPage>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
2166
src/features/arbius/abis/arbius.json
Normal file
2166
src/features/arbius/abis/arbius.json
Normal file
File diff suppressed because it is too large
Load Diff
818
src/features/arbius/abis/erc20.json
Normal file
818
src/features/arbius/abis/erc20.json
Normal file
File diff suppressed because one or more lines are too long
229
src/features/arbius/arbius.ts
Normal file
229
src/features/arbius/arbius.ts
Normal file
@ -0,0 +1,229 @@
|
||||
import { ethers, parseUnits } from "ethers";
|
||||
import { pinFileToIPFS, cidify } from "@/utils/ipfs";
|
||||
import ArbiusAbi from "./abis/arbius.json";
|
||||
import ERC20Abi from "./abis/erc20.json";
|
||||
import { arbiusProcessSteps } from "@/components/arbiusModelProcess";
|
||||
import { config } from "@/utils/config";
|
||||
|
||||
export type ArbiusState = {
|
||||
currentStep: number;
|
||||
completedSteps: number[];
|
||||
isProcessing: boolean;
|
||||
taskId?: string;
|
||||
result?: string;
|
||||
ipfs?: string;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
const arbiusAddress = process.env.NEXT_PUBLIC_ARBIUS_ADDRESS as `0x${string}`;
|
||||
const tokenAddress = process.env.NEXT_PUBLIC_TOKEN_ADDRESS as `0x${string}`;
|
||||
|
||||
export class ArbiusModel {
|
||||
address?: string;
|
||||
signer?: ethers.Signer;
|
||||
provider?: ethers.Provider;
|
||||
wsProvider?: ethers.WebSocketProvider;
|
||||
setArbiusState?: (state: ArbiusState) => void;
|
||||
arbiusState: ArbiusState;
|
||||
|
||||
constructor() {
|
||||
this.arbiusState = {
|
||||
currentStep: 0,
|
||||
completedSteps: [],
|
||||
isProcessing: false,
|
||||
};
|
||||
}
|
||||
|
||||
public async initialize(
|
||||
signer: ethers.Signer,
|
||||
setArbiusState: (state: ArbiusState) => void
|
||||
) {
|
||||
this.signer = signer;
|
||||
this.provider = signer.provider!;
|
||||
this.wsProvider = new ethers.WebSocketProvider(process.env.NEXT_PUBLIC_WS_PROVIDER! as string);
|
||||
this.setArbiusState = setArbiusState;
|
||||
this.address = await signer.getAddress();
|
||||
|
||||
this.bootupChecks()
|
||||
}
|
||||
|
||||
private async bootupChecks() {
|
||||
const token = new ethers.Contract(tokenAddress, ERC20Abi.abi, this.signer);
|
||||
|
||||
const balance = await token.balanceOf(this.address);
|
||||
|
||||
const allowance = await token.allowance(this.address, arbiusAddress);
|
||||
console.log('AIUS Token Allowance:', ethers.formatEther(allowance));
|
||||
if (allowance < balance) {
|
||||
console.log('Approving Arbius to spend tokens');
|
||||
// Convert 10 AIUS to wei
|
||||
const amountToApprove = parseUnits('10', 18);
|
||||
const tx = await token.approve(arbiusAddress,amountToApprove);
|
||||
const receipt = await tx.wait();
|
||||
console.log('tx:', receipt.hash);
|
||||
}
|
||||
}
|
||||
|
||||
public resetState() {
|
||||
this.updateState({
|
||||
currentStep: 0,
|
||||
completedSteps: [],
|
||||
isProcessing: false,
|
||||
taskId: undefined,
|
||||
result: undefined,
|
||||
error: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
private updateState(updates: Partial<ArbiusState>) {
|
||||
if (!this.setArbiusState) return;
|
||||
this.arbiusState = { ...this.arbiusState, ...updates };
|
||||
this.setArbiusState(this.arbiusState);
|
||||
}
|
||||
|
||||
private advanceStep() {
|
||||
const { currentStep, completedSteps } = this.arbiusState;
|
||||
const nextStep = currentStep + 1;
|
||||
|
||||
if (nextStep < arbiusProcessSteps.length) {
|
||||
this.updateState({
|
||||
completedSteps: [...completedSteps, currentStep],
|
||||
currentStep: nextStep,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// Finish final step
|
||||
if (!completedSteps.includes(currentStep)) {
|
||||
this.updateState({
|
||||
completedSteps: [...completedSteps, currentStep],
|
||||
isProcessing: false,
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async getArbiusModelResponse(prompt: string): Promise<string | undefined> {
|
||||
try {
|
||||
this.resetState();
|
||||
this.updateState({ isProcessing: true });
|
||||
|
||||
const taskId = await this.submitTask(prompt);
|
||||
if (!taskId) throw new Error("Task submission failed");
|
||||
this.updateState({ taskId });
|
||||
this.advanceStep();
|
||||
|
||||
const cid = await this.waitForSolutionCID(taskId);
|
||||
const ipfs = `https://ipfs.arbius.org/ipfs/${cidify(cid)}/out-1.txt`;
|
||||
this.updateState({ ipfs });
|
||||
this.advanceStep();
|
||||
|
||||
const res = await fetch(ipfs);
|
||||
if (!res.ok) throw new Error("Failed to fetch from IPFS");
|
||||
const text = await res.text();
|
||||
|
||||
this.updateState({
|
||||
result: text,
|
||||
isProcessing: false,
|
||||
});
|
||||
this.advanceStep();
|
||||
|
||||
return text;
|
||||
} catch (err: any) {
|
||||
console.error("Failed to get model response:", err);
|
||||
this.updateState({ isProcessing: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async submitTask(prompt: string): Promise<string | undefined> {
|
||||
if (!this.signer || !this.address) throw new Error("Signer not initialized");
|
||||
|
||||
const modelId = config("arbius_llm_model_id") as `0x${string}`;
|
||||
|
||||
try {
|
||||
const input = JSON.stringify({ prompt });
|
||||
const bytes = ethers.hexlify(ethers.toUtf8Bytes(input));
|
||||
|
||||
const contract = new ethers.Contract(arbiusAddress, ArbiusAbi, this.signer);
|
||||
|
||||
const model = await contract.models(modelId);
|
||||
const fee = model[0];
|
||||
console.log("Model Fee:", ethers.formatEther(fee));
|
||||
|
||||
const tx = await contract.submitTask(0, this.address, modelId, fee, bytes);
|
||||
|
||||
const receipt = await tx.wait();
|
||||
|
||||
const taskId = receipt.logs[0].args[0];
|
||||
|
||||
const cid = await pinFileToIPFS(
|
||||
Buffer.from(input, "utf-8"),
|
||||
`task-${taskId}.json`
|
||||
);
|
||||
|
||||
console.log(`Task input pinned to IPFS with CID: ${cid}`);
|
||||
return taskId;
|
||||
} catch (err: any) {
|
||||
if (err.code === 'ACTION_REJECTED') {
|
||||
console.warn("User rejected the transaction.");
|
||||
} else {
|
||||
console.error("Failed to submit task", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async waitForSolutionCID(taskId: string): Promise<string> {
|
||||
if (!this.wsProvider) throw new Error("WebSocketProvider not set");
|
||||
|
||||
const contract = new ethers.Contract(arbiusAddress, ArbiusAbi, this.wsProvider);
|
||||
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
const listener = async (addr: string, submitTaskId: string) => {
|
||||
console.log(`Event: Solution ${submitTaskId} solved by: ${addr}`);
|
||||
|
||||
if (submitTaskId !== taskId) return;
|
||||
|
||||
try {
|
||||
const solution = await contract.solutions(submitTaskId);
|
||||
if (!solution.cid || solution.cid === "") throw new Error("Missing CID in solution");
|
||||
|
||||
contract.off("SolutionSubmitted", listener); // Clean up
|
||||
clearTimeout(timeout); // Stop timeout
|
||||
resolve(solution.cid);
|
||||
} catch (err) {
|
||||
contract.off("SolutionSubmitted", listener);
|
||||
clearTimeout(timeout);
|
||||
reject(err);
|
||||
}
|
||||
};
|
||||
|
||||
contract.on("SolutionSubmitted", listener);
|
||||
|
||||
// Optional timeout to avoid hanging forever
|
||||
const timeout = setTimeout(() => {
|
||||
contract.off("SolutionSubmitted", listener);
|
||||
reject(new Error("Timeout: No solution submitted in time"));
|
||||
}, 2 * 60 * 1000); // 2 minutes
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public async getTaskResult(taskId: string): Promise<string | undefined> {
|
||||
try {
|
||||
const cid = await this.waitForSolutionCID(taskId);
|
||||
const url = `https://ipfs.arbius.org/ipfs/${cidify(cid)}/out-1.txt`;
|
||||
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error(`Failed to fetch IPFS: ${url}`);
|
||||
|
||||
const fullText = await res.text();
|
||||
return fullText.includes("</think>")
|
||||
? fullText.split("</think>").pop()?.trim()
|
||||
: fullText;
|
||||
} catch (err) {
|
||||
console.error("Error getting task result:", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
6
src/features/arbius/arbiusContext.tsx
Normal file
6
src/features/arbius/arbiusContext.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import { createContext } from "react";
|
||||
import { ArbiusModel } from "./arbius";
|
||||
|
||||
const arbiusModel = new ArbiusModel();
|
||||
|
||||
export const ArbiusContext = createContext({ arbiusModel });
|
||||
@ -1,10 +1,19 @@
|
||||
import { buildPrompt } from "@/utils/buildPrompt";
|
||||
import { ArbiusModel } from "@/features/arbius/arbius";
|
||||
import { Message } from "./messages";
|
||||
|
||||
export async function getArbiusChatResponseStream(messages: Message[]) {
|
||||
export async function getArbiusChatResponseStream(messages: Message[], arbiusModel: ArbiusModel) {
|
||||
const prompt = buildPrompt(messages);
|
||||
const message = await arbiusModel.getArbiusModelResponse(prompt);
|
||||
|
||||
if (!message) {
|
||||
throw new Error("Arbius chat error: no message");
|
||||
}
|
||||
|
||||
const stream = new ReadableStream({
|
||||
async start(controller: ReadableStreamDefaultController) {
|
||||
try {
|
||||
let lastMessage = messages[messages.length - 1].content;
|
||||
let lastMessage = message;
|
||||
const lastChar = lastMessage.length > 0 ? lastMessage[lastMessage.length - 1] : ' ';
|
||||
if (lastChar !== '.' && lastChar !== '?' && lastChar !== '!') {
|
||||
lastMessage += ".";
|
||||
@ -22,5 +31,4 @@ export async function getArbiusChatResponseStream(messages: Message[]) {
|
||||
});
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
}
|
||||
@ -44,6 +44,7 @@ import { isCharacterIdle, characterIdleTime, resetIdleTimer } from "@/utils/isId
|
||||
import { getOpenRouterChatResponseStream } from './openRouterChat';
|
||||
import { handleUserInput } from '../externalAPI/externalAPI';
|
||||
import { loadVRMAnimation } from '@/lib/VRMAnimation/loadVRMAnimation';
|
||||
import { ArbiusModel } from "../arbius/arbius";
|
||||
|
||||
type Speak = {
|
||||
audioBuffer: ArrayBuffer | null;
|
||||
@ -60,6 +61,7 @@ export class Chat {
|
||||
public initialized: boolean;
|
||||
|
||||
public amicaLife?: AmicaLife;
|
||||
public arbiusModel?: ArbiusModel;
|
||||
public viewer?: Viewer;
|
||||
public alert?: Alert;
|
||||
|
||||
@ -120,6 +122,7 @@ export class Chat {
|
||||
|
||||
public initialize(
|
||||
amicaLife: AmicaLife,
|
||||
arbiusModel: ArbiusModel,
|
||||
viewer: Viewer,
|
||||
alert: Alert,
|
||||
setChatLog: (messageLog: Message[]) => void,
|
||||
@ -131,6 +134,7 @@ export class Chat {
|
||||
setChatSpeaking: (speaking: boolean) => void,
|
||||
) {
|
||||
this.amicaLife = amicaLife;
|
||||
this.arbiusModel = arbiusModel;
|
||||
this.viewer = viewer;
|
||||
this.alert = alert;
|
||||
this.setChatLog = setChatLog;
|
||||
@ -720,7 +724,7 @@ export class Chat {
|
||||
|
||||
switch (chatbotBackend) {
|
||||
case "arbius_llm":
|
||||
return getArbiusChatResponseStream(messages);
|
||||
return getArbiusChatResponseStream(messages, this.arbiusModel!);
|
||||
case "chatgpt":
|
||||
return getOpenAiChatResponseStream(messages);
|
||||
case "llamacpp":
|
||||
|
||||
@ -5,28 +5,20 @@ import "@/styles/globals.css";
|
||||
import "@charcoal-ui/icons";
|
||||
import type { AppProps } from "next/app";
|
||||
import {
|
||||
getDefaultConfig,
|
||||
RainbowKitProvider,
|
||||
} from '@rainbow-me/rainbowkit';
|
||||
import { WagmiProvider } from 'wagmi';
|
||||
import { arbitrum } from 'wagmi/chains';
|
||||
import {
|
||||
QueryClientProvider,
|
||||
QueryClient,
|
||||
} from "@tanstack/react-query";
|
||||
|
||||
const config = getDefaultConfig({
|
||||
appName: 'arbius.heyamica.com',
|
||||
projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!,
|
||||
chains: [arbitrum],
|
||||
ssr: true, // If your dApp uses server side rendering (SSR)
|
||||
});
|
||||
import { wagmiConfig } from '@/utils/wagmiConfig';
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
export default function App({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
<WagmiProvider config={config}>
|
||||
<WagmiProvider config={wagmiConfig}>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<RainbowKitProvider>
|
||||
<Component {...pageProps} />
|
||||
|
||||
@ -64,6 +64,11 @@ import { TimestampedPrompt } from "@/features/amicaLife/eventHandler";
|
||||
import { handleChatLogs } from "@/features/externalAPI/externalAPI";
|
||||
import { VerticalSwitchBox } from "@/components/switchBox";
|
||||
import { ThoughtText } from "@/components/thoughtText";
|
||||
import ArbiusModelOperation from "@/components/arbiusModelProcess";
|
||||
import { ArbiusContext } from "@/features/arbius/arbiusContext";
|
||||
import { useAccount, useWalletClient } from "wagmi";
|
||||
import { ArbiusState } from "@/features/arbius/arbius";
|
||||
import { ethers } from "ethers";
|
||||
|
||||
const m_plus_2 = M_PLUS_2({
|
||||
variable: "--font-m-plus-2",
|
||||
@ -117,6 +122,7 @@ export default function Home() {
|
||||
const { t, i18n } = useTranslation();
|
||||
const currLang = i18n.resolvedLanguage;
|
||||
const { viewer } = useContext(ViewerContext);
|
||||
const { arbiusModel } = useContext(ArbiusContext);
|
||||
const { alert } = useContext(AlertContext);
|
||||
const { chat: bot } = useContext(ChatContext);
|
||||
const { amicaLife: amicaLife } = useContext(AmicaLifeContext);
|
||||
@ -129,6 +135,11 @@ export default function Home() {
|
||||
const [thoughtMessage, setThoughtMessage] = useState("");
|
||||
const [shownMessage, setShownMessage] = useState<Role>("system");
|
||||
const [subconciousLogs, setSubconciousLogs] = useState<TimestampedPrompt[]>([]);
|
||||
const [arbiusState, setArbiusState] = useState<ArbiusState>({
|
||||
currentStep: 0,
|
||||
completedSteps: [],
|
||||
isProcessing: false
|
||||
});
|
||||
|
||||
// showContent exists to allow ssr
|
||||
// otherwise issues from usage of localStorage and window will occur
|
||||
@ -155,11 +166,28 @@ export default function Home() {
|
||||
|
||||
const [isVRHeadset, setIsVRHeadset] = useState(false);
|
||||
|
||||
const { isConnected } = useAccount();
|
||||
const { data: walletClient } = useWalletClient();
|
||||
const [signer, setSigner] = useState<ethers.JsonRpcSigner | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
amicaLife.checkSettingOff(!showSettings);
|
||||
}, [showSettings, amicaLife]);
|
||||
|
||||
const arbiusSelected = config("chatbot_backend") == "arbius_llm";
|
||||
useEffect(() => {
|
||||
const setupSigner = async () => {
|
||||
if (arbiusSelected && isConnected && walletClient) {
|
||||
const provider = new ethers.BrowserProvider(walletClient.transport);
|
||||
const signer = await provider.getSigner();
|
||||
|
||||
await arbiusModel.initialize(signer, setArbiusState);
|
||||
setSigner(signer);
|
||||
}
|
||||
};
|
||||
setupSigner();
|
||||
}, [isConnected, walletClient, setArbiusState, arbiusSelected]);
|
||||
|
||||
useEffect(() => {
|
||||
if (muted === null) {
|
||||
setMuted(config('tts_muted') === 'true');
|
||||
@ -292,13 +320,12 @@ export default function Home() {
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
bot.initialize(
|
||||
amicaLife,
|
||||
arbiusModel,
|
||||
viewer,
|
||||
alert,
|
||||
setChatLog,
|
||||
@ -540,6 +567,8 @@ export default function Home() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{config("chatbot_backend") == "arbius_llm" && <ArbiusModelOperation arbiusState={arbiusState} signer={signer}/> }
|
||||
|
||||
{showChatLog && <ChatLog messages={chatLog} />}
|
||||
|
||||
{/* Normal chat text */}
|
||||
|
||||
@ -20,6 +20,8 @@ import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css';
|
||||
import { vrmDataProvider } from "@/features/vrmStore/vrmDataProvider";
|
||||
import { IconButton } from '@/components/iconButton';
|
||||
|
||||
import { ConnectButton } from '@rainbow-me/rainbowkit';
|
||||
|
||||
registerPlugin(
|
||||
FilePondPluginImagePreview,
|
||||
FilePondPluginFileValidateType,
|
||||
@ -190,12 +192,13 @@ export default function Share() {
|
||||
`}
|
||||
</style>
|
||||
<div className="fixed top-0 left-0 w-full max-h-full text-black text-xs text-left z-20">
|
||||
<div className="p-2 bg-white">
|
||||
<div className="p-2 bg-white flex justify-between items-center">
|
||||
<IconButton
|
||||
iconName="24/Close"
|
||||
isProcessing={false}
|
||||
className="bg-secondary hover:bg-secondary-hover active:bg-secondary-active"
|
||||
onClick={handleCloseIcon}/>
|
||||
<ConnectButton />
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-3 max-w-md rounded-xl mt-4">
|
||||
|
||||
@ -31,6 +31,7 @@ export const defaults = {
|
||||
voice_url: process.env.NEXT_PUBLIC_VOICE_URL ?? '',
|
||||
chatbot_backend: process.env.NEXT_PUBLIC_CHATBOT_BACKEND ?? 'openai',
|
||||
arbius_llm_model_id: process.env.NEXT_PUBLIC_ARBIUS_LLM_MODEL_ID ?? 'default',
|
||||
insufficient_aius: 'false',
|
||||
openai_apikey: process.env.NEXT_PUBLIC_OPENAI_APIKEY ?? 'default',
|
||||
openai_url: process.env.NEXT_PUBLIC_OPENAI_URL ?? 'https://i-love-amica.com',
|
||||
openai_model: process.env.NEXT_PUBLIC_OPENAI_MODEL ?? 'mlabonne/NeuralDaredevil-8B-abliterated',
|
||||
|
||||
37
src/utils/ipfs.ts
Normal file
37
src/utils/ipfs.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Readable } from 'stream';
|
||||
import FormData from 'form-data';
|
||||
import { ethers } from 'ethers';
|
||||
import { base58 } from '@scure/base';
|
||||
|
||||
export function cidify(cid: string): string {
|
||||
if (! cid) {
|
||||
return '';
|
||||
}
|
||||
return base58.encode(ethers.getBytes(cid));
|
||||
}
|
||||
|
||||
export async function pinFileToIPFS(content: Buffer, filename: string) {
|
||||
const formData = new FormData();
|
||||
const blob = new Blob([content], { type: "application/json" });
|
||||
|
||||
formData.append("file", blob, { filename });
|
||||
|
||||
formData.append("pinataOptions", JSON.stringify({ cidVersion: 0 }));
|
||||
|
||||
|
||||
const res = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", {
|
||||
method: "POST",
|
||||
body: formData as any,
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.NEXT_PUBLIC_PINATA_JWT}`,
|
||||
},
|
||||
});
|
||||
if (! res.ok) {
|
||||
throw new Error(`Pinata API Error (${res.status})`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
console.log('pinning res', data);
|
||||
|
||||
return data.IpfsHash;
|
||||
}
|
||||
9
src/utils/wagmiConfig.ts
Normal file
9
src/utils/wagmiConfig.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { getDefaultConfig } from '@rainbow-me/rainbowkit';
|
||||
import { arbitrum } from 'wagmi/chains';
|
||||
|
||||
export const wagmiConfig = getDefaultConfig({
|
||||
appName: 'arbius.heyamica.com',
|
||||
projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!,
|
||||
chains: [arbitrum],
|
||||
ssr: true,
|
||||
});
|
||||
@ -23,9 +23,11 @@ module.exports = {
|
||||
M_PLUS_2: ["Montserrat", "M_PLUS_2", "sans-serif"],
|
||||
Montserrat: ["Montserrat", "sans-serif"],
|
||||
},
|
||||
backgroundImage: {
|
||||
"buy-hover":
|
||||
"linear-gradient(95.28deg, #4A28FF 17.25%, #92BDFF 123.27%)",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
require('@tailwindcss/forms'),
|
||||
],
|
||||
plugins: [require("@tailwindcss/forms")],
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user