JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 912
  • Score
    100M100P100Q121359F
  • License SEE LICENSE IN LICENSE

Ollama

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@agentic-kit/ollama) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    @agentic-kit/ollama

    A JavaScript/TypeScript client for the Ollama LLM server, supporting model listing, text generation, streaming responses, embeddings, and model management.

    Installation

    npm install @agentic-kit/ollama

    Usage

    import OllamaClient, { GenerateInput } from '@agentic-kit/ollama';
    
    // Create a client (default port 11434)
    const client = new OllamaClient('http://localhost:11434');
    
    // List available models
    const models = await client.listModels();
    console.log('Available models:', models);
    
    // Non-streaming text generation
    const output = await client.generate({ model: 'mistral', prompt: 'Hello, Ollama!' });
    console.log(output);
    
    // Streaming generation
    await client.generate(
      { model: 'mistral', prompt: 'Hello, streaming!', stream: true },
      (chunk) => {
        console.log('Received chunk:', chunk);
      }
    );
    
    // Pull a model to local cache
    await client.pullModel('mistral');
    
    // Generate embeddings
    const embedding = await client.generateEmbedding('Compute embeddings');
    console.log('Embedding vector length:', embedding.length);
    
    // Generate a conversational response with context
    const response = await client.generateResponse(
      'What is the capital of France?',
      'Geography trivia'
    );
    console.log(response);
    
    // Delete a pulled model when done
    await client.deleteModel('mistral');

    API Reference

    • new OllamaClient(baseUrl?: string) – defaults to http://localhost:11434
    • .listModels(): Promise<string[]>
    • .generate(input: GenerateInput, onChunk?: (chunk: string) => void): Promise<string | void>
    • .generateStreamingResponse(prompt: string, onChunk: (chunk: string) => void, context?: string): Promise<void>
    • .generateEmbedding(text: string): Promise<number[]>
    • .generateResponse(prompt: string, context?: string): Promise<string>
    • .pullModel(model: string): Promise<void>
    • .deleteModel(model: string): Promise<void>

    GenerateInput type

    interface GenerateInput {
      model: string;
      prompt: string;
      stream?: boolean;
    }

    Contributing

    Please open issues or pull requests on GitHub.