Skip to content

Commit

Permalink
use generateObject
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 committed Jan 20, 2025
1 parent e3a4e77 commit da23468
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/plugin-lightning/src/actions/payInvoice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IAgentRuntime, Memory, State } from "@elizaos/core";
import {
composeContext,
generateObjectV2,
generateObject,
ModelClass,
elizaLogger,
} from "@elizaos/core";
Expand All @@ -25,10 +25,10 @@ export class PayInvoiceAction {
async getAvalibleChannelId(): Promise<string> {
const { channels } = await this.lightningProvider.getLndChannel();
const filteredActiveChannels = channels.filter(
(channel) => channel.is_active === true,
(channel) => channel.is_active === true
);
const sortedChannels = filteredActiveChannels.sort(
(a, b) => b.local_balance - a.local_balance,
(a, b) => b.local_balance - a.local_balance
);
if (sortedChannels.length > 0) {
return sortedChannels[0].id;
Expand All @@ -44,8 +44,9 @@ export class PayInvoiceAction {
outgoing_channel: outgoing_channel,
...params,
};
const retPayInvoice =
await this.lightningProvider.payInvoice(requestArgs);
const retPayInvoice = await this.lightningProvider.payInvoice(
requestArgs
);
return {
...retPayInvoice,
outgoing_channel: outgoing_channel,
Expand All @@ -61,7 +62,7 @@ export const payInvoiceAction = {
_message: Memory,
state: State,
_options: any,
callback?: any,
callback?: any
) => {
elizaLogger.log("payInvoice action handler called");
const lightningProvider = await initLightningProvider(runtime);
Expand All @@ -72,7 +73,7 @@ export const payInvoiceAction = {
state,
template: payInvoiceTemplate,
});
const content = await generateObjectV2({
const content = await generateObject({
runtime,
context: payInvoiceContext,
modelClass: ModelClass.LARGE,
Expand Down

0 comments on commit da23468

Please sign in to comment.