Skip to content

Commit

Permalink
feat: update package version to 0.0.6-alpha.1 and modify dependencies…
Browse files Browse the repository at this point in the history
…; refactor audio response handling in generateAudio function
  • Loading branch information
bucurdavid committed Feb 17, 2025
1 parent 87c6e2e commit 3ecd800
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aithranetwork/plugin-aithra-toolkit",
"version": "0.0.5-alpha.2",
"version": "0.0.6-alpha.1",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
Expand All @@ -23,7 +23,7 @@
],
"dependencies": {
"@aithranetwork/sdk-aithra-toolkit": "0.0.7-alpha.1",
"@elizaos/core": "0.25.6-alpha.1",
"@elizaos/core": "workspace:*",
"@solana/spl-token": "^0.4.12",
"@solana/web3.js": "1.95.8",
"bs58": "^6.0.0",
Expand All @@ -37,6 +37,7 @@
"tsup": "8.3.5"
},
"scripts": {
"build":"tsup --format esm --dts",
"preinstall:stable": "node -e \"const p=require('./package.json');require('child_process').exec('npm view @elizaos/core versions --json',(e,o)=>{const v=JSON.parse(o).filter(v=>!v.includes('alpha')&&!v.includes('beta')).pop();p.dependencies['@elizaos/core']=v;require('fs').writeFileSync('./package.json',JSON.stringify(p,null,2))});\"",
"preinstall:develop": "node -e \"const p=require('./package.json');require('child_process').exec('npm view @elizaos/core versions --json',(e,o)=>{const v=JSON.parse(o).pop();p.dependencies['@elizaos/core']=v;require('fs').writeFileSync('./package.json',JSON.stringify(p,null,2))});\"",
"build:stable": "tsup --format esm --dts",
Expand Down
26 changes: 12 additions & 14 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,20 @@ export async function generateAudio({
};

const response = await replicate.run("minimax/music-01", { input });


if (response instanceof ReadableStream) {
const reader = response.getReader();
const chunks: Uint8Array[] = [];

while (true) {
const { done, value } = await reader.read();
if (done) break;
chunks.push(value);

if (typeof response.toString() === "string") {
try {
const audioResponse = await fetch(response.toString());
const arrayBuffer = await audioResponse.arrayBuffer();
return Result.ok(Buffer.from(arrayBuffer));
} catch (error) {
return Result.err(
new Error(
`Failed to fetch audio from URL: ${error.message}`
)
);
}

const audioBuffer = Buffer.concat(chunks.map(chunk => Buffer.from(chunk)));
return Result.ok(audioBuffer);
}


return Result.err(new Error('Invalid response format from Replicate API'));
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/paymentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class PaymentsService {
// First try SOL transfer
const solResult = await this.getSolTransferDetails(paymentHash);

if (solResult.isOk) {
if (solResult.isOk()) {
const { receiver, sender, amount } = solResult.unwrap();

if (sender !== walletAddress || receiver !== this.walletPublicKey) {
Expand Down Expand Up @@ -185,7 +185,7 @@ export class PaymentsService {
// If not SOL transfer, try SPL token transfer
const splResult = await this.getSplTransferDetails(paymentHash);

if (splResult.isOk) {
if (splResult.isOk()) {
const { receiver, sender, amount } = splResult.unwrap();

const sourceAta = getAssociatedTokenAddressSync(this.AITHRA_MINT, new PublicKey(walletAddress), true);
Expand Down

0 comments on commit 3ecd800

Please sign in to comment.