GraphQL Agent Tool - v0.0.2
    Preparing search index...

    Class GraphqlAgentTool

    A tool that LLM models can use to execute GraphQL queries and mutations. This tool is useful for agents that need to execute GraphQL queries and mutations.

    import { GraphqlAgentTool } from "graphql-agent-tool";

    const graphqlCapitalTool = new GraphqlAgentTool({
    name: "getCountryCapital",
    purpose:
    "Retrieves the capital city of a country using its ISO country code. The tool expects a country code in ISO format (e.g., 'IN' for India, 'US' for United States). Input should be provided in the format {variables: {countryCode: <countryCode>}}.",
    url: "https://countries.trevorblades.com",
    query: `
    query GetCountryCapital($countryCode: ID!) {
    country(code: $countryCode) {
    capital
    }
    }
    `,
    }).getTool();

    const modelWithTools = mistralModel.bindTools([graphqlCapitalTool]);
    const response = await modelWithTools.invoke(prompt);

    console.log(response);

    For more examples, see the examples directory.

    Index

    Constructors

    Accessors

    Methods

    Constructors

    • The constructor for the GraphqlAgentTool class.

      Parameters

      • options: {
            config?: AxiosRequestConfig<any>;
            name: string;
            purpose: string;
            query: string;
            responseParser?: (...args: [unknown, ...unknown[]]) => unknown;
            url: string;
        }

        The options for the GraphqlAgentTool class. See GraphqlAgentToolOptions for more details.

      Returns GraphqlAgentTool

    Accessors

    Methods

    • Returns the tool object that can be used by the LLM. See examples for more details.

      Returns DynamicStructuredTool<
          ZodObject<
              { variables: ZodRecord<ZodString, ZodUnknown> },
              "strip",
              ZodTypeAny,
              { variables: Record<string, unknown> },
              { variables: Record<string, unknown> },
          >,
          { variables: Record<string, unknown> },
          { variables: Record<string, unknown> },
      >