🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

deechat-ai-chat

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

deechat-ai-chat

A focused AI chat client for handling AI requests and tool calling in Node.js applications

latest
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

@ai-chat/core

A focused AI chat client for handling AI requests and tool calling in Node.js applications.

🎯 Core Purpose

@ai-chat is designed with a clear focus on core AI interaction:

  • AI Request Processing - Send messages to AI providers and handle responses
  • Tool Calling Coordination - Manage tool calls and results in AI conversations

This package does NOT handle:

  • ❌ Conversation history management (use context-manager)
  • ❌ Message persistence (use context-manager)
  • ❌ Session state tracking (use context-manager)
  • ❌ Token calculation and cost estimation (use dedicated token calculation packages)
  • ❌ Specific tool implementations (use mcp-client or custom providers)

🚀 Quick Start

import { AIChat } from '@ai-chat/core'

// Create AI chat client
const aiChat = new AIChat({
  provider: 'openai',
  apiKey: process.env.OPENAI_API_KEY,
  model: 'gpt-4'
})

// Send messages (you manage the conversation history)
const messages = [
  { role: 'user', content: 'Hello!' }
]

const response = await aiChat.sendMessage(messages)
console.log(response.message.content)

📖 Core API

AIChat Class

class AIChat {
  constructor(config: AIChatConfig)
  
  // Send message and get complete response
  sendMessage(
    messages: Message[], 
    options?: ChatOptions
  ): Promise<ChatResponse>
  
  // Send message and get streaming response
  sendMessageStream(
    messages: Message[],
    options?: ChatOptions  
  ): AsyncIterable<ChatStreamChunk>
}

Configuration

interface AIChatConfig {
  provider: 'openai' | 'claude' | 'gemini' | string
  apiKey: string
  model?: string
  baseUrl?: string
  temperature?: number
  maxTokens?: number
}

Tool Integration

// Tools are provided as input, not discovered by this package
const response = await aiChat.sendMessage(messages, {
  tools: [
    {
      name: "search_files",
      description: "Search for files",
      parameters: { /* JSON Schema */ }
    }
  ],
  onToolCall: async (call) => {
    // Your tool execution logic here
    // This could call mcp-client, local functions, etc.
    return {
      toolCallId: call.id,
      result: await executeMyTool(call.name, call.arguments)
    }
  }
})

🌊 Streaming Example

const stream = aiChat.sendMessageStream(messages, {
  tools: myTools,
  onToolCall: handleToolCall
})

for await (const chunk of stream) {
  if (chunk.content) {
    process.stdout.write(chunk.content)
  }
  
  if (chunk.toolCalls) {
    console.log('AI wants to call tools:', chunk.toolCalls)
  }
  
  if (chunk.done) {
    console.log('\nResponse complete!')
    break
  }
}

🏗️ Architecture Integration

This package is designed to work alongside other focused packages:

// Example: Complete DeeChat integration
import { AIChat } from '@ai-chat/core'
import { ContextManager } from '@context-manager'  
import { MCPClient } from '@mcp-client'

// Each package handles its own responsibility
const aiChat = new AIChat(aiConfig)           // AI communication
const contextManager = new ContextManager()   // History & state
const mcpClient = new MCPClient()             // Tool implementation

// Compose them together
const sessionId = 'session-123'
const history = contextManager.getMessages(sessionId)

const response = await aiChat.sendMessage(
  [...history, { role: 'user', content: userInput }],
  {
    tools: await mcpClient.getTools(),
    onToolCall: (call) => mcpClient.executeTools(call)
  }
)

// Update context with response
contextManager.addMessage(sessionId, response.message)

🎯 Features

  • Multiple AI Providers: OpenAI, Claude, Gemini support
  • Streaming Responses: Real-time response streaming
  • Tool Calling: Coordinate tool execution without managing tools
  • TypeScript First: Full type safety and IntelliSense
  • Lightweight: Focused scope, minimal dependencies
  • Framework Agnostic: Works in any Node.js environment

📦 Installation

npm install @ai-chat/core

# Peer dependencies (install the providers you need)
npm install openai anthropic  # for AI providers

📚 Documentation

核心文档

  • API 设计文档 - 详细的 API 设计和类型定义
  • 产品需求文档 - 完整的产品需求和用户故事
  • 架构设计 - 技术架构和设计决策

开发文档

🤝 Contributing

We welcome contributions! Please see our Contributing Guide.

📄 License

MIT License - see LICENSE file for details.

Keywords

ai

FAQs

Package last updated on 07 Sep 2025

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