langchain-swift  by buhe

LangChain SDK for Swift, optimized for on-device use

created 2 years ago
397 stars

Top 73.8% on sourcepulse

GitHubView on GitHub
Project Summary

LangChain Swift is a pure client-side Swift library for building applications powered by large language models (LLMs) and AI. It provides a comprehensive toolkit for developers targeting iOS, macOS, and visionOS, enabling seamless integration of LLM capabilities directly within native applications without requiring a backend server.

How It Works

The library implements the core LangChain concepts, including LLMs, prompt templates, memory management, document loaders, text splitters, vector stores, retrievers, agents, and output parsers. It offers a modular architecture allowing developers to chain components together to create complex AI workflows. The library supports various LLM providers and local model inference, with a focus on efficient execution on Apple platforms, including Metal acceleration for local models.

Quick Start & Requirements

  • Install: Add https://github.com/buhe/langchain-swift to your Swift Package Manager dependencies. For local models, use .branch("local").
  • Prerequisites: API keys for various services (OpenAI, Supabase, Serper, etc.) are required. For local models, specific model files are needed. Metal support is available for GPU acceleration.
  • Setup: Configuration involves setting environment variables or using LC.initSet() with API keys and other necessary parameters.
  • Docs: bilibili-api

Highlighted Details

  • Supports a wide range of LLM providers including OpenAI, Hugging Face, Llama 2, Gemini, and local models via Ollama and LMStudio APIs.
  • Integrates with Supabase for vector storage and retrieval.
  • Includes tools for web scraping (via Serper), location, weather, and text-to-speech.
  • Features agent and chain capabilities for complex task execution and conversational AI.
  • Offers various output parsers for structured data extraction from LLM responses.

Maintenance & Community

Licensing & Compatibility

  • The repository does not explicitly state a license in the README.

Limitations & Caveats

  • The library is currently in beta.
  • Some features, like Distilbert embeddings, are marked as not yet implemented on the roadmap.
  • The README mentions watchOS (part), indicating potential limitations for that platform.
Health Check
Last commit

4 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
28 stars in the last 90 days

Explore Similar Projects

Starred by John Resig John Resig(Author of jQuery; Chief Software Architect at Khan Academy), Travis Fischer Travis Fischer(Founder of Agentic), and
1 more.

instructor-js by 567-labs

0%
738
Typescript tool for structured extraction from LLMs
created 1 year ago
updated 6 months ago
Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Nat Friedman Nat Friedman(Former CEO of GitHub), and
32 more.

llama.cpp by ggml-org

0.4%
84k
C/C++ library for local LLM inference
created 2 years ago
updated 13 hours ago
Feedback? Help us improve.