Skip to main content

Overview

The @feedback/ai package provides a comprehensive AI toolkit for the GTM Feedback platform, including specialized agents for Slack integration, request matching, search, analytics, and identity resolution. Built on top of the Vercel AI SDK with support for OpenAI and Anthropic models.

Installation

npm install @feedback/ai

Package Information

name
string
@feedback/ai
version
string
0.0.1
dependencies
object
  • @ai-sdk/openai: ^3.0.0
  • @ai-sdk/devtools: 0.0.1
  • @upstash/vector: ^1.0.0
  • ai: 6.0.5
  • zod: ^4.2.1

Exports

The package provides multiple export paths for different functionalities:

Main Export

import * from '@feedback/ai'
Re-exports all functionality from the Vercel AI SDK (ai package).

Models

import { claudeSonnet, claudeHaiku, gpt4oMini } from '@feedback/ai/models'
claudeSonnet
LanguageModel
Wrapped Claude Sonnet 4 model with DevTools middleware (development only)
claudeHaiku
LanguageModel
Wrapped Claude Haiku 4.5 model with DevTools middleware (development only)
gpt4oMini
LanguageModel
Wrapped GPT-4o Mini model with DevTools middleware (development only)

Agents

import { agent, createAgent } from '@feedback/ai/agents'
The default agent instance provides access to all specialized agents:
import { agent } from '@feedback/ai/agents'

// Use Slack agent to extract customer pain from a message
const result = await agent.slack.generate({
  mode: 'extract',
  ref: { channel: 'C123', threadTs: '1234567890.123456' }
})

// Use Request agent to match customer pain to existing requests
const match = await agent.request.generate({
  customerPain: "Users can't export data to CSV",
  candidates: existingRequests,
  mode: 'match'
})

Agent Types

agent.slack
AgentSlack
Extract customer pain from Slack messages, compose notifications, and chat with usersMethods:
  • generate(input): Extract pain or compose messages
  • chat(input): Stream chat responses
agent.request
AgentRequest
Match customer pain to existing requests or generate new request detailsMethods:
  • generate(input): Match, create, or find related requests
Search and rank requests based on semantic similarityMethods:
  • generate(input): Search requests and return ranked matches
agent.analytics
AgentAnalytics
Generate insights and analytics for areas or requestsMethods:
  • generate(input): Generate analytics sections with visuals
agent.identity
AgentIdentity
Resolve user identity from email addressesMethods:
  • generate(input): Match email to user ID

Specialized Agents

import { createSlackAgent } from '@feedback/ai/agents/slack'
import { createRequestAgent } from '@feedback/ai/agents/requests'
import { createSearchAgent } from '@feedback/ai/agents/search'
import { createAnalyticsAgent } from '@feedback/ai/agents/analytics'
import { createIdentityAgent } from '@feedback/ai/agents/identity'

Embeddings

import {
  createRequestEmbedding,
  createRequestEmbeddings,
  storeRequestEmbedding,
  storeRequestEmbeddings,
  findSimilarRequests,
  updateRequestEmbedding,
  deleteRequestEmbedding
} from '@feedback/ai/embeddings'
createRequestEmbedding
function
Creates an embedding vector for a single requestParameters:
  • title (string): Request title
  • description (string): Request description
  • apiKey (string): OpenAI API key
Returns: Promise<number[] | null>
createRequestEmbeddings
function
Creates embedding vectors for multiple requests in batchParameters:
  • items (Array): Array of { title, description } objects
  • apiKey (string): OpenAI API key
Returns: Promise<number[][] | null>
storeRequestEmbedding
function
Stores an embedding in Upstash VectorParameters:
  • requestId (string): Unique request identifier
  • embedding (number[]): 384-dimensional embedding vector
  • url (string): Upstash Vector REST URL
  • token (string): Upstash Vector REST token
  • metadata (object, optional): Additional metadata
Returns: Promise<boolean>
storeRequestEmbeddings
function
Stores multiple embeddings in batchParameters:
  • items (Array): Array of { requestId, embedding, metadata? } objects
  • url (string): Upstash Vector REST URL
  • token (string): Upstash Vector REST token
Returns: Promise<Set<string>> - Set of successfully stored request IDs
findSimilarRequests
function
Searches for similar requests using vector similarityParameters:
  • embedding (number[]): Query embedding vector
  • url (string): Upstash Vector REST URL
  • token (string): Upstash Vector REST token
  • limit (number, optional): Maximum results (default: 10)
  • excludeIds (string[], optional): Request IDs to exclude
Returns: Promise<Array<{ id, score, metadata? }>>
updateRequestEmbedding
function
Updates an existing embedding (alias for storeRequestEmbedding)Parameters: Same as storeRequestEmbeddingReturns: Promise<boolean>
deleteRequestEmbedding
function
Deletes an embedding from Upstash VectorParameters:
  • requestId (string): Request identifier to delete
  • url (string): Upstash Vector REST URL
  • token (string): Upstash Vector REST token
Returns: Promise<boolean>

Key Types

Agent Types

export interface AgentResult<T> {
  output: T
  usage?: {
    inputTokens: number
    outputTokens: number
  }
  steps?: number
}

Usage Examples

import { agent } from '@feedback/ai/agents'

const result = await agent.slack.generate({
  mode: 'extract',
  ref: {
    channel: 'C123456',
    threadTs: '1234567890.123456'
  }
})

if (result.output.type === 'extraction') {
  console.log('Customer pain:', result.output.painDescription)
  console.log('Is customer-specific:', result.output.isCustomerSpecific)
}

Environment Variables

OPENAI_API_KEY
string
required
OpenAI API key for embeddings and GPT models
UPSTASH_VECTOR_REST_URL
string
required
Upstash Vector REST API URL for embedding storage
UPSTASH_VECTOR_REST_TOKEN
string
required
Upstash Vector REST API token for authentication
NODE_ENV
string
Set to ‘development’ to enable AI DevTools middleware

Build docs developers (and LLMs) love