npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

intex-js

v1.0.0

Published

Intent + Context Framework for OpenAI Function Calling

Readme

Intex: Intent + Context Framework for OpenAI Function Calling

Intex is a TypeScript framework designed to simplify the development of AI-powered applications using OpenAI's Function Calling. It provides a structured way to define intents, organize function calls, and manage conversation context.

npm version License TypeScript

📋 Table of Contents

✨ Features

  • Intent Detection: Flexible intent recognition using pattern-based matching and/or LLM-based detection
  • Contract-Based Design: Clear separation of intents, functions, and context
  • Middleware Support: Add validation, authentication, logging, or any custom processing logic
  • Plugin Architecture: Easily extend the framework with analytics, logging, performance tracking, and more
  • Storage Extensions: Flexible storage options for maintaining conversation state and context
  • Type Safety: Full TypeScript support with generics for end-to-end type checking
  • Builder Pattern: Clean, fluent API for defining intents and functions

📦 Installation

npm install intex

Or using yarn:

yarn add intex

🚀 Quick Start

Here's a basic example of creating a weather information application:

import { 
  createFunction, 
  createIntent, 
  IntentFramework 
} from 'intex';

// 1. Create a function
const getWeatherFunction = createFunction({
  name: "get_weather",
  description: "Get current weather for a location",
  parameters: {
    type: "object",
    properties: {
      location: {
        type: "string",
        description: "City name or location"
      }
    },
    required: ["location"]
  },
  handler: async (params) => {
    // Call your weather API here
    return {
      temperature: 22,
      description: "Sunny",
      location: params.location
    };
  }
});

// 2. Create an intent contract
const weatherContract = createIntent()
  .withId("weather")
  .withName("Weather Information")
  .withDescription("Get weather information for locations")
  .withPatterns(
    "weather.*in.*",
    "what.*is.*the.*weather",
    "temperature.*in.*"
  )
  .withExamples(
    "What is the weather in London?",
    "Show me weather in New York"
  )
  .withFunctions(getWeatherFunction)
  .build();

// 3. Create and configure the framework
const framework = new IntentFramework({
  openai: {
    apiKey: process.env.OPENAI_API_KEY,
    model: "gpt-3.5-turbo"
  },
  intentDetection: {
    strategy: "hybrid" // Use both pattern matching and LLM
  },
  logging: {
    enabled: true,
    level: "info"
  }
});

// 4. Register your contract
framework.registerContract(weatherContract);

// 5. Process user messages
const response = await framework.process(
  "What's the weather in Paris?",
  "conversation-123"
);

console.log(response.response); // The LLM response with weather data

🏗️ Architecture

Intex is built around several key architectural components:

  • Intent Framework: Core component that manages intents and handles request processing
  • Builders: Fluent interfaces for creating intents and functions
  • Middleware: Pluggable components that modify the processing pipeline
  • Extensions: Modular components that add functionality to the framework
  • Plugins: Self-contained modules that can monitor and interact with the framework

🧩 Core Concepts

Intents and Function Contracts

Intents represent user goals, while function contracts define the operations available to fulfill those goals.

Middleware

Middleware components allow you to intercept and modify the processing flow at different points. Common uses include:

  • Authentication and authorization
  • Rate limiting
  • Request validation
  • Logging and monitoring

Plugins

Plugins provide a way to extend the framework with additional functionality such as:

  • Performance monitoring
  • Analytics tracking
  • Advanced logging
  • Custom behaviors

Storage Extensions

Storage extensions allow you to persist conversation context and state across user interactions:

  • In-memory storage for testing
  • Custom storage implementations for production use

📚 Examples

The repository includes examples demonstrating various framework capabilities:

Basic Examples

Advanced Examples

Middleware Examples

To run an example:

# Run the weather bot example
npm run example:weather

# Run the math calculator example
npm run example:math

# Run the storage extension example
npm run example:storage-extension

📖 Documentation

For comprehensive documentation on all aspects of the framework, please refer to:

👨‍💻 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the terms of the license included with this repository.