{"_id":"@abstraxn/chat-ai","_rev":"4-11ff094a2cebd195cd9c0b2ae7f11d30","name":"@abstraxn/chat-ai","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@abstraxn/chat-ai","version":"0.0.1","keywords":["chatai","RAG","Abstraxn","SDK","AskAI"],"author":{"name":"Pankaj Kumar","email":"pankaj.kumar@antiersolutions.com"},"license":"MIT","_id":"@abstraxn/chat-ai@0.0.1","maintainers":[{"name":"jaskaran449","email":"jaskaran.singh@antiersolutions.com"},{"name":"sandeep_sj","email":"sandeepsj26899@gmail.com"},{"name":"pankaj829","email":"pankajdogra829@gmail.com"}],"dist":{"shasum":"451eaed2de6db8b88867ae3af2dcfe6c7df8977b","tarball":"https://registry.npmjs.org/@abstraxn/chat-ai/-/chat-ai-0.0.1.tgz","fileCount":14,"integrity":"sha512-AgfQv2kdpsAJdQR31GsL5o2Kiir0b8XUtC/qvBDY8401yAk7MLFkFa5Z4X8HCAeZUBJ+eExbeKZhm/YzdRrzYg==","signatures":[{"sig":"MEQCID+Y+ka7anhToyDuaHV0lyegztLF8MCOIRXQFKzalsFyAiBsL5B03MNeRlWmN2OTdIIC3A3hAO9iFB7UmxmcniQSNg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22987},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14.0.0"},"gitHead":"141cea99c23610e4cac918e4116754a080e4beba","scripts":{"build":"rimraf dist && tsc"},"_npmUser":{"name":"pankaj829","email":"pankajdogra829@gmail.com"},"_npmVersion":"10.9.2","description":"Abstraxn ChatAI package for Simple and efficient communication with ChatAI API","directories":{},"_nodeVersion":"22.13.1","dependencies":{"node-fetch":"^2.7.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.0.1","typescript":"^4.9.0","@types/node":"^18.0.0","@types/node-fetch":"^2.6.12"},"_npmOperationalInternal":{"tmp":"tmp/chat-ai_0.0.1_1754287716630_0.6112228595768487","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-08-04T06:08:36.522Z","modified":"2026-04-27T10:13:29.579Z","0.0.1":"2025-08-04T06:08:36.861Z"},"author":{"name":"Pankaj Kumar","email":"pankaj.kumar@antiersolutions.com"},"license":"MIT","keywords":["chatai","RAG","Abstraxn","SDK","AskAI"],"description":"Abstraxn ChatAI package for Simple and efficient communication with ChatAI API","maintainers":[{"email":"shubham.singla@antiersolutions.com","name":"shubham.antier"},{"email":"sandeepsj26899@gmail.com","name":"sandeep_sj"},{"email":"abhishek.upadhyay@antiersolutions.com","name":"abhi883"},{"email":"pankajdogra829@gmail.com","name":"pankaj829"}],"readme":"# ChatAI\n\n## Overview\n\nThe Abstraxn ChatAI SDK is a simple and efficient SDK for communicating with the ChatAI API. This SDK provides easy-to-use methods for both streaming and non-streaming chat interactions.\n\n## Installation\n\n```bash\nnpm install @abstraxn/chat-ai\n```\n\nOr using `yarn` package manager:\n\n```bash\nyarn add @abstraxn/chat-ai\n```\n\n## Quick Start\n\n```typescript\nimport { ChatAIClient } from \"@abstraxn/chat-ai\";\n\nconst client = new ChatAIClient({\n  apiKey: \"your-api-key-here\",\n});\n\n// Simple chat\nconst response = await client.chat(\"What is machine learning?\");\nconsole.log(response.response);\n```\n\n## Features\n\n- **Simple API** - Easy to use with minimal configuration\n- **Streaming Support** - Real-time streaming responses with Server-Sent Events\n- **Session Management** - Maintain conversation context across requests\n- **CORS Support** - Configurable headers for cross-origin requests\n- **TypeScript Support** - Full type definitions included\n- **Error Handling** - Comprehensive error handling with detailed messages\n- **Custom Headers** - Support for additional HTTP headers\n\n## Usage Examples\n\n### Basic Chat (Non-Streaming)\n\n```typescript\nimport { ChatAIClient } from \"@abstraxn/chat-ai\";\n\nconst client = new ChatAIClient({\n  apiKey: \"your-api-key\",\n});\n\nasync function basicChat() {\n  try {\n    const response = await client.chat(\"What is artificial intelligence?\");\n    console.log(\"AI Response:\", response.response);\n    console.log(\"Session ID:\", response.sessionId);\n  } catch (error) {\n    console.error(\"Error:\", error.message);\n  }\n}\n\nbasicChat();\n```\n\n### Streaming Chat\n\n```typescript\nimport { ChatAIClient } from \"@abstraxn/chat-ai\";\n\nconst client = new ChatAIClient({\n  apiKey: \"your-api-key\",\n});\n\nasync function streamingChat() {\n  try {\n    const stream = await client.chatStream(\"Explain deep learning in detail\");\n\n    for await (const chunk of stream) {\n      if (chunk.type === \"content\") {\n        process.stdout.write(chunk.content); // Print streaming content\n      }\n      if (chunk.type === \"done\") {\n        console.log(\"\\n[Stream complete]\");\n      }\n    }\n  } catch (error) {\n    console.error(\"Streaming error:\", error.message);\n  }\n}\n\nstreamingChat();\n```\n\n### Session Management\n\n```typescript\nimport { ChatAIClient } from \"@abstraxn/chat-ai\";\n\nconst client = new ChatAIClient({ apiKey: \"your-api-key\" });\n\nasync function conversation() {\n  const sessionId = \"user-session-123\";\n\n  // First message\n  const response1 = await client.chat(\"Hello, my name is John\", {\n    sessionId: sessionId,\n  });\n  console.log(\"AI:\", response1.response);\n\n  // Follow-up message (AI will remember the conversation)\n  const response2 = await client.chat(\"What is my name?\", {\n    sessionId: sessionId,\n  });\n  console.log(\"AI:\", response2.response);\n}\n```\n\n### Custom Headers and CORS\n\n```typescript\nconst client = new ChatAIClient({\n  apiKey: \"your-api-key\",\n  origin: \"https://my-frontend.com\",\n  headers: {\n    \"X-Request-ID\": \"abc123\",\n    \"X-Client-Version\": \"1.0.0\",\n  },\n});\n```\n\n### Error Handling\n\n```typescript\ntry {\n  const response = await client.chat(\"Tell me about AI\");\n  console.log(response.response);\n} catch (error) {\n  if (error.status) {\n    console.error(`API Error ${error.status}:`, error.message);\n  } else {\n    console.error(\"Network Error:\", error.message);\n  }\n}\n```\n\n## API Reference\n\n### ChatAIClient\n\n#### Constructor\n\n```typescript\nnew ChatAIClient(config);\n```\n\n**Config Options:**\n\n- `apiKey` (required): Your ChatAI API key\n- `timeout` (optional): Request timeout in milliseconds (default: `30000`)\n- `origin` (optional): Origin header for CORS (default: `*`)\n- `headers` (optional): Additional custom headers\n\n#### Methods\n\n##### `chat(query, options)`\n\nSend a chat message and get a complete response.\n\n**Parameters:**\n\n- `query` (string): The message to send\n- `options` (object, optional):\n  - `sessionId` (string, optional): Session ID for conversation continuity\n  - `stream` (boolean, optional): Force non-streaming mode (default: `false`)\n\n**Returns:** Promise<ChatResponse>\n\n##### `chatStream(query, options)`\n\nSend a chat message and get a streaming response.\n\n**Parameters:**\n\n- `query` (string): The message to send\n- `options` (object, optional):\n  - `sessionId` (string, optional): Session ID for conversation continuity\n\n**Returns:** AsyncGenerator<ChatChunk>\n\n### Types\n\n#### ChatResponse\n\n```typescript\ninterface ChatResponse {\n  error: boolean;\n  sessionId: string;\n  response: string;\n  outOfContext?: boolean;\n}\n```\n\n#### ChatChunk\n\n```typescript\ninterface ChatChunk {\n  type: \"session\" | \"content\" | \"done\" | \"error\";\n  sessionId?: string;\n  content?: string;\n  timestamp?: string;\n  timing?: {\n    total: number;\n  };\n  outOfContext?: boolean;\n  message?: string;\n}\n```\n","readmeFilename":"README.md"}