{"data":{"slug":"davidmigloz-langchain-dart","name":"langchain_dart","tagline":"Build LLM-powered Dart/Flutter applications.","github_url":"https://github.com/davidmigloz/langchain_dart","owner":"davidmigloz","repo":"langchain_dart","owner_avatar_url":"https://avatars.githubusercontent.com/u/6546265?v=4","primary_language":"Dart","stars":683,"forks":154,"topics":["ai","dart","flutter","generative-ai","llms","nlp"],"archived":false,"github_pushed_at":"2026-06-29T00:11:32+00:00","maintenance_label":"Active","url":"https://www.graphcanon.com/tools/davidmigloz-langchain-dart","markdown_url":"https://www.graphcanon.com/tools/davidmigloz-langchain-dart.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/davidmigloz-langchain-dart","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=davidmigloz-langchain-dart","description":"Build LLM-powered Dart/Flutter applications.","homepage_url":"http://davidmigloz.github.io/langchain_dart/","license":"MIT","open_issues":20,"watchers":15,"ai_summary":null,"readme_excerpt":"## Getting started\n\nTo start using LangChain.dart, add `langchain` as a dependency to your `pubspec.yaml` file. Also, include the dependencies for the specific integrations you want to use (e.g.`langchain_community`, `langchain_openai`, `langchain_google`, etc.):\n\n```yaml\ndependencies:\n  langchain: {version}\n  langchain_community: {version}\n  langchain_openai: {version}\n  langchain_google: {version}\n  ...\n```\n\nThe most basic building block of LangChain.dart is calling an LLM on some prompt. LangChain.dart provides a unified interface for calling different LLMs. For example, we can use `ChatGoogleGenerativeAI` to call Google's Gemini model:\n\n```dart\nfinal model = ChatGoogleGenerativeAI(apiKey: googleApiKey);\nfinal prompt = PromptValue.string('Hello world!');\nfinal result = await model.invoke(prompt);\n// Hello everyone! I'm new here and excited to be part of this community.\n```\n\nBut the power of LangChain.dart comes from chaining together multiple components to implement complex use cases. For example, a RAG (Retrieval-Augmented Generation) pipeline that would accept a user query, retrieve relevant documents from a vector store, format them using prompt templates, invoke the model, and parse the output:\n\n```dart\n// 1. Create a vector store and add documents to it\nfinal vectorStore = MemoryVectorStore(\n  embeddings: OpenAIEmbeddings(apiKey: openaiApiKey),\n);\nawait vectorStore.addDocuments(\n  documents: [\n    Document(pageContent: 'LangChain was created by Harrison'),\n    Document(pageContent: 'David ported LangChain to Dart in LangChain.dart'),\n  ],\n);\n\n// 2. Define the retrieval chain\nfinal retriever = vectorStore.asRetriever();\nfinal setupAndRetrieval = Runnable.fromMap<String>({\n  'context': retriever.pipe(\n    Runnable.mapInput((docs) => docs.map((d) => d.pageContent).join('\\n')),\n  ),\n  'question': Runnable.passthrough(),\n});\n\n// 3. Construct a RAG prompt template\nfinal promptTemplate = ChatPromptTemplate.fromTemplates([\n  (ChatMessageType.system, 'Answer the question based on only the following context:\\n{context}'),\n  (ChatMessageType.human, '{question}'),\n]);\n\n// 4. Define the final chain\nfinal model = ChatOpenAI(apiKey: openaiApiKey);\nconst outputParser = StringOutputParser<ChatResult>();\nfinal chain = setupAndRetrieval\n    .pipe(promptTemplate)\n    .pipe(model)\n    .pipe(outputParser);\n\n// 5. Run the pipeline\nfinal res = await chain.invoke('Who created LangChain.dart?');\nprint(res);\n// David created LangChain.dart\n```\n\n---\n\n## License\n\nLangChain.dart is licensed under the [MIT License](https://github.com/davidmigloz/langchain_dart/blob/main/LICENSE).","github_created_at":"2023-06-03T14:38:25+00:00","created_at":"2026-07-11T10:43:27.333601+00:00","updated_at":"2026-07-11T10:43:34.325832+00:00","categories":[{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"},{"slug":"speech-audio","name":"Speech & Audio","url":"https://www.graphcanon.com/categories/speech-audio","markdown_url":"https://www.graphcanon.com/categories/speech-audio.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/speech-audio"},{"slug":"vector-databases","name":"Vector Databases","url":"https://www.graphcanon.com/categories/vector-databases","markdown_url":"https://www.graphcanon.com/categories/vector-databases.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/vector-databases"}],"tags":[{"slug":"ai","name":"ai"},{"slug":"dart","name":"dart"},{"slug":"flutter","name":"flutter"},{"slug":"generative-ai","name":"generative-ai"},{"slug":"llms","name":"llms"},{"slug":"nlp","name":"nlp"}],"trust":{"provenance":{"is_fork":false,"github_id":649025519,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-07-11T10:43:28.018Z","maintenance":{"label":"Active","score":82,"methodology":"github_public_v1","releases_90d":0,"days_since_push":12,"last_release_at":"2025-12-27T16:53:00Z"},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T10:43:28.820Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-07-11T10:43:28.432Z"},"languages":{"value":["dart"],"source":"github.language","observed_at":"2026-07-11T10:43:28.432Z"},"license_spdx":{"value":"MIT","source":"github.license","observed_at":"2026-07-11T10:43:28.432Z"}}}}