Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7962a7492 | ||
|
|
1b639d0d4f | ||
|
|
2e919d24c3 | ||
|
|
d6ee6dd79d | ||
|
|
cad27eb98b | ||
|
|
c17cea3a6e | ||
|
|
90d8efa767 | ||
|
|
34a4484eee | ||
|
|
9292f678e8 | ||
|
|
1d4b726c47 | ||
|
|
b739c823ca | ||
|
|
41ded53e45 | ||
|
|
b67c3735c0 |
@ -3,6 +3,7 @@ NEXT_PUBLIC_AMICA_API_URL=https://store.heyamica.com
|
||||
NEXT_PUBLIC_AMICA_STORAGE_URL=https://vrm.heyamica.com/file/amica-vrm
|
||||
NEXT_PUBLIC_SUPABASE_URL=https://kzfcwefqffysqsjrlyld.supabase.co
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imt6ZmN3ZWZxZmZ5c3FzanJseWxkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDEyNzA5NjUsImV4cCI6MjAxNjg0Njk2NX0.z9zm2mbJu6RkdZ6zkCUltThIF43-ava_bLvk9qFQsiA
|
||||
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=9f8cee238fde4f0011880ecef0616c88
|
||||
|
||||
X_API_KEY="X_API_KEY"
|
||||
X_API_SECRET="X_API_SECRET"
|
||||
|
||||
10582
package-lock.json
generated
10582
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -28,11 +28,13 @@
|
||||
"@mkkellogg/gaussian-splats-3d": "^0.4.5",
|
||||
"@next/third-parties": "^14.2.16",
|
||||
"@pixiv/three-vrm": "^3.1.2",
|
||||
"@rainbow-me/rainbowkit": "^2.2.0",
|
||||
"@ricky0123/vad-react": "^0.0.24",
|
||||
"@sentry/nextjs": "^8.34.0",
|
||||
"@supabase/supabase-js": "^2.45.4",
|
||||
"@tabler/icons-react": "^3.19.0",
|
||||
"@tailwindcss/forms": "^0.5.9",
|
||||
"@tanstack/react-query": "^5.59.16",
|
||||
"@testing-library/jest-dom": "^6.5.0",
|
||||
"@webxr-input-profiles/assets": "^1.0.16",
|
||||
"@webxr-input-profiles/motion-controllers": "^1.0.0",
|
||||
@ -40,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",
|
||||
@ -64,6 +67,8 @@
|
||||
"three.quarks": "^0.15.5",
|
||||
"twitter-api-v2": "^1.19.0",
|
||||
"typescript-collections": "^1.3.3",
|
||||
"viem": "^2.21.37",
|
||||
"wagmi": "^2.12.25",
|
||||
"wavefile": "^11.0.0",
|
||||
"webm-duration-fix": "^1.0.4",
|
||||
"window.ai": "^0.2.4",
|
||||
|
||||
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 |
@ -1,3 +1,6 @@
|
||||
import { useAccount } from 'wagmi'
|
||||
import { ConnectButton } from '@rainbow-me/rainbowkit';
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const ArbiusIntroduction = ({ open, close }: {
|
||||
@ -5,8 +8,10 @@ export const ArbiusIntroduction = ({ open, close }: {
|
||||
close: () => void;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { address } = useAccount();
|
||||
|
||||
if (!open) {
|
||||
|
||||
if (! open) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -24,15 +29,23 @@ export const ArbiusIntroduction = ({ open, close }: {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="my-8 flex space-x-4">
|
||||
<ConnectButton />
|
||||
</div>
|
||||
<div className="my-8">
|
||||
<button
|
||||
onClick={() => {
|
||||
close();
|
||||
}}
|
||||
className="ml-3 inline-flex items-center rounded-md bg-white px-2.5 py-1.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
{t("Continue to Amica")}
|
||||
</button>
|
||||
{address && (
|
||||
<button
|
||||
onClick={() => {
|
||||
close();
|
||||
}}
|
||||
className="ml-3 inline-flex items-center rounded-md bg-white px-2.5 py-1.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
{t("Continue to Amica")}
|
||||
</button>
|
||||
)}
|
||||
{(!address) && (
|
||||
<p>{t("Please connect your wallet to continue.")}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
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":
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
MeshBVHHelper,
|
||||
StaticGeometryGenerator,
|
||||
} from "three-mesh-bvh";
|
||||
// import { GenerateMeshBVHWorker } from "@/workers/bvh/GenerateMeshBVHWorker";
|
||||
import { GenerateMeshBVHWorker } from "@/workers/bvh/GenerateMeshBVHWorker";
|
||||
import { WorkerBase } from "@/workers/bvh/utils/WorkerBase";
|
||||
// Temp Disable : WebXR
|
||||
// import {
|
||||
@ -498,7 +498,7 @@ export class Viewer {
|
||||
statsMesh.scale.setScalar(2.5);
|
||||
igroup.add(statsMesh);
|
||||
|
||||
// this.bvhWorker = new GenerateMeshBVHWorker();
|
||||
this.bvhWorker = new GenerateMeshBVHWorker();
|
||||
this.raycaster.firstHitOnly = true;
|
||||
|
||||
// Temp Disable : WebXR
|
||||
|
||||
@ -1,171 +0,0 @@
|
||||
{
|
||||
"Amica Life": "Vida de Amica",
|
||||
"Set min max interval range": "Establecer rango de intervalo mínimo y máximo",
|
||||
"Set time before bot go to sleep": "Establecer tiempo antes de que el bot se duerma",
|
||||
"Min": "Mín",
|
||||
"Max": "Máx",
|
||||
"Idle text prompt": "Mensaje de texto inactivo",
|
||||
"add_to_homescreen": "Añadir Amica a la pantalla de inicio",
|
||||
"add_to_homescreen_desc": "Amica se puede instalar localmente para una carga más rápida y una interfaz más limpia.",
|
||||
"Accept": "Aceptar",
|
||||
"Decline": "Rechazar",
|
||||
"Close": "Cerrar",
|
||||
"Restart": "Reiniciar",
|
||||
"Save": "Guardar",
|
||||
"Load": "Cargar",
|
||||
"Load Chat": "Cargar chat",
|
||||
"YOU": "TÚ",
|
||||
"Welcome to Amica": "Bienvenido a Amica",
|
||||
"amica_intro": "\nAmica es una interfaz de chatbot de código abierto que proporciona Emoción, visión, animaciones, acciones autoactivadas, funciones de texto a voz y voz a texto. Está diseñado para conectarse a cualquier modelo de IA. Se puede usar con cualquier modelo>
|
||||
|
||||
"Setup": "Configuración",
|
||||
|
||||
"amica_setup": "Haz clic en la esquina superior izquierda de la pantalla para abrir la configuración. Puedes cambiar la voz, el mensaje del sistema de caracteres, compartir/cargar/guardar y conectar a diferentes backends o modelos del navegador. Consulta nuestra docume>
|
||||
|
||||
"Read the full documents here": "Lee la documentación completa aquí",
|
||||
|
||||
"dont_show_again": "No volver a mostrar",
|
||||
|
||||
"Background Color": "Color de fondo",
|
||||
"bg_color_desc": "Configura el color de fondo. Esto anula la imagen de fondo.",
|
||||
"no_bg_color": "No hay color de fondo establecido. Haz clic en el cuadro de abajo.",
|
||||
"Color": "Color",
|
||||
"Load image": "Cargar imagen",
|
||||
"bg_youtube_desc": "Selecciona un vídeo de fondo. Copia esto del ID del vídeo de YouTube de la URL; se verá similar a kDCXBwzSI",
|
||||
"Background Video": "Vídeo de fondo",
|
||||
"YouTube Video ID": "ID del vídeo de YouTube",
|
||||
"Character Animation": "Animación del personaje",
|
||||
"Select the animation to play": "Selecciona la animación que se reproducirá",
|
||||
"Animation": "Animación",
|
||||
"Character Model": "Modelo del personaje",
|
||||
"character_desc": "Selecciona el personaje que quieres interpretar; actualmente, solo Amica, por defecto, tiene todas las emociones. Carga aquí tus propios VRM.",
|
||||
"Load VRM": "Cargar VRM",
|
||||
"Chatbot Backend": "Chatbot Backend",
|
||||
"Chatbot_Backend_desc": "Selecciona el backend del chatbot que quieres usar. Echo simplemente responde con lo que escribes y se usa para pruebas y demostraciones. Por defecto, Amica está configurado para usar nuestros servidores de demostración, lo que puede tardar un >
|
||||
"Configure": "Configurar",
|
||||
"Click here to configure": "Haz clic aquí para configurar",
|
||||
"Appearance": "Apariencia",
|
||||
"ChatBot": "ChatBot",
|
||||
"Text-to-Speech": "Texto a voz",
|
||||
"Speech-to-text": "Voz a texto",
|
||||
"Vision": "Visión",
|
||||
"Reset Settings": "Restablecer configuración",
|
||||
"Community": "Comunidad",
|
||||
"Discord": "Discord",
|
||||
"Background Image": "Imagen de fondo",
|
||||
"ChatBot Backend": "Backend del ChatBot",
|
||||
"Echo": "Echo",
|
||||
"ChatGPT": "ChatGPT",
|
||||
"LLama.cpp": "LLama.cpp",
|
||||
"Ollama": "Ollama",
|
||||
"KoboldAI": "KoboldAI",
|
||||
"Window.ai": "Window.ai",
|
||||
"Name": "Nombre",
|
||||
"System Prompt": "Indicador del sistema",
|
||||
"TTS": "TTS",
|
||||
"TTS Backend": "TTS Backend",
|
||||
"Piper": "Piper",
|
||||
"ElevenLabs": "ElevenLabs",
|
||||
"SpeechT5": "SpeechT5",
|
||||
"Coqui": "Coqui",
|
||||
"OpenAI": "OpenAI",
|
||||
"Vision Backend": "Vision Backend",
|
||||
"STT Backend": "STT Backend",
|
||||
"Whisper (OpenAI)": "Whisper (OpenAI)",
|
||||
"Whisper.cpp": "Whisper.cpp",
|
||||
"Wake Word": "Activar Word",
|
||||
"Reset to Default": "Restablecer valores predeterminados",
|
||||
"community_desc": "Únete a la comunidad de Amica para conectar con otros que exploran esta tecnología.",
|
||||
"Telegram": "Telegram",
|
||||
"Twitter": "Twitter",
|
||||
"Documentation": "Documentación",
|
||||
"Settings": "Configuración",
|
||||
"piper_desc": "Configurar Piper",
|
||||
"coqui_desc": "Configurar Coqui (Local); Coqui se ejecuta localmente y no se utiliza la API de Coqui (donde la empresa ha dejado de proporcionar un servicio de API).",
|
||||
"not_using_alert": "Actualmente no estás usando {{name}} como tu backend {{what}}. Esta configuración no se utilizará.",
|
||||
"API Key": "Clave de API",
|
||||
"Voice ID": "ID de voz",
|
||||
"elevenLabs_desc": "Configurar ElevenLabs",
|
||||
"kobold_cpp_desc": "KoboldCpp es Un software de generación de texto con IA fácil de usar para modelos GGML y GGUF.",
|
||||
"API URL": "API URL",
|
||||
"llama.cpp": "llama.cpp",
|
||||
"llama_cpp_desc": "LLama.cpp es un backend de chatbot gratuito y de código abierto. Debes compilar el servidor desde el código fuente y ejecutarlo en tu propio ordenador. Puedes obtener el código fuente desde",
|
||||
"GitHub": "GitHub",
|
||||
"cfg_avatar_name_desc": "Configura el nombre del avatar. Este es el nombre que se utiliza para generar la respuesta del chatbot.",
|
||||
"ollama_desc": "Ollama te permite empezar a trabajar con grandes modelos de lenguaje localmente. Descargar desde",
|
||||
"ollama.ai": "ollama.ai",
|
||||
"Model": "Modelo",
|
||||
"OpenAI TTS": "OpenAI TTS",
|
||||
"OpenAI_tts_desc": "Configurar OpenAI TTS",
|
||||
"Voice": "Voz",
|
||||
"Reset All Settings": "Restablecer todos los ajustes",
|
||||
"SpeechT5_desc": "Configurar SpeechT5",
|
||||
"STT": "STT",
|
||||
"STT_desc": "Seleccionar el backend de STT a usar",
|
||||
"System_Prompt_desc": "Configurar el mensaje del sistema. Este es el mensaje que se utiliza para generar la respuesta del chatbot",
|
||||
"TTS_Backend_desc": "Seleccionar el backend de TTS a usar. Por defecto, está configurado en nuestro servidor de TTS. Elevenlabs es un servicio de pago con la mejor voz, pero es gratuito para uso no comercial. SpeechT5 es>",
|
||||
"Vision_Backend_desc": "Seleccionar el backend de Vision a usar",
|
||||
"Vision_System_Prompt_desc": "Configurar el mensaje del sistema de visión. Este es el mensaje que se utiliza para generar las descripciones de las imágenes.",
|
||||
|
||||
"Whisper_cpp_desc": "Configurar Whisper.cpp",
|
||||
|
||||
"URL": "URL",
|
||||
|
||||
"Whisper_OpenAI_desc": "Configurar Whisper (OpenAI)",
|
||||
|
||||
"OpenAI URL": "URL de OpenAI",
|
||||
|
||||
"Error!": "¡Error!",
|
||||
|
||||
"Something went wrong.": "Algo salió mal.",
|
||||
|
||||
"Try again later.": "Inténtalo de nuevo más tarde.",
|
||||
|
||||
"Click here": "Haz clic aquí",
|
||||
|
||||
"to return to homepage.": "Para volver a la página principal.",
|
||||
|
||||
"Import": "Importar",
|
||||
|
||||
"Description": "Descripción",
|
||||
|
||||
"Vision System Prompt": "Mensaje del sistema de visión",
|
||||
"Background Url": "URL de fondo",
|
||||
|
||||
"Youtube Video Id": "ID del vídeo de YouTube",
|
||||
|
||||
"VRM Url": "URL de VRM",
|
||||
|
||||
"Animation Url": "Animación Url",
|
||||
"Voice Url": "URL de voz",
|
||||
"Upload VRM": "Subir VRM",
|
||||
"VRM upload message": "El VRM de este personaje se guarda localmente",
|
||||
"VRM local share message": "Para compartir este personaje, debes subir el VRM al servidor",
|
||||
"Import character": "Importar personaje",
|
||||
"Wrong place?": "¿Lugar equivocado?",
|
||||
"Go home": "Ir a inicio",
|
||||
"Please enter the code you received from the share page": "Introduce el código que recibiste de la página para compartir",
|
||||
"Code": "Código",
|
||||
"Provide a description of the character": "Proporciona una descripción del personaje",
|
||||
"Background URL": "URL de fondo",
|
||||
"Example": "Ejemplo",
|
||||
"Save Character": "Guardar personaje",
|
||||
"Share this code (click to copy):": "Comparte este código (click to copy):",
|
||||
"Or, you can share this direct link:": "O puedes compartir este enlace directo:",
|
||||
"Conversación": "Conversación",
|
||||
"Depurar": "Depurar",
|
||||
"Importar Carácter": "Importar Carácter",
|
||||
"Copiar URL": "Copiar URL",
|
||||
"Vista Previa": "Vista Previa",
|
||||
"Ninguno": "Ninguno",
|
||||
"Conversión de Voz a Texto": "Conversión de Voz a Texto",
|
||||
"Establecer tiempo antes de que el bot se inactive": "Establecer tiempo antes de que el bot se inactive",
|
||||
"tiempo antes de que el bot se inactive": "tiempo antes de que el bot se inactive",
|
||||
"Palabra de Activación": "Palabra de Activación",
|
||||
"Especificar": "Especificar",
|
||||
"seg": "seg",
|
||||
"Usar": "Usar",
|
||||
"Establecer": "Establecer",
|
||||
"Habilitado": "Habilitado",
|
||||
"STOP SECUENCIA": "STOP SECUENCIA"
|
||||
}
|
||||
@ -1,10 +1,29 @@
|
||||
import '@/i18n';
|
||||
|
||||
import '@rainbow-me/rainbowkit/styles.css';
|
||||
import "@/styles/globals.css";
|
||||
import "@charcoal-ui/icons";
|
||||
import type { AppProps } from "next/app";
|
||||
import {
|
||||
RainbowKitProvider,
|
||||
} from '@rainbow-me/rainbowkit';
|
||||
import { WagmiProvider } from 'wagmi';
|
||||
import {
|
||||
QueryClientProvider,
|
||||
QueryClient,
|
||||
} from "@tanstack/react-query";
|
||||
import { wagmiConfig } from '@/utils/wagmiConfig';
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
export default function App({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
<Component {...pageProps} />
|
||||
<WagmiProvider config={wagmiConfig}>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<RainbowKitProvider>
|
||||
<Component {...pageProps} />
|
||||
</RainbowKitProvider>
|
||||
</QueryClientProvider>
|
||||
</WagmiProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -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