mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 07:51:41 +00:00
Add link understanding tool support (#1637)
* Add * Fix --------- Co-authored-by: Richard <dasilva333@DESKTOP-74E3GJO.localdomain>
This commit is contained in:
37
src/link-understanding/apply.ts
Normal file
37
src/link-understanding/apply.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import type { MsgContext } from "../auto-reply/templating.js";
|
||||
import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js";
|
||||
import { formatLinkUnderstandingBody } from "./format.js";
|
||||
import { runLinkUnderstanding } from "./runner.js";
|
||||
|
||||
export type ApplyLinkUnderstandingResult = {
|
||||
outputs: string[];
|
||||
urls: string[];
|
||||
};
|
||||
|
||||
export async function applyLinkUnderstanding(params: {
|
||||
ctx: MsgContext;
|
||||
cfg: ClawdbotConfig;
|
||||
}): Promise<ApplyLinkUnderstandingResult> {
|
||||
const result = await runLinkUnderstanding({
|
||||
cfg: params.cfg,
|
||||
ctx: params.ctx,
|
||||
});
|
||||
|
||||
if (result.outputs.length === 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
params.ctx.LinkUnderstanding = [...(params.ctx.LinkUnderstanding ?? []), ...result.outputs];
|
||||
params.ctx.Body = formatLinkUnderstandingBody({
|
||||
body: params.ctx.Body,
|
||||
outputs: result.outputs,
|
||||
});
|
||||
|
||||
finalizeInboundContext(params.ctx, {
|
||||
forceBodyForAgent: true,
|
||||
forceBodyForCommands: true,
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user