The @astack-tech/integrations package provides external service integrations for the AStack framework, primarily focused on Large Language Model (LLM) provider implementations. This package abstracts vendor-specific APIs behind a unified ModelProvider interface, enabling agents and other components to interact with different LLM services without code changes.
For detailed documentation of the ModelProvider interface specification, see Model Provider Interface. For implementation details of the Deepseek provider, see Deepseek Integration. For information on how agents consume model providers, see Base Agent.
Sources: packages/integrations/package.json1-63 packages/integrations/src/model-provider/deepseek/index.ts1-522
The integrations package is organized as a single package with multiple export paths, following modern ESM/CJS dual-format conventions:
| Export Path | Purpose | Types Location |
|---|---|---|
@astack-tech/integrations | Main package entry point | ./dist/index.d.ts |
@astack-tech/integrations/model-provider | Model provider implementations | ./dist/model-provider/index.d.ts |
The package supports both ESM (import) and CommonJS (require) module systems through conditional exports defined in packages/integrations/package.json9-26
Sources: packages/integrations/package.json59-62
The integrations package implements the ModelProvider interface defined in the components package. This interface standardizes how agents and other components interact with LLM services:
Sources: packages/components/src/agents/index.ts160-184 packages/integrations/src/model-provider/deepseek/index.ts125-174
The Deepseek class is the primary model provider implementation, using the OpenAI SDK to communicate with Deepseek's OpenAI-compatible API endpoint.
The Deepseek component extends the base Component class and implements the ModelProvider interface:
Sources: packages/integrations/src/model-provider/deepseek/index.ts125-174
| Method | Signature | Purpose |
|---|---|---|
generateCompletion() | async generateCompletion(prompt: string): Promise<string> | Generate text completion from a simple prompt |
chatCompletion() | async chatCompletion(messages: Message[], options?): Promise<Message> | Generate response from conversation messages |
streamChatCompletion() | async *streamChatCompletion(messages: Message[], options?): AsyncGenerator<Partial<Message>> | Stream response chunks in real-time |
run() | async run(input: string | Message[]): Promise<string | Message> | Standalone execution mode |
_transform() | _transform($i: any, $o: any): void | Pipeline execution mode |
Sources: packages/integrations/src/model-provider/deepseek/index.ts176-517
The DeepseekConfig interface defines all configuration options for initializing a Deepseek provider instance:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | - | Deepseek API authentication key |
model | string | No | 'deepseek-chat' | Model identifier to use |
baseURL | string | No | 'https://api.deepseek.com/v1' | API endpoint URL |
temperature | number | No | 0.7 | Controls output randomness (0-2) |
maxTokens | number | No | undefined | Maximum tokens to generate |
topP | number | No | undefined | Nucleus sampling probability |
systemPrompt | string | No | undefined | System-level instructions |
rawTools | Array<Tool> | No | undefined | Tool instances (auto-converted to API format) |
tools | unknown[] | No | undefined | Pre-formatted API tool definitions |
Tools can be provided in two formats:
rawTools): Simple tool objects that are automatically converted to API format packages/integrations/src/model-provider/deepseek/index.ts154-163tools): Pre-formatted OpenAI-compatible tool definitions packages/integrations/src/model-provider/deepseek/index.ts164-167Sources: packages/integrations/src/model-provider/deepseek/index.ts7-60 packages/integrations/src/model-provider/deepseek/index.ts137-167
The Message interface defines the structure for conversation messages:
Sources: packages/integrations/src/model-provider/deepseek/index.ts64-110
The ToolCall interface represents a tool invocation request from the model:
The Deepseek implementation also handles OpenAI's standard format with nested function objects packages/integrations/src/model-provider/deepseek/index.ts448-467 ensuring compatibility with the Agent component's expectations.
Sources: packages/integrations/src/model-provider/deepseek/index.ts68-85
Sources: packages/integrations/src/model-provider/deepseek/index.ts351-471
Sources: packages/integrations/src/model-provider/deepseek/index.ts233-343
The Deepseek component can be executed directly via the run() method:
Sources: packages/integrations/src/model-provider/deepseek/index.ts478-484
When used in a pipeline, the component's _transform() method handles port-based data flow:
| Input Port | Data Type | Handler Method |
|---|---|---|
'prompt' | string | generateCompletion() |
'messages' | Message[] | chatCompletion() |
| Output Port | Data Type | Source |
|---|---|---|
'completion' | string | From generateCompletion() |
'message' | Message | From chatCompletion() |
Sources: packages/integrations/src/model-provider/deepseek/index.ts491-517
The following demonstrates how to instantiate and use the Deepseek provider:
Sources: examples/agent-with-tools/index.ts104-153
The Deepseek provider supports tool calling through two mechanisms:
Tools provided during construction via rawTools or tools are included in all API calls:
Sources: packages/integrations/src/model-provider/deepseek/index.ts154-167
Tools can be provided at call-time via the temporaryTools option, overriding configured tools:
Sources: packages/integrations/src/model-provider/deepseek/index.ts395-430
The component implements try-catch error handling in its _transform() method for pipeline execution:
| Error Location | Handling Strategy |
|---|---|
generateCompletion() | Sends "API 调用错误" to output port |
chatCompletion() | Sends error message object with role: 'assistant' |
Sources: packages/integrations/src/model-provider/deepseek/index.ts494-516
| Property | Value |
|---|---|
| Package Name | @astack-tech/integrations |
| Version | 0.1.1-beta.2 |
| License | MIT |
| Node Version | >=18.0.0 |
| Build Tool | tsup |
| Test Framework | vitest |
Refresh this wiki