Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@llamaindex/autotool

Package Overview
Dependencies
Maintainers
0
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@llamaindex/autotool

auto transpile your JS function to LLM Agent compatible

  • 5.0.23
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@llamaindex/autotool

Auto transpile your JS function to LLM Agent compatible

Usage

First, Install the package

npm install @llamaindex/autotool
pnpm add @llamaindex/autotool
yarn add @llamaindex/autotool

Second, Add the plugin/loader to your configuration:

Next.js

import { withNext } from "@llamaindex/autotool/next";

/** @type {import('next').NextConfig} */
const nextConfig = {};

export default withNext(nextConfig);

Node.js

node --import @llamaindex/autotool/node ./path/to/your/script.js

Third, add "use tool" on top of your tool file or change to .tool.ts.

"use tool";

export function getWeather(city: string) {
  // ...
}
// ...

Finally, export a chat handler function to the frontend using llamaindex Agent

"use server";

// imports ...

export async function chatWithAI(message: string): Promise<JSX.Element> {
  const agent = new OpenAIAgent({
    tools: convertTools("llamaindex"),
  });
  const uiStream = createStreamableUI();
  agent
    .chat({
      stream: true,
      message,
    })
    .then(async (responseStream) => {
      return responseStream.pipeTo(
        new WritableStream({
          start: () => {
            uiStream.append("\n");
          },
          write: async (message) => {
            uiStream.append(message.response.delta);
          },
          close: () => {
            uiStream.done();
          },
        }),
      );
    });
  return uiStream.value;
}

License

MIT

FAQs

Package last updated on 27 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc