@crashteamdev/chainbrain-agent-proto
v0.0.4
Published
Protobuf definitions for ChainBrain Agent Service
Downloads
13
Maintainers
Readme
ChainBrain Agent Proto
TypeScript/JavaScript client library for ChainBrain Agent Service protobuf definitions.
Installation
npm install @crashteam/chainbrain-agent-protoUsage
Basic Usage
import {
ProcessMessageRequest,
MessageContext,
MessageContext_MessageType,
AgentOptions,
AgentServiceDefinition,
} from '@crashteam/chainbrain-agent-proto';
// Create a message request
const request: ProcessMessageRequest = {
userId: 'user-123',
conversationId: 'conv-456',
message: 'Hello, how can you help me?',
context: {
messageType: MessageContext_MessageType.TEXT,
attachments: [],
metadata: {},
},
options: {
autoModelSelection: true,
preferredProvider: 'openai',
preferredModel: 'gpt-4',
temperature: 0.7,
maxTokens: 2048,
enableTools: true,
allowedTools: ['search', 'calculator'],
},
};Using with nice-grpc
import { createChannel, createClient } from 'nice-grpc';
import { AgentServiceDefinition } from '@crashteam/chainbrain-agent-proto';
const channel = createChannel('localhost:50051');
const agentClient = createClient(AgentServiceDefinition, channel);
async function processMessage() {
try {
const response = await agentClient.processMessage(request);
console.log('Agent response:', response.response);
} catch (error) {
console.error('Error processing message:', error);
}
}
// Streaming messages
async function streamMessage() {
try {
for await (const chunk of agentClient.streamMessage(request)) {
console.log('Chunk:', chunk.content);
}
} catch (error) {
console.error('Error streaming message:', error);
}
}Available Types
ProcessMessageRequest- Request for processing a messageProcessMessageResponse- Response from message processingMessageChunk- Streaming message chunkMessageContext- Context information for messagesAgentOptions- Configuration options for the agentModelInfo- Information about the model usedToolExecution- Details about tool executionTokenUsage- Token usage statisticsGetConversationHistoryRequest- Request for conversation historyGetConversationHistoryResponse- Response with conversation historyMessage- Individual message in conversation history
Service Definition
The package exports AgentServiceDefinition which can be used with gRPC clients like nice-grpc.
Development
This package is automatically generated from protobuf definitions. To build from source:
npm install
npm run buildLicense
MIT
