[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-patterns-ai-core--langchainrb":3,"tool-patterns-ai-core--langchainrb":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",151918,2,"2026-04-12T11:33:05",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":77,"owner_email":77,"owner_twitter":77,"owner_website":77,"owner_url":78,"languages":79,"stars":95,"forks":96,"last_commit_at":97,"license":98,"difficulty_score":32,"env_os":99,"env_gpu":99,"env_ram":99,"env_deps":100,"category_tags":105,"github_topics":106,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":114,"updated_at":115,"faqs":116,"releases":147},6960,"patterns-ai-core\u002Flangchainrb","langchainrb","Build LLM-powered applications in Ruby","langchainrb 是一款专为 Ruby 开发者打造的开源库，旨在简化基于大语言模型（LLM）的应用程序开发流程。它解决了 Ruby 生态中缺乏统一接口来对接各类主流 AI 模型的痛点，让开发者无需为不同服务商编写重复的适配代码，即可轻松构建智能应用。\n\n该工具主要面向熟悉 Ruby 或 Ruby on Rails 框架的软件工程师和技术团队。无论是想快速原型验证的研究人员，还是致力于在生产环境中集成 AI 功能的全栈开发者，都能通过它高效地实现复杂逻辑。其核心亮点在于提供了一套标准化的抽象层，统一支持包括 OpenAI、Anthropic、Google Gemini、AWS Bedrock 以及本地部署的 Ollama 等十余种主流模型提供商。用户只需切换配置即可在不同后端间无缝迁移，极大地提升了开发灵活性。\n\n此外，langchainrb 内置了构建检索增强生成（RAG）系统、向量搜索、智能助手（聊天机器人）以及提示词管理等关键模块所需的全套工具。它还支持自定义输出解析和评估机制，帮助开发者更精准地控制模型行为并优化应用效果。如果你希望在熟悉的 Ruby 环境中充分利用大语言模","langchainrb 是一款专为 Ruby 开发者打造的开源库，旨在简化基于大语言模型（LLM）的应用程序开发流程。它解决了 Ruby 生态中缺乏统一接口来对接各类主流 AI 模型的痛点，让开发者无需为不同服务商编写重复的适配代码，即可轻松构建智能应用。\n\n该工具主要面向熟悉 Ruby 或 Ruby on Rails 框架的软件工程师和技术团队。无论是想快速原型验证的研究人员，还是致力于在生产环境中集成 AI 功能的全栈开发者，都能通过它高效地实现复杂逻辑。其核心亮点在于提供了一套标准化的抽象层，统一支持包括 OpenAI、Anthropic、Google Gemini、AWS Bedrock 以及本地部署的 Ollama 等十余种主流模型提供商。用户只需切换配置即可在不同后端间无缝迁移，极大地提升了开发灵活性。\n\n此外，langchainrb 内置了构建检索增强生成（RAG）系统、向量搜索、智能助手（聊天机器人）以及提示词管理等关键模块所需的全套工具。它还支持自定义输出解析和评估机制，帮助开发者更精准地控制模型行为并优化应用效果。如果你希望在熟悉的 Ruby 环境中充分利用大语言模型的能力，langchainrb 是一个值得尝试的实用选择。","💎🔗 Langchain.rb\n---\n⚡ Building LLM-powered applications in Ruby ⚡\n\nFor deep Rails integration see: [langchainrb_rails](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb_rails) gem.\n\nAvailable for paid consulting engagements! [Email me](mailto:andrei@sourcelabs.io).\n\n![Tests status](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg?branch=main)\n[![Gem Version](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Flangchainrb.svg)](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Flangchainrb)\n[![Docs](http:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fyard-docs-blue.svg)](http:\u002F\u002Frubydoc.info\u002Fgems\u002Flangchainrb)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green.svg)](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fblob\u002Fmain\u002FLICENSE.txt)\n[![](https:\u002F\u002Fdcbadge.vercel.app\u002Fapi\u002Fserver\u002FWDARp7J2n8?compact=true&style=flat)](https:\u002F\u002Fdiscord.gg\u002FWDARp7J2n8)\n[![X](https:\u002F\u002Fimg.shields.io\u002Ftwitter\u002Furl\u002Fhttps\u002Ftwitter.com\u002Fcloudposse.svg?style=social&label=Follow%20%40rushing_andrei)](https:\u002F\u002Ftwitter.com\u002Frushing_andrei)\n\n## Use Cases\n* Retrieval Augmented Generation (RAG) and vector search\n* [Assistants](#assistants) (chat bots)\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Unified Interface for LLMs](#unified-interface-for-llms)\n- [Prompt Management](#prompt-management)\n- [Output Parsers](#output-parsers)\n- [Building RAG](#building-retrieval-augment-generation-rag-system)\n- [Assistants](#assistants)\n- [Evaluations](#evaluations-evals)\n- [Examples](#examples)\n- [Logging](#logging)\n- [Problems](#problems)\n- [Development](#development)\n- [Discord](#discord)\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    bundle add langchainrb\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    gem install langchainrb\n\nAdditional gems may be required. They're not included by default so you can include only what you need.\n\n## Usage\n\n```ruby\nrequire \"langchain\"\n```\n\n# Unified Interface for LLMs\n\nThe `Langchain::LLM` module provides a unified interface for interacting with various Large Language Model (LLM) providers. This abstraction allows you to easily switch between different LLM backends without changing your application code.\n\n## Supported LLM Providers\n\n- Anthropic\n- AWS Bedrock\n- Azure OpenAI\n- Cohere\n- Google Gemini\n- Google Vertex AI\n- HuggingFace\n- Mistral AI\n- Ollama\n- OpenAI\n- Replicate\n\n## Usage\n\nAll LLM classes inherit from `Langchain::LLM::Base` and provide a consistent interface for common operations:\n\n1. Generating embeddings\n2. Generating prompt completions\n3. Generating chat completions\n\n### Initialization\n\nMost LLM classes can be initialized with an API key and optional default options:\n\n```ruby\nllm = Langchain::LLM::OpenAI.new(\n  api_key: ENV[\"OPENAI_API_KEY\"],\n  default_options: { temperature: 0.7, chat_model: \"gpt-4o\" }\n)\n```\n\n### Generating Embeddings\n\nUse the `embed` method to generate embeddings for given text:\n\n```ruby\nresponse = llm.embed(text: \"Hello, world!\")\nembedding = response.embedding\n```\n\n#### Accepted parameters for `embed()`\n\n- `text`: (Required) The input text to embed.\n- `model`: (Optional) The model name to use or default embedding model will be used.\n\n### Prompt completions\n\nUse the `complete` method to generate completions for a given prompt:\n\n```ruby\nresponse = llm.complete(prompt: \"Once upon a time\")\ncompletion = response.completion\n```\n\n#### Accepted parameters for `complete()`\n\n- `prompt`: (Required) The input prompt for completion.\n- `max_tokens`: (Optional) The maximum number of tokens to generate.\n- `temperature`: (Optional) Controls randomness in generation. Higher values (e.g., 0.8) make output more random, while lower values (e.g., 0.2) make it more deterministic.\n- `top_p`: (Optional) An alternative to temperature, controls diversity of generated tokens.\n- `n`: (Optional) Number of completions to generate for each prompt.\n- `stop`: (Optional) Sequences where the API will stop generating further tokens.\n- `presence_penalty`: (Optional) Penalizes new tokens based on their presence in the text so far.\n- `frequency_penalty`: (Optional) Penalizes new tokens based on their frequency in the text so far.\n\n### Generating Chat Completions\n\nUse the `chat` method to generate chat completions:\n\n```ruby\nmessages = [\n  { role: \"system\", content: \"You are a helpful assistant.\" },\n  { role: \"user\", content: \"What's the weather like today?\" }\n  # Google Gemini and Google VertexAI expect messages in a different format:\n  # { role: \"user\", parts: [{ text: \"why is the sky blue?\" }]}\n]\nresponse = llm.chat(messages: messages)\nchat_completion = response.chat_completion\n```\n\n#### Accepted parameters for `chat()`\n\n- `messages`: (Required) An array of message objects representing the conversation history.\n- `model`: (Optional) The specific chat model to use.\n- `temperature`: (Optional) Controls randomness in generation.\n- `top_p`: (Optional) An alternative to temperature, controls diversity of generated tokens.\n- `n`: (Optional) Number of chat completion choices to generate.\n- `max_tokens`: (Optional) The maximum number of tokens to generate in the chat completion.\n- `stop`: (Optional) Sequences where the API will stop generating further tokens.\n- `presence_penalty`: (Optional) Penalizes new tokens based on their presence in the text so far.\n- `frequency_penalty`: (Optional) Penalizes new tokens based on their frequency in the text so far.\n- `logit_bias`: (Optional) Modifies the likelihood of specified tokens appearing in the completion.\n- `user`: (Optional) A unique identifier representing your end-user.\n- `tools`: (Optional) A list of tools the model may call.\n- `tool_choice`: (Optional) Controls how the model calls functions.\n\n## Switching LLM Providers\n\nThanks to the unified interface, you can easily switch between different LLM providers by changing the class you instantiate:\n\n```ruby\n# Using Anthropic\nanthropic_llm = Langchain::LLM::Anthropic.new(api_key: ENV[\"ANTHROPIC_API_KEY\"])\n\n# Using Google Gemini\ngemini_llm = Langchain::LLM::GoogleGemini.new(api_key: ENV[\"GOOGLE_GEMINI_API_KEY\"])\n\n# Using OpenAI\nopenai_llm = Langchain::LLM::OpenAI.new(api_key: ENV[\"OPENAI_API_KEY\"])\n```\n\n## Response Objects\n\nEach LLM method returns a response object that provides a consistent interface for accessing the results:\n\n- `embedding`: Returns the embedding vector\n- `completion`: Returns the generated text completion\n- `chat_completion`: Returns the generated chat completion\n- `tool_calls`: Returns tool calls made by the LLM\n- `prompt_tokens`: Returns the number of tokens in the prompt\n- `completion_tokens`: Returns the number of tokens in the completion\n- `total_tokens`: Returns the total number of tokens used\n\n> [!NOTE]\n> While the core interface is consistent across providers, some LLMs may offer additional features or parameters. Consult the documentation for each LLM class to learn about provider-specific capabilities and options.\n\n### Prompt Management\n\n#### Prompt Templates\n\nCreate a prompt with input variables:\n\n```ruby\nprompt = Langchain::Prompt::PromptTemplate.new(template: \"Tell me a {adjective} joke about {content}.\", input_variables: [\"adjective\", \"content\"])\nprompt.format(adjective: \"funny\", content: \"chickens\") # \"Tell me a funny joke about chickens.\"\n```\n\nCreating a PromptTemplate using just a prompt and no input_variables:\n\n```ruby\nprompt = Langchain::Prompt::PromptTemplate.from_template(\"Tell me a funny joke about chickens.\")\nprompt.input_variables # []\nprompt.format # \"Tell me a funny joke about chickens.\"\n```\n\nSave prompt template to JSON file:\n\n```ruby\nprompt.save(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Fprompt_template.json\")\n```\n\nLoading a new prompt template using a JSON file:\n\n```ruby\nprompt = Langchain::Prompt.load_from_path(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Fprompt_template.json\")\nprompt.input_variables # [\"adjective\", \"content\"]\n```\n\n#### Few Shot Prompt Templates\n\nCreate a prompt with a few shot examples:\n\n```ruby\nprompt = Langchain::Prompt::FewShotPromptTemplate.new(\n  prefix: \"Write antonyms for the following words.\",\n  suffix: \"Input: {adjective}\\nOutput:\",\n  example_prompt: Langchain::Prompt::PromptTemplate.new(\n    input_variables: [\"input\", \"output\"],\n    template: \"Input: {input}\\nOutput: {output}\"\n  ),\n  examples: [\n    { \"input\": \"happy\", \"output\": \"sad\" },\n    { \"input\": \"tall\", \"output\": \"short\" }\n  ],\n   input_variables: [\"adjective\"]\n)\n\nprompt.format(adjective: \"good\")\n\n# Write antonyms for the following words.\n#\n# Input: happy\n# Output: sad\n#\n# Input: tall\n# Output: short\n#\n# Input: good\n# Output:\n```\n\nSave prompt template to JSON file:\n\n```ruby\nprompt.save(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Ffew_shot_prompt_template.json\")\n```\n\nLoading a new prompt template using a JSON file:\n\n```ruby\nprompt = Langchain::Prompt.load_from_path(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Ffew_shot_prompt_template.json\")\nprompt.prefix # \"Write antonyms for the following words.\"\n```\n\nLoading a new prompt template using a YAML file:\n\n```ruby\nprompt = Langchain::Prompt.load_from_path(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Fprompt_template.yaml\")\nprompt.input_variables #=> [\"adjective\", \"content\"]\n```\n\n\n### Output Parsers\n\nParse LLM text responses into structured output, such as JSON.\n\n#### Structured Output Parser\n\nYou can use the `StructuredOutputParser` to generate a prompt that instructs the LLM to provide a JSON response adhering to a specific JSON schema:\n\n```ruby\njson_schema = {\n  type: \"object\",\n  properties: {\n    name: {\n      type: \"string\",\n      description: \"Persons name\"\n    },\n    age: {\n      type: \"number\",\n      description: \"Persons age\"\n    },\n    interests: {\n      type: \"array\",\n      items: {\n        type: \"object\",\n        properties: {\n          interest: {\n            type: \"string\",\n            description: \"A topic of interest\"\n          },\n          levelOfInterest: {\n            type: \"number\",\n            description: \"A value between 0 and 100 of how interested the person is in this interest\"\n          }\n        },\n        required: [\"interest\", \"levelOfInterest\"],\n        additionalProperties: false\n      },\n      minItems: 1,\n      maxItems: 3,\n      description: \"A list of the person's interests\"\n    }\n  },\n  required: [\"name\", \"age\", \"interests\"],\n  additionalProperties: false\n}\nparser = Langchain::OutputParsers::StructuredOutputParser.from_json_schema(json_schema)\nprompt = Langchain::Prompt::PromptTemplate.new(template: \"Generate details of a fictional character.\\n{format_instructions}\\nCharacter description: {description}\", input_variables: [\"description\", \"format_instructions\"])\nprompt_text = prompt.format(description: \"Korean chemistry student\", format_instructions: parser.get_format_instructions)\n# Generate details of a fictional character.\n# You must format your output as a JSON value that adheres to a given \"JSON Schema\" instance.\n# ...\n```\n\nThen parse the llm response:\n\n```ruby\nllm = Langchain::LLM::OpenAI.new(api_key: ENV[\"OPENAI_API_KEY\"])\nllm_response = llm.chat(messages: [{role: \"user\", content: prompt_text}]).completion\nparser.parse(llm_response)\n# {\n#   \"name\" => \"Kim Ji-hyun\",\n#   \"age\" => 22,\n#   \"interests\" => [\n#     {\n#       \"interest\" => \"Organic Chemistry\",\n#       \"levelOfInterest\" => 85\n#     },\n#     ...\n#   ]\n# }\n```\n\nIf the parser fails to parse the LLM response, you can use the `OutputFixingParser`. It sends an error message, prior output, and the original prompt text to the LLM, asking for a \"fixed\" response:\n\n```ruby\nbegin\n  parser.parse(llm_response)\nrescue Langchain::OutputParsers::OutputParserException => e\n  fix_parser = Langchain::OutputParsers::OutputFixingParser.from_llm(\n    llm: llm,\n    parser: parser\n  )\n  fix_parser.parse(llm_response)\nend\n```\n\nAlternatively, if you don't need to handle the `OutputParserException`, you can simplify the code:\n\n```ruby\n# we already have the `OutputFixingParser`:\n# parser = Langchain::OutputParsers::StructuredOutputParser.from_json_schema(json_schema)\nfix_parser = Langchain::OutputParsers::OutputFixingParser.from_llm(\n  llm: llm,\n  parser: parser\n)\nfix_parser.parse(llm_response)\n```\n\nSee [here](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Ftree\u002Fmain\u002Fexamples\u002Fcreate_and_manage_prompt_templates_using_structured_output_parser.rb) for a concrete example\n\n## Building Retrieval Augment Generation (RAG) system\nRAG is a methodology that assists LLMs generate accurate and up-to-date information.\nA typical RAG workflow follows the 3 steps below:\n1. Relevant knowledge (or data) is retrieved from the knowledge base (typically a vector search DB)\n2. A prompt, containing retrieved knowledge above, is constructed.\n3. LLM receives the prompt above to generate a text completion.\nMost common use-case for a RAG system is powering Q&A systems where users pose natural language questions and receive answers in natural language.\n\n### Vector search databases\nLangchain.rb provides a convenient unified interface on top of supported vectorsearch databases that make it easy to configure your index, add data, query and retrieve from it.\n\n#### Supported vector search databases and features:\n\n| Database                                                                                   | Open-source        | Cloud offering     |\n| --------                                                                                   |:------------------:| :------------:     |\n| [Chroma](https:\u002F\u002Ftrychroma.com\u002F?utm_source=langchainrb&utm_medium=github)                  | ✅                 | ✅                 |\n| [Hnswlib](https:\u002F\u002Fgithub.com\u002Fnmslib\u002Fhnswlib\u002F?utm_source=langchainrb&utm_medium=github)     | ✅                 | ❌                 |\n| [Milvus](https:\u002F\u002Fmilvus.io\u002F?utm_source=langchainrb&utm_medium=github)                      | ✅                 | ✅ Zilliz Cloud    |\n| [Pinecone](https:\u002F\u002Fwww.pinecone.io\u002F?utm_source=langchainrb&utm_medium=github)              | ❌                 | ✅                 |\n| [Pgvector](https:\u002F\u002Fgithub.com\u002Fpgvector\u002Fpgvector\u002F?utm_source=langchainrb&utm_medium=github) | ✅                 | ✅                 |\n| [Qdrant](https:\u002F\u002Fqdrant.tech\u002F?utm_source=langchainrb&utm_medium=github)                    | ✅                 | ✅                 |\n| [Weaviate](https:\u002F\u002Fweaviate.io\u002F?utm_source=langchainrb&utm_medium=github)                  | ✅                 | ✅                 |\n| [Elasticsearch](https:\u002F\u002Fwww.elastic.co\u002F?utm_source=langchainrb&utm_medium=github)          | ✅                 | ✅                 |\n\n### Using Vector Search Databases 🔍\n\nPick the vector search database you'll be using, add the gem dependency and instantiate the client:\n```ruby\ngem \"weaviate-ruby\", \"~> 0.8.9\"\n```\n\nChoose and instantiate the LLM provider you'll be using to generate embeddings\n```ruby\nllm = Langchain::LLM::OpenAI.new(api_key: ENV[\"OPENAI_API_KEY\"])\n```\n\n```ruby\nclient = Langchain::Vectorsearch::Weaviate.new(\n    url: ENV[\"WEAVIATE_URL\"],\n    api_key: ENV[\"WEAVIATE_API_KEY\"],\n    index_name: \"Documents\",\n    llm: llm\n)\n```\n\nYou can instantiate any other supported vector search database:\n```ruby\nclient = Langchain::Vectorsearch::Chroma.new(...)   # `gem \"chroma-db\", \"~> 0.6.0\"`\nclient = Langchain::Vectorsearch::Hnswlib.new(...)  # `gem \"hnswlib\", \"~> 0.8.1\"`\nclient = Langchain::Vectorsearch::Milvus.new(...)   # `gem \"milvus\", \"~> 0.9.3\"`\nclient = Langchain::Vectorsearch::Pinecone.new(...) # `gem \"pinecone\", \"~> 1.0\"`\nclient = Langchain::Vectorsearch::Pgvector.new(...) # `gem \"pgvector\", \"~> 0.2\"`\nclient = Langchain::Vectorsearch::Qdrant.new(...)   # `gem \"qdrant-ruby\", \"~> 0.9.3\"`\nclient = Langchain::Vectorsearch::Elasticsearch.new(...)   # `gem \"elasticsearch\", \"~> 8.2.0\"`\n```\n\nCreate the default schema:\n```ruby\nclient.create_default_schema\n```\n\nAdd plain text data to your vector search database:\n```ruby\nclient.add_texts(\n  texts: [\n    \"Begin by preheating your oven to 375°F (190°C). Prepare four boneless, skinless chicken breasts by cutting a pocket into the side of each breast, being careful not to cut all the way through. Season the chicken with salt and pepper to taste. In a large skillet, melt 2 tablespoons of unsalted butter over medium heat. Add 1 small diced onion and 2 minced garlic cloves, and cook until softened, about 3-4 minutes. Add 8 ounces of fresh spinach and cook until wilted, about 3 minutes. Remove the skillet from heat and let the mixture cool slightly.\",\n      \"In a bowl, combine the spinach mixture with 4 ounces of softened cream cheese, 1\u002F4 cup of grated Parmesan cheese, 1\u002F4 cup of shredded mozzarella cheese, and 1\u002F4 teaspoon of red pepper flakes. Mix until well combined. Stuff each chicken breast pocket with an equal amount of the spinach mixture. Seal the pocket with a toothpick if necessary. In the same skillet, heat 1 tablespoon of olive oil over medium-high heat. Add the stuffed chicken breasts and sear on each side for 3-4 minutes, or until golden brown.\"\n  ]\n)\n```\n\nOr use the file parsers to load, parse and index data into your database:\n```ruby\nmy_pdf = Langchain.root.join(\"path\u002Fto\u002Fmy.pdf\")\nmy_text = Langchain.root.join(\"path\u002Fto\u002Fmy.txt\")\nmy_docx = Langchain.root.join(\"path\u002Fto\u002Fmy.docx\")\n\nclient.add_data(paths: [my_pdf, my_text, my_docx])\n```\nSupported file formats: docx, html, pdf, text, json, jsonl, csv, xlsx, eml, pptx.\n\nRetrieve similar documents based on the query string passed in:\n```ruby\nclient.similarity_search(\n  query:,\n  k:       # number of results to be retrieved\n)\n```\n\nRetrieve similar documents based on the query string passed in via the [HyDE technique](https:\u002F\u002Farxiv.org\u002Fabs\u002F2212.10496):\n```ruby\nclient.similarity_search_with_hyde()\n```\n\nRetrieve similar documents based on the embedding passed in:\n```ruby\nclient.similarity_search_by_vector(\n  embedding:,\n  k:       # number of results to be retrieved\n)\n```\n\nRAG-based querying\n```ruby\nclient.ask(question: \"...\")\n```\n\n## Assistants\n`Langchain::Assistant` is a powerful and flexible class that combines Large Language Models (LLMs), tools, and conversation management to create intelligent, interactive assistants. It's designed to handle complex conversations, execute tools, and provide coherent responses based on the context of the interaction.\n\n### Features\n* Supports multiple LLM providers (OpenAI, Google Gemini, Anthropic, Mistral AI and open-source models via Ollama)\n* Integrates with various tools to extend functionality\n* Manages conversation threads\n* Handles automatic and manual tool execution\n* Supports different message formats for various LLM providers\n\n### Usage\n```ruby\nllm = Langchain::LLM::OpenAI.new(api_key: ENV[\"OPENAI_API_KEY\"])\nassistant = Langchain::Assistant.new(\n  llm: llm,\n  instructions: \"You're a helpful AI assistant\",\n  tools: [Langchain::Tool::NewsRetriever.new(api_key: ENV[\"NEWS_API_KEY\"])]\n)\n\n# Add a user message and run the assistant\nassistant.add_message_and_run!(content: \"What's the latest news about AI?\")\n\n# Supply an image to the assistant\nassistant.add_message_and_run!(\n  content: \"Describe this image.\",\n  image_url: \"https:\u002F\u002Fupload.wikimedia.org\u002Fwikipedia\u002Fcommons\u002Fthumb\u002Fd\u002Fdd\u002FGfp-wisconsin-madison-the-nature-boardwalk.jpg\u002F2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\"\n)\n\n# Access the conversation thread\nmessages = assistant.messages\n\n# Run the assistant with automatic tool execution\nassistant.run(auto_tool_execution: true)\n\n# If you want to stream the response, you can add a response handler\nassistant = Langchain::Assistant.new(\n  llm: llm,\n  instructions: \"You're a helpful AI assistant\",\n  tools: [Langchain::Tool::NewsRetriever.new(api_key: ENV[\"NEWS_API_KEY\"])]\n) do |response_chunk|\n  # ...handle the response stream\n  # print(response_chunk.inspect)\nend\nassistant.add_message(content: \"Hello\")\nassistant.run(auto_tool_execution: true)\n```\n\nNote that streaming is not currently supported for all LLMs.\n\n### Configuration\n* `llm`: The LLM instance to use (required)\n* `tools`: An array of tool instances (optional)\n* `instructions`: System instructions for the assistant (optional)\n* `tool_choice`: Specifies how tools should be selected. Default: \"auto\". A specific tool function name can be passed. This will force the Assistant to **always** use this function.\n* `parallel_tool_calls`: Whether to make multiple parallel tool calls. Default: true\n* `add_message_callback`: A callback function (proc, lambda) that is called when any message is added to the conversation (optional)\n```ruby\nassistant.add_message_callback = -> (message) { puts \"New message: #{message}\" }\n```\n* `tool_execution_callback`: A callback function (proc, lambda) that is called right before a tool is executed (optional)\n```ruby\nassistant.tool_execution_callback = -> (tool_call_id, tool_name, method_name, tool_arguments) { puts \"Executing tool_call_id: #{tool_call_id}, tool_name: #{tool_name}, method_name: #{method_name}, tool_arguments: #{tool_arguments}\" }\n```\n\n### Key Methods\n* `add_message`: Adds a user message to the messages array\n* `run!`: Processes the conversation and generates responses\n* `add_message_and_run!`: Combines adding a message and running the assistant\n* `submit_tool_output`: Manually submit output to a tool call\n* `messages`: Returns a list of ongoing messages\n\n### Built-in Tools 🛠️\n* `Langchain::Tool::Calculator`: Useful for evaluating math expressions. Requires `gem \"eqn\"`.\n* `Langchain::Tool::Database`: Connect your SQL database. Requires `gem \"sequel\"`.\n* `Langchain::Tool::FileSystem`: Interact with the file system (read & write).\n* `Langchain::Tool::GoogleSearch`: Wrapper around SerpApi's Google Search API. Requires `gem \"google_search_results\"`.\n* `Langchain::Tool::NewsRetriever`: A wrapper around [NewsApi.org](https:\u002F\u002Fnewsapi.org) to fetch news articles.\n* `Langchain::Tool::RubyCodeInterpreter`: Useful for evaluating generated Ruby code. Requires `gem \"safe_ruby\"` (In need of a better solution).\n* `Langchain::Tool::Tavily`: A wrapper around [Tavily AI](https:\u002F\u002Ftavily.com).\n* `Langchain::Tool::Vectorsearch`: A wrapper for vector search classes.\n* `Langchain::Tool::Weather`: Calls [Open Weather API](https:\u002F\u002Fhome.openweathermap.org) to retrieve the current weather.\n* `Langchain::Tool::Wikipedia`: Calls Wikipedia API. Requires `gem \"wikipedia-client\"`.\n\n### Creating custom Tools\nThe Langchain::Assistant can be easily extended with custom tools by creating classes that `extend Langchain::ToolDefinition` module and implement required methods.\n```ruby\nclass MovieInfoTool\n  extend Langchain::ToolDefinition\n\n  define_function :search_movie, description: \"MovieInfoTool: Search for a movie by title\" do\n    property :query, type: \"string\", description: \"The movie title to search for\", required: true\n  end\n\n  define_function :get_movie_details, description: \"MovieInfoTool: Get detailed information about a specific movie\" do\n    property :movie_id, type: \"integer\", description: \"The TMDb ID of the movie\", required: true\n  end\n\n  def initialize(api_key:)\n    @api_key = api_key\n  end\n\n  def search_movie(query:)\n    tool_response(...)\n  end\n\n  def get_movie_details(movie_id:)\n    tool_response(...)\n  end\nend\n```\n\n#### Example usage:\n```ruby\nmovie_tool = MovieInfoTool.new(api_key: \"...\")\n\nassistant = Langchain::Assistant.new(\n  llm: llm,\n  instructions: \"You're a helpful AI assistant that can provide movie information\",\n  tools: [movie_tool]\n)\n\nassistant.add_message_and_run(content: \"Can you tell me about the movie 'Inception'?\")\n# Check the response in the last message in the conversation\nassistant.messages.last\n```\n\n### Error Handling\nThe assistant includes error handling for invalid inputs, unsupported LLM types, and tool execution failures. It uses a state machine to manage the conversation flow and handle different scenarios gracefully.\n\n### Demos\n1. [Building an AI Assistant that operates a simulated E-commerce Store](https:\u002F\u002Fwww.loom.com\u002Fshare\u002F83aa4fd8dccb492aad4ca95da40ed0b2)\n2. [New Langchain.rb Assistants interface](https:\u002F\u002Fwww.loom.com\u002Fshare\u002Fe883a4a49b8746c1b0acf9d58cf6da36)\n3. [Langchain.rb Assistant demo with NewsRetriever and function calling on Gemini](https:\u002F\u002Fyoutu.be\u002F-ieyahrpDpM&t=1477s) - [code](https:\u002F\u002Fgithub.com\u002Fpalladius\u002Fgemini-news-crawler)\n\n## Evaluations (Evals)\nThe Evaluations module is a collection of tools that can be used to evaluate and track the performance of the output products by LLM and your RAG (Retrieval Augmented Generation) pipelines.\n\n### RAGAS\nRagas helps you evaluate your Retrieval Augmented Generation (RAG) pipelines. The implementation is based on this [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2309.15217) and the original Python [repo](https:\u002F\u002Fgithub.com\u002Fexplodinggradients\u002Fragas). Ragas tracks the following 3 metrics and assigns the 0.0 - 1.0 scores:\n* Faithfulness - the answer is grounded in the given context.\n* Context Relevance - the retrieved context is focused, containing little to no irrelevant information.\n* Answer Relevance - the generated answer addresses the actual question that was provided.\n\n```ruby\n# We recommend using Langchain::LLM::OpenAI as your llm for Ragas\nragas = Langchain::Evals::Ragas::Main.new(llm: llm)\n\n# The answer that the LLM generated\n# The question (or the original prompt) that was asked\n# The context that was retrieved (usually from a vectorsearch database)\nragas.score(answer: \"\", question: \"\", context: \"\")\n# =>\n# {\n#   ragas_score: 0.6601257446503674,\n#   answer_relevance_score: 0.9573145866787608,\n#   context_relevance_score: 0.6666666666666666,\n#   faithfulness_score: 0.5\n# }\n```\n\n## Examples\nAdditional examples available: [\u002Fexamples](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Ftree\u002Fmain\u002Fexamples)\n\n## Logging\n\nLangchain.rb uses the standard Ruby [Logger](https:\u002F\u002Fruby-doc.org\u002Fstdlib-2.4.0\u002Flibdoc\u002Flogger\u002Frdoc\u002FLogger.html) mechanism and defaults to same `level` value (currently `Logger::DEBUG`).\n\nTo show all log messages:\n\n```ruby\nLangchain.logger.level = Logger::DEBUG\n```\n\nThe logger logs to `STDOUT` by default. In order to configure the log destination (ie. log to a file) do:\n\n```ruby\nLangchain.logger = Logger.new(\"path\u002Fto\u002Ffile\", **Langchain::LOGGER_OPTIONS)\n```\n\n## Problems\nIf you're having issues installing `unicode` gem required by `pragmatic_segmenter`, try running:\n```bash\ngem install unicode -- --with-cflags=\"-Wno-incompatible-function-pointer-types\"\n```\n\n## Development\n\n1. `git clone https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb.git`\n2. `cp .env.example .env`, then fill out the environment variables in `.env`\n3. `bundle exec rake` to ensure that the tests pass and to run standardrb\n4. `bin\u002Fconsole` to load the gem in a REPL session. Feel free to add your own instances of LLMs, Tools, Agents, etc. and experiment with them.\n5. Optionally, install lefthook git hooks for pre-commit to auto lint: `gem install lefthook && lefthook install -f`\n\n## Discord\nJoin us in the [Langchain.rb](https:\u002F\u002Fdiscord.gg\u002FWDARp7J2n8) Discord server.\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fpatterns-ai-core_langchainrb_readme_dd20ee231d7e.png)](https:\u002F\u002Fstar-history.com\u002F#andreibondarev\u002Flangchainrb&Date)\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT).\n","💎🔗 Langchain.rb\n---\n⚡ 使用 Ruby 构建基于大语言模型的应用程序 ⚡\n\n如需深度集成 Rails，请参阅：[langchainrb_rails](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb_rails) gem。\n\n提供付费咨询支持！[发送邮件给我](mailto:andrei@sourcelabs.io)。\n\n![测试状态](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg?branch=main)\n[![Gem 版本](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Flangchainrb.svg)](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Flangchainrb)\n[![文档](http:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fyard-docs-blue.svg)](http:\u002F\u002Frubydoc.info\u002Fgems\u002Flangchainrb)\n[![许可证](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green.svg)](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fblob\u002Fmain\u002FLICENSE.txt)\n[![](https:\u002F\u002Fdcbadge.vercel.app\u002Fapi\u002Fserver\u002FWDARp7J2n8?compact=true&style=flat)](https:\u002F\u002Fdiscord.gg\u002FWDARp7J2n8)\n[![X](https:\u002F\u002Fimg.shields.io\u002Ftwitter\u002Furl\u002Fhttps\u002Ftwitter.com\u002Fcloudposse.svg?style=social&label=Follow%20%40rushing_andrei)](https:\u002F\u002Ftwitter.com\u002Frushing_andrei)\n\n## 使用场景\n* 检索增强生成 (RAG) 和向量搜索\n* [助手](#assistants)（聊天机器人）\n\n## 目录\n\n- [安装](#installation)\n- [使用](#usage)\n- [LLM 统一接口](#unified-interface-for-llms)\n- [提示管理](#prompt-management)\n- [输出解析器](#output-parsers)\n- [构建 RAG](#building-retrieval-augment-generation-rag-system)\n- [助手](#assistants)\n- [评估](#evaluations-evals)\n- [示例](#examples)\n- [日志记录](#logging)\n- [问题](#problems)\n- [开发](#development)\n- [Discord](#discord)\n\n## 安装\n\n通过执行以下命令安装 gem 并将其添加到应用程序的 Gemfile 中：\n\n    bundle add langchainrb\n\n如果未使用 Bundler 管理依赖项，则可通过以下命令安装 gem：\n\n    gem install langchainrb\n\n可能需要其他 gem。它们默认不包含，因此您可以仅包含所需的部分。\n\n## 使用\n\n```ruby\nrequire \"langchain\"\n```\n\n# LLM 统一接口\n\n`Langchain::LLM` 模块提供了一个用于与各种大型语言模型 (LLM) 提供商交互的统一接口。这种抽象使您无需更改应用程序代码即可轻松切换不同的 LLM 后端。\n\n## 支持的 LLM 提供商\n\n- Anthropic\n- AWS Bedrock\n- Azure OpenAI\n- Cohere\n- Google Gemini\n- Google Vertex AI\n- HuggingFace\n- Mistral AI\n- Ollama\n- OpenAI\n- Replicate\n\n## 使用\n\n所有 LLM 类都继承自 `Langchain::LLM::Base`，并为常见操作提供一致的接口：\n\n1. 生成嵌入\n2. 生成提示补全\n3. 生成聊天补全\n\n### 初始化\n\n大多数 LLM 类可以使用 API 密钥和可选的默认选项进行初始化：\n\n```ruby\nllm = Langchain::LLM::OpenAI.new(\n  api_key: ENV[\"OPENAI_API_KEY\"],\n  default_options: { temperature: 0.7, chat_model: \"gpt-4o\" }\n)\n```\n\n### 生成嵌入\n\n使用 `embed` 方法为给定文本生成嵌入：\n\n```ruby\nresponse = llm.embed(text: \"Hello, world!\")\nembedding = response.embedding\n```\n\n#### `embed()` 接受的参数\n\n- `text`:（必填）要嵌入的输入文本。\n- `model`:（可选）使用的模型名称；若未指定，则使用默认嵌入模型。\n\n### 提示补全\n\n使用 `complete` 方法为给定提示生成补全：\n\n```ruby\nresponse = llm.complete(prompt: \"Once upon a time\")\ncompletion = response.completion\n```\n\n#### `complete()` 接受的参数\n\n- `prompt`:（必填）用于补全的输入提示。\n- `max_tokens`:（可选）要生成的最大标记数。\n- `temperature`:（可选）控制生成过程中的随机性。较高的值（如 0.8）会使输出更具随机性，而较低的值（如 0.2）则使其更具确定性。\n- `top_p`:（可选）作为温度的替代品，控制生成标记的多样性。\n- `n`:（可选）为每个提示生成的补全数量。\n- `stop`:（可选）API 将在此处停止生成更多标记的序列。\n- `presence_penalty`:（可选）根据标记在文本中已出现的频率对新标记进行惩罚。\n- `frequency_penalty`:（可选）根据标记在文本中出现的频率对新标记进行惩罚。\n\n### 生成聊天补全\n\n使用 `chat` 方法生成聊天补全：\n\n```ruby\nmessages = [\n  { role: \"system\", content: \"You are a helpful assistant.\" },\n  { role: \"user\", content: \"What's the weather like today?\" }\n  # Google Gemini 和 Google VertexAI 要求消息采用不同格式：\n  # { role: \"user\", parts: [{ text: \"why is the sky blue?\" }]}\n]\nresponse = llm.chat(messages: messages)\nchat_completion = response.chat_completion\n```\n\n#### `chat()` 接受的参数\n\n- `messages`:（必填）代表对话历史的消息对象数组。\n- `model`:（可选）要使用的特定聊天模型。\n- `temperature`:（可选）控制生成过程中的随机性。\n- `top_p`:（可选）作为温度的替代品，控制生成标记的多样性。\n- `n`:（可选）要生成的聊天补全选项数量。\n- `max_tokens`:（可选）聊天补全中要生成的最大标记数。\n- `stop`:（可选）API 将在此处停止生成更多标记的序列。\n- `presence_penalty`:（可选）根据标记在文本中已出现的频率对新标记进行惩罚。\n- `frequency_penalty`:（可选）根据标记在文本中出现的频率对新标记进行惩罚。\n- `logit_bias`:（可选）修改指定标记出现在补全中的可能性。\n- `user`:（可选）代表最终用户的唯一标识符。\n- `tools`:（可选）模型可能调用的工具列表。\n- `tool_choice`:（可选）控制模型如何调用函数。\n\n## 切换 LLM 提供商\n\n得益于统一的接口，您可以通过更改实例化的类轻松切换不同的 LLM 提供商：\n\n```ruby\n# 使用 Anthropic\nanthropic_llm = Langchain::LLM::Anthropic.new(api_key: ENV[\"ANTHROPIC_API_KEY\"])\n\n# 使用 Google Gemini\ngemini_llm = Langchain::LLM::GoogleGemini.new(api_key: ENV[\"GOOGLE_GEMINI_API_KEY\"])\n\n# 使用 OpenAI\nopenai_llm = Langchain::LLM::OpenAI.new(api_key: ENV[\"OPENAI_API_KEY\"])\n```\n\n## 响应对象\n\n每个 LLM 方法都会返回一个响应对象，该对象提供了一致的接口来访问结果：\n\n- `embedding`: 返回嵌入向量\n- `completion`: 返回生成的文本补全\n- `chat_completion`: 返回生成的聊天补全\n- `tool_calls`: 返回 LLM 执行的工具调用\n- `prompt_tokens`: 返回提示中的标记数\n- `completion_tokens`: 返回补全中的标记数\n- `total_tokens`: 返回使用的总标记数\n\n> [!注意]\n> 虽然核心接口在各提供商之间保持一致，但某些 LLM 可能提供额外的功能或参数。请查阅每个 LLM 类的文档，以了解特定提供商的功能和选项。\n\n### 提示管理\n\n#### 提示模板\n\n创建带有输入变量的提示：\n\n```ruby\nprompt = Langchain::Prompt::PromptTemplate.new(template: \"给我讲一个关于{content}的{adjective}笑话。\", input_variables: [\"adjective\", \"content\"])\nprompt.format(adjective: \"有趣\", content: \"鸡\") # \"给我讲一个关于鸡的有趣笑话。\"\n```\n\n仅使用提示文本而不带输入变量创建 PromptTemplate：\n\n```ruby\nprompt = Langchain::Prompt::PromptTemplate.from_template(\"给我讲一个关于鸡的有趣笑话。\")\nprompt.input_variables # []\nprompt.format # \"给我讲一个关于鸡的有趣笑话。\"\n```\n\n将提示模板保存为 JSON 文件：\n\n```ruby\nprompt.save(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Fprompt_template.json\")\n```\n\n使用 JSON 文件加载新的提示模板：\n\n```ruby\nprompt = Langchain::Prompt.load_from_path(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Fprompt_template.json\")\nprompt.input_variables # [\"adjective\", \"content\"]\n```\n\n#### 少量示例提示模板\n\n创建包含少量示例的提示：\n\n```ruby\nprompt = Langchain::Prompt::FewShotPromptTemplate.new(\n  prefix: \"为以下词语写出反义词。\",\n  suffix: \"输入：{adjective}\\n输出：\",\n  example_prompt: Langchain::Prompt::PromptTemplate.new(\n    input_variables: [\"input\", \"output\"],\n    template: \"输入：{input}\\n输出：{output}\"\n  ),\n  examples: [\n    { \"input\": \"happy\", \"output\": \"sad\" },\n    { \"input\": \"tall\", \"output\": \"short\" }\n  ],\n  input_variables: [\"adjective\"]\n)\n\nprompt.format(adjective: \"good\")\n\n# 为以下词语写出反义词。\n#\n# 输入：happy\n# 输出：sad\n#\n# 输入：tall\n# 输出：short\n#\n# 输入：good\n# 输出：\n```\n\n将提示模板保存为 JSON 文件：\n\n```ruby\nprompt.save(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Ffew_shot_prompt_template.json\")\n```\n\n使用 JSON 文件加载新的提示模板：\n\n```ruby\nprompt = Langchain::Prompt.load_from_path(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Ffew_shot_prompt_template.json\")\nprompt.prefix # \"为以下词语写出反义词。\"\n```\n\n使用 YAML 文件加载新的提示模板：\n\n```ruby\nprompt = Langchain::Prompt.load_from_path(file_path: \"spec\u002Ffixtures\u002Fprompt\u002Fprompt_template.yaml\")\nprompt.input_variables #=> [\"adjective\", \"content\"]\n```\n\n\n### 输出解析器\n\n将 LLM 的文本响应解析为结构化输出，例如 JSON。\n\n#### 结构化输出解析器\n\n您可以使用 `StructuredOutputParser` 生成一个提示，指示 LLM 提供符合特定 JSON 模式的 JSON 响应：\n\n```ruby\njson_schema = {\n  type: \"object\",\n  properties: {\n    name: {\n      type: \"string\",\n      description: \"人的姓名\"\n    },\n    age: {\n      type: \"number\",\n      description: \"人的年龄\"\n    },\n    interests: {\n      type: \"array\",\n      items: {\n        type: \"object\",\n        properties: {\n          interest: {\n            type: \"string\",\n            description: \"一个感兴趣的领域\"\n          },\n          levelOfInterest: {\n            type: \"number\",\n            description: \"表示该人对该兴趣的兴趣程度，取值范围为 0 到 100\"\n          }\n        },\n        required: [\"interest\", \"levelOfInterest\"],\n        additionalProperties: false\n      },\n      minItems: 1,\n      maxItems: 3,\n      description: \"列出该人的兴趣爱好\"\n    }\n  },\n  required: [\"name\", \"age\", \"interests\"],\n  additionalProperties: false\n}\nparser = Langchain::OutputParsers::StructuredOutputParser.from_json_schema(json_schema)\nprompt = Langchain::Prompt::PromptTemplate.new(template: \"生成一个虚构角色的详细信息。\\n{format_instructions}\\n角色描述：{description}\", input_variables: [\"description\", \"format_instructions\"])\nprompt_text = prompt.format(description: \"韩国化学系学生\", format_instructions: parser.get_format_instructions)\n# 生成一个虚构角色的详细信息。\n# 您必须将输出格式化为符合给定“JSON Schema”实例的 JSON 值。\n# ...\n```\n\n然后解析 LLM 的响应：\n\n```ruby\nllm = Langchain::LLM::OpenAI.new(api_key: ENV[\"OPENAI_API_KEY\"])\nllm_response = llm.chat(messages: [{role: \"user\", content: prompt_text}]).completion\nparser.parse(llm_response)\n# {\n#   \"name\" => \"金智贤\",\n#   \"age\" => 22,\n#   \"interests\" => [\n#     {\n#       \"interest\" => \"有机化学\",\n#       \"levelOfInterest\" => 85\n#     },\n#     ...\n#   ]\n# }\n```\n\n如果解析器无法解析 LLM 的响应，可以使用 `OutputFixingParser`。它会将错误信息、之前的输出和原始提示文本发送给 LLM，请求其提供“修复后”的响应：\n\n```ruby\nbegin\n  parser.parse(llm_response)\nrescue Langchain::OutputParsers::OutputParserException => e\n  fix_parser = Langchain::OutputParsers::OutputFixingParser.from_llm(\n    llm: llm,\n    parser: parser\n  )\n  fix_parser.parse(llm_response)\nend\n```\n\n或者，如果您不需要处理 `OutputParserException`，可以简化代码：\n\n```ruby\n# 我们已经有了 `OutputFixingParser`：\n# parser = Langchain::OutputParsers::StructuredOutputParser.from_json_schema(json_schema)\nfix_parser = Langchain::OutputParsers::OutputFixingParser.from_llm(\n  llm: llm,\n  parser: parser\n)\nfix_parser.parse(llm_response)\n```\n\n具体示例请参见 [这里](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Ftree\u002Fmain\u002Fexamples\u002Fcreate_and_manage_prompt_templates_using_structured_output_parser.rb)。\n\n## 构建检索增强生成（RAG）系统\nRAG 是一种帮助 LLM 生成准确且最新信息的方法论。\n典型的 RAG 工作流程遵循以下 3 个步骤：\n1. 从知识库（通常是向量搜索数据库）中检索相关知识（或数据）。\n2. 构建包含上述检索到的知识的提示。\n3. LLM 接收上述提示并生成文本补全。\nRAG 系统最常见的用法是支持问答系统，用户可以用自然语言提问，并以自然语言获得答案。\n\n### 向量搜索数据库\nLangchain.rb 在支持的向量搜索数据库之上提供了一个便捷的统一接口，使配置索引、添加数据、查询和检索变得非常容易。\n\n#### 支持的向量搜索数据库及功能：\n\n| 数据库                                                                                   | 开源        | 云服务     |\n| --------                                                                                   |:------------------:| :------------:     |\n| [Chroma](https:\u002F\u002Ftrychroma.com\u002F?utm_source=langchainrb&utm_medium=github)                  | ✅                 | ✅                 |\n| [Hnswlib](https:\u002F\u002Fgithub.com\u002Fnmslib\u002Fhnswlib\u002F?utm_source=langchainrb&utm_medium=github)     | ✅                 | ❌                 |\n| [Milvus](https:\u002F\u002Fmilvus.io\u002F?utm_source=langchainrb&utm_medium=github)                      | ✅                 | ✅ Zilliz Cloud    |\n| [Pinecone](https:\u002F\u002Fwww.pinecone.io\u002F?utm_source=langchainrb&utm_medium=github)              | ❌                 | ✅                 |\n| [Pgvector](https:\u002F\u002Fgithub.com\u002Fpgvector\u002Fpgvector\u002F?utm_source=langchainrb&utm_medium=github) | ✅                 | ✅                 |\n| [Qdrant](https:\u002F\u002Fqdrant.tech\u002F?utm_source=langchainrb&utm_medium=github)                    | ✅                 | ✅                 |\n| [Weaviate](https:\u002F\u002Fweaviate.io\u002F?utm_source=langchainrb&utm_medium=github)                  | ✅                 | ✅                 |\n| [Elasticsearch](https:\u002F\u002Fwww.elastic.co\u002F?utm_source=langchainrb&utm_medium=github)          | ✅                 | ✅                 |\n\n### 使用向量搜索数据库 🔍\n\n选择你要使用的向量搜索数据库，添加 gem 依赖并实例化客户端：\n```ruby\ngem \"weaviate-ruby\", \"~> 0.8.9\"\n```\n\n选择并实例化你将用于生成嵌入的 LLM 提供者：\n```ruby\nllm = Langchain::LLM::OpenAI.new(api_key: ENV[\"OPENAI_API_KEY\"])\n```\n\n```ruby\nclient = Langchain::Vectorsearch::Weaviate.new(\n    url: ENV[\"WEAVIATE_URL\"],\n    api_key: ENV[\"WEAVIATE_API_KEY\"],\n    index_name: \"Documents\",\n    llm: llm\n)\n```\n\n你也可以实例化其他任何支持的向量搜索数据库：\n```ruby\nclient = Langchain::Vectorsearch::Chroma.new(...)   # `gem \"chroma-db\", \"~> 0.6.0\"`\nclient = Langchain::Vectorsearch::Hnswlib.new(...)  # `gem \"hnswlib\", \"~> 0.8.1\"`\nclient = Langchain::Vectorsearch::Milvus.new(...)   # `gem \"milvus\", \"~> 0.9.3\"`\nclient = Langchain::Vectorsearch::Pinecone.new(...) # `gem \"pinecone\", \"~> 1.0\"`\nclient = Langchain::Vectorsearch::Pgvector.new(...) # `gem \"pgvector\", \"~> 0.2\"`\nclient = Langchain::Vectorsearch::Qdrant.new(...)   # `gem \"qdrant-ruby\", \"~> 0.9.3\"`\nclient = Langchain::Vectorsearch::Elasticsearch.new(...)   # `gem \"elasticsearch\", \"~> 8.2.0\"`\n```\n\n创建默认模式：\n```ruby\nclient.create_default_schema\n```\n\n将纯文本数据添加到你的向量搜索数据库中：\n```ruby\nclient.add_texts(\n  texts: [\n    \"首先预热烤箱至 375°F（190°C）。准备四块去骨去皮鸡胸肉，在每块鸡胸肉的一侧切开一个口袋，注意不要完全切断。根据口味用盐和胡椒粉给鸡肉调味。在一口大煎锅中，用中火融化 2 汤匙无盐黄油。加入 1 个小洋葱丁和 2 瓣蒜末，炒至变软，约 3-4 分钟。加入 8 盎司新鲜菠菜，炒至菠菜变软，约 3 分钟。将锅从火上移开，让混合物稍微冷却。\",\n      \"在一个碗中，将菠菜混合物与 4 盎司软化的奶油奶酪、1\u002F4 杯磨碎的帕尔马干酪、1\u002F4 杯马苏里拉奶酪丝以及 1\u002F4 茶匙红辣椒碎混合均匀。将混合物均匀地填入每块鸡胸肉的口袋中。如有必要，可用牙签封住口袋。在同一口锅中，用中高火加热 1 汤匙橄榄油，放入酿好的鸡胸肉，每面煎 3-4 分钟，或直至金黄色。\"\n  ]\n)\n```\n\n或者使用文件解析器加载、解析并将数据索引到你的数据库中：\n```ruby\nmy_pdf = Langchain.root.join(\"path\u002Fto\u002Fmy.pdf\")\nmy_text = Langchain.root.join(\"path\u002Fto\u002Fmy.txt\")\nmy_docx = Langchain.root.join(\"path\u002Fto\u002Fmy.docx\")\n\nclient.add_data(paths: [my_pdf, my_text, my_docx])\n```\n支持的文件格式：docx、html、pdf、text、json、jsonl、csv、xlsx、eml、pptx。\n\n根据传入的查询字符串检索相似文档：\n```ruby\nclient.similarity_search(\n  query:,\n  k:       # 要检索的结果数量\n)\n```\n\n根据通过 [HyDE 技术](https:\u002F\u002Farxiv.org\u002Fabs\u002F2212.10496) 传入的查询字符串检索相似文档：\n```ruby\nclient.similarity_search_with_hyde()\n```\n\n根据传入的嵌入向量检索相似文档：\n```ruby\nclient.similarity_search_by_vector(\n  embedding:,\n  k:       # 要检索的结果数量\n)\n```\n\n基于 RAG 的查询：\n```ruby\nclient.ask(question: \"...\")\n```\n\n## 助手\n`Langchain::Assistant` 是一个强大而灵活的类，它结合了大型语言模型 (LLMs)、工具和对话管理，以创建智能、交互式的助手。它旨在处理复杂的对话、执行工具操作，并根据交互上下文提供连贯的响应。\n\n### 特性\n* 支持多个 LLM 提供商（OpenAI、Google Gemini、Anthropic、Mistral AI 以及通过 Ollama 使用的开源模型）\n* 可集成多种工具以扩展功能\n* 管理对话线程\n* 处理自动和手动工具执行\n* 支持不同 LLM 提供商的多种消息格式\n\n### 使用方法\n```ruby\nllm = Langchain::LLM::OpenAI.new(api_key: ENV[\"OPENAI_API_KEY\"])\nassistant = Langchain::Assistant.new(\n  llm: llm,\n  instructions: \"你是一位乐于助人的 AI 助手\",\n  tools: [Langchain::Tool::NewsRetriever.new(api_key: ENV[\"NEWS_API_KEY\"])]\n)\n\n# 添加用户消息并运行助手\nassistant.add_message_and_run!(content: \"关于人工智能的最新消息是什么？\")\n\n# 向助手提供一张图片\nassistant.add_message_and_run!(\n  content: \"请描述这张图片。\",\n  image_url: \"https:\u002F\u002Fupload.wikimedia.org\u002Fwikipedia\u002Fcommons\u002Fthumb\u002Fd\u002Fdd\u002FGfp-wisconsin-madison-the-nature-boardwalk.jpg\u002F2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\"\n)\n\n# 访问对话线程\nmessages = assistant.messages\n\n# 以自动工具执行方式运行助手\nassistant.run(auto_tool_execution: true)\n\n# 如果你想流式传输响应，可以添加一个响应处理器\nassistant = Langchain::Assistant.new(\n  llm: llm,\n  instructions: \"你是一位乐于助人的 AI 助手\",\n  tools: [Langchain::Tool::NewsRetriever.new(api_key: ENV[\"NEWS_API_KEY\"])]\n) do |response_chunk|\n  # ...处理响应流\n  # print(response_chunk.inspect)\nend\nassistant.add_message(content: \"你好\")\nassistant.run(auto_tool_execution: true)\n```\n\n请注意，目前并非所有 LLM 都支持流式传输。\n\n### 配置\n* `llm`: 要使用的 LLM 实例（必填）\n* `tools`: 工具实例数组（可选）\n* `instructions`: 助手的系统指令（可选）\n* `tool_choice`: 指定工具的选择方式。默认值为 \"auto\"。也可以传入具体的工具函数名称，这将强制助手**始终**使用该函数。\n* `parallel_tool_calls`: 是否允许并行调用多个工具。默认值为 true。\n* `add_message_callback`: 当有消息被添加到对话中时调用的回调函数（proc 或 lambda）（可选）\n```ruby\nassistant.add_message_callback = -> (message) { puts \"新消息: #{message}\" }\n```\n* `tool_execution_callback`: 在工具执行之前调用的回调函数（proc 或 lambda）（可选）\n```ruby\nassistant.tool_execution_callback = -> (tool_call_id, tool_name, method_name, tool_arguments) { puts \"正在执行 tool_call_id: #{tool_call_id}, tool_name: #{tool_name}, method_name: #{method_name}, tool_arguments: #{tool_arguments}\" }\n```\n\n### 主要方法\n* `add_message`: 将用户消息添加到消息数组中。\n* `run!`: 处理对话并生成响应。\n* `add_message_and_run!`: 结合添加消息和运行助手的功能。\n* `submit_tool_output`: 手动提交工具调用的输出。\n* `messages`: 返回当前正在进行的消息列表。\n\n### 内置工具 🛠️\n* `Langchain::Tool::Calculator`: 用于计算数学表达式。需要安装 `gem \"eqn\"`。\n* `Langchain::Tool::Database`: 连接你的 SQL 数据库。需要安装 `gem \"sequel\"`。\n* `Langchain::Tool::FileSystem`: 与文件系统交互（读写）。\n* `Langchain::Tool::GoogleSearch`: 基于 SerpApi 的 Google 搜索 API 封装。需要安装 `gem \"google_search_results\"`。\n* `Langchain::Tool::NewsRetriever`: 基于 [NewsApi.org](https:\u002F\u002Fnewsapi.org) 的新闻文章获取封装。\n* `Langchain::Tool::RubyCodeInterpreter`: 用于执行生成的 Ruby 代码。需要安装 `gem \"safe_ruby\"`（仍在寻找更好的解决方案）。\n* `Langchain::Tool::Tavily`: 基于 [Tavily AI](https:\u002F\u002Ftavily.com) 的封装。\n* `Langchain::Tool::Vectorsearch`: 向量搜索类的封装。\n* `Langchain::Tool::Weather`: 调用 [Open Weather API](https:\u002F\u002Fhome.openweathermap.org) 获取当前天气。\n* `Langchain::Tool::Wikipedia`: 调用 Wikipedia API。需要安装 `gem \"wikipedia-client\"`。\n\n### 创建自定义工具\n可以通过创建继承 `Langchain::ToolDefinition` 模块并实现所需方法的类，轻松扩展 Langchain::Assistant 的功能。\n```ruby\nclass MovieInfoTool\n  extend Langchain::ToolDefinition\n\n  define_function :search_movie, description: \"MovieInfoTool：按标题搜索电影\" do\n    property :query, type: \"string\", description: \"要搜索的电影标题\", required: true\n  end\n\n  define_function :get_movie_details, description: \"MovieInfoTool：获取特定电影的详细信息\" do\n    property :movie_id, type: \"integer\", description: \"电影的 TMDb ID\", required: true\n  end\n\n  def initialize(api_key:)\n    @api_key = api_key\n  end\n\n  def search_movie(query:)\n    tool_response(...)\n  end\n\n  def get_movie_details(movie_id:)\n    tool_response(...)\n  end\nend\n```\n\n#### 使用示例：\n```ruby\nmovie_tool = MovieInfoTool.new(api_key: \"...\")\n\nassistant = Langchain::Assistant.new(\n  llm: llm,\n  instructions: \"你是一个可以帮助提供电影信息的AI助手\",\n  tools: [movie_tool]\n)\n\nassistant.add_message_and_run(content: \"你能告诉我关于电影《盗梦空间》的信息吗？\")\n# 查看对话中最后一条消息的回复\nassistant.messages.last\n```\n\n### 错误处理\n助手内置了对无效输入、不支持的 LLM 类型以及工具执行失败等情况的错误处理机制。它使用状态机来管理对话流程，并优雅地处理各种场景。\n\n### 演示\n1. [构建一个操作模拟电商商店的AI助手](https:\u002F\u002Fwww.loom.com\u002Fshare\u002F83aa4fd8dccb492aad4ca95da40ed0b2)\n2. [新的 Langchain.rb 助手界面](https:\u002F\u002Fwww.loom.com\u002Fshare\u002Fe883a4a49b8746c1b0acf9d58cf6da36)\n3. [Langchain.rb 助手演示：结合 NewsRetriever 和 Gemini 的函数调用](https:\u002F\u002Fyoutu.be\u002F-ieyahrpDpM?t=1477s) - [代码](https:\u002F\u002Fgithub.com\u002Fpalladius\u002Fgemini-news-crawler)\n\n## 评估 (Evals)\n评估模块是一组工具，可用于评估和跟踪 LLM 及其 RAG（检索增强生成）流水线的输出性能。\n\n### RAGAS\nRagas 帮助你评估你的检索增强生成（RAG）流水线。其实现基于这篇[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2309.15217)和原始的 Python [仓库](https:\u002F\u002Fgithub.com\u002Fexplodinggradients\u002Fragas)。Ragas 会跟踪以下 3 个指标，并给出 0.0 到 1.0 的分数：\n* 忠实度 - 答案基于给定的上下文。\n* 上下文相关性 - 检索到的上下文集中且几乎没有无关信息。\n* 答案相关性 - 生成的答案直接回答了提出的问题。\n\n```ruby\n# 我们建议使用 Langchain::LLM::OpenAI 作为 Ragas 的 LLM\nragas = Langchain::Evals::Ragas::Main.new(llm: llm)\n\n# LLM 生成的答案\n# 提出的问题（或原始提示）\n# 检索到的上下文（通常来自向量搜索数据库）\nragas.score(answer: \"\", question: \"\", context: \"\")\n# =>\n# {\n#   ragas_score: 0.6601257446503674,\n#   answer_relevance_score: 0.9573145866787608,\n#   context_relevance_score: 0.6666666666666666,\n#   faithfulness_score: 0.5\n# }\n```\n\n## 示例\n更多示例请参见：[\u002Fexamples](https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Ftree\u002Fmain\u002Fexamples)\n\n## 日志记录\n\nLangchain.rb 使用标准的 Ruby [Logger](https:\u002F\u002Fruby-doc.org\u002Fstdlib-2.4.0\u002Flibdoc\u002Flogger\u002Frdoc\u002FLogger.html) 机制，默认日志级别为 `Logger::DEBUG`。\n\n若需显示所有日志消息：\n\n```ruby\nLangchain.logger.level = Logger::DEBUG\n```\n\n默认情况下，日志会输出到 `STDOUT`。若要配置日志目标（例如写入文件），可以这样做：\n\n```ruby\nLangchain.logger = Logger.new(\"path\u002Fto\u002Ffile\", **Langchain::LOGGER_OPTIONS)\n```\n\n## 问题\n\n如果在安装 `pragmatic_segmenter` 所需的 `unicode` gem 时遇到问题，可以尝试运行以下命令：\n```bash\ngem install unicode -- --with-cflags=\"-Wno-incompatible-function-pointer-types\"\n```\n\n## 开发\n\n1. `git clone https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb.git`\n2. `cp .env.example .env`，然后填写 `.env` 文件中的环境变量。\n3. `bundle exec rake` 来确保测试通过，并运行 standardrb。\n4. `bin\u002Fconsole` 加载 gem 进入 REPL 会话。你可以自由添加自己的 LLM、工具、代理等实例，并进行实验。\n5. 也可以选择安装 lefthook git hooks 用于 pre-commit 自动 lint：`gem install lefthook && lefthook install -f`\n\n## Discord\n加入我们的 [Langchain.rb](https:\u002F\u002Fdiscord.gg\u002FWDARp7J2n8) Discord 服务器。\n\n## 星标历史\n\n[![星标历史图表](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fpatterns-ai-core_langchainrb_readme_dd20ee231d7e.png)](https:\u002F\u002Fstar-history.com\u002F#andreibondarev\u002Flangchainrb&Date)\n\n## 贡献\n欢迎在 GitHub 上提交 bug 报告和 pull 请求：https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb。\n\n## 许可证\n该 gem 以开源形式发布，遵循 [MIT 许可证](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT) 的条款。","# Langchain.rb 快速上手指南\n\nLangchain.rb 是一个用于在 Ruby 中构建大语言模型（LLM）驱动应用的开源库。它提供了统一的接口来连接多种 LLM 提供商，支持检索增强生成（RAG）、聊天机器人等场景。\n\n## 环境准备\n\n*   **系统要求**: 需要安装 Ruby (建议版本 3.0+)。\n*   **前置依赖**:\n    *   包管理工具：`bundler` (推荐) 或 `gem`。\n    *   API Key：根据你选择的 LLM 提供商（如 OpenAI, Anthropic, Google Gemini 等），需提前申请对应的 API Key 并配置为环境变量。\n*   **网络提示**: 由于 LLM 服务大多位于海外，国内开发者可能需要配置代理或使用特定的网络加速方案以确保连接稳定。\n\n## 安装步骤\n\n### 方式一：使用 Bundler（推荐 Rails 或标准项目）\n\n在项目根目录执行以下命令，将 gem 添加到 `Gemfile` 并安装：\n\n```bash\nbundle add langchainrb\n```\n\n### 方式二：直接安装\n\n如果不使用 Bundler 管理依赖，可直接执行：\n\n```bash\ngem install langchainrb\n```\n\n> **注意**：核心库不包含所有提供商的依赖。如果你需要使用特定的 LLM（如 `anthropic` 或 `google-generative-ai`），可能需要额外安装对应的 gem，具体请参考各提供商的文档说明。\n\n## 基本使用\n\n### 1. 引入库\n\n在你的 Ruby 脚本或控制台入口文件中引入：\n\n```ruby\nrequire \"langchain\"\n```\n\n### 2. 初始化 LLM 客户端\n\nLangchain.rb 提供统一接口。以下以 OpenAI 为例，初始化客户端并设置默认参数：\n\n```ruby\nllm = Langchain::LLM::OpenAI.new(\n  api_key: ENV[\"OPENAI_API_KEY\"],\n  default_options: { temperature: 0.7, chat_model: \"gpt-4o\" }\n)\n```\n\n*注：切换其他提供商只需更改类名，例如 `Langchain::LLM::Anthropic.new` 或 `Langchain::LLM::GoogleGemini.new`。*\n\n### 3. 发起对话请求\n\n构建消息历史并调用 `chat` 方法获取回复：\n\n```ruby\nmessages = [\n  { role: \"system\", content: \"You are a helpful assistant.\" },\n  { role: \"user\", content: \"请用中文介绍什么是 RAG？\" }\n]\n\nresponse = llm.chat(messages: messages)\nputs response.chat_completion\n```\n\n### 4. 进阶：结构化输出（可选）\n\n如果你需要让 LLM 返回固定的 JSON 格式数据，可以使用 `StructuredOutputParser`：\n\n```ruby\n# 定义 JSON Schema\njson_schema = {\n  type: \"object\",\n  properties: {\n    name: { type: \"string\", description: \"人物姓名\" },\n    age: { type: \"number\", description: \"人物年龄\" }\n  },\n  required: [\"name\", \"age\"]\n}\n\n# 创建解析器\nparser = Langchain::OutputParsers::StructuredOutputParser.from_json_schema(json_schema)\n\n# 构建包含格式指令的 Prompt\nprompt = Langchain::Prompt::PromptTemplate.new(\n  template: \"生成一个虚构人物的信息。\\n{format_instructions}\\n描述：{description}\",\n  input_variables: [\"description\", \"format_instructions\"]\n)\n\nprompt_text = prompt.format(description: \"一位年轻的 Ruby 开发者\", format_instructions: parser.get_format_instructions)\n\n# 发送请求并解析结果\nllm_response = llm.chat(messages: [{role: \"user\", content: prompt_text}]).completion\nresult = parser.parse(llm_response)\n\nputs result \n# 输出示例：{\"name\"=>\"张三\", \"age\"=>28}\n```","一家拥有大量 Ruby on Rails 遗留代码的电商公司，希望为其客服系统引入基于私有商品文档的智能问答机器人，以自动回答用户关于退换货政策和商品参数的咨询。\n\n### 没有 langchainrb 时\n- **技术栈割裂**：团队被迫在现有的 Ruby 项目中嵌入 Python 微服务来调用大模型，导致架构复杂、部署维护成本高昂。\n- **重复造轮子**：开发者需手动编写代码处理不同大模型厂商（如 OpenAI、Anthropic）的 API 差异，切换模型时几乎要重写底层逻辑。\n- **RAG 实现困难**：构建检索增强生成（RAG）系统时，缺乏统一的向量数据库接口和文本分块工具，数据预处理流程繁琐且易出错。\n- **提示词管理混乱**：Prompt 模板硬编码在业务逻辑中，缺乏版本管理和动态调整机制，优化回复质量如同“盲人摸象”。\n\n### 使用 langchainrb 后\n- **原生无缝集成**：直接在 Gemfile 中引入 langchainrb，无需额外服务即可在 Rails 控制器中调用大模型，保持纯 Ruby 技术栈的统一。\n- **统一抽象接口**：通过标准化的 `Langchain::LLM` 接口，仅需修改初始化参数即可在 OpenAI、Google Gemini 或本地 Ollama 之间自由切换。\n- **一站式 RAG 构建**：利用内置的向量存储适配器和文档加载器，快速搭建起从文档切片、向量化到语义检索的完整流水线。\n- **结构化输出解析**：借助 Output Parsers 功能，轻松将大模型的自然语言回复转化为程序可处理的 JSON 对象，确保业务逻辑稳定运行。\n\nlangchainrb 让 Ruby 开发者能够以原生的开发体验，高效构建并落地企业级的大语言模型应用，彻底打破了语言生态的壁垒。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fpatterns-ai-core_langchainrb_b3c35257.png","patterns-ai-core","Patterns AI","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fpatterns-ai-core_b3f89a62.png","",null,"https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core",[80,84,88,92],{"name":81,"color":82,"percentage":83},"Ruby","#701516",94.6,{"name":85,"color":86,"percentage":87},"HTML","#e34c26",5.1,{"name":89,"color":90,"percentage":91},"JavaScript","#f1e05a",0.1,{"name":93,"color":94,"percentage":91},"CSS","#663399",1978,260,"2026-04-12T10:31:14","MIT","未说明",{"notes":101,"python":102,"dependencies":103},"这是一个 Ruby 库（Gem），而非 Python 工具。安装需使用 Ruby 包管理器（bundler 或 gem install）。支持多种 LLM 提供商（如 OpenAI, Anthropic, Google Gemini 等），部分功能可能需要额外安装对应的依赖 Gem。无本地 GPU 或特定显存要求，因为主要调用外部 API。","不适用 (此为 Ruby 库)",[104],"langchainrb (Gem)",[14,13],[107,108,109,110,111,112,113],"artificial-intelligence","machine-learning","ml","rubyml","vector-search","agents","ai-agents","2026-03-27T02:49:30.150509","2026-04-13T06:11:23.215387",[117,122,127,132,137,142],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},31371,"如何在 Langchain.rb 中实现对话历史持久化以支持多轮聊天？","可以使用新的 `Langchain::Chat` 接口，它会在内存中持久化聊天历史。用法示例如下：\n```ruby\nllm = Langchain::LLM::OpenAI.new(api_key: ENV['OPENAI_API_KEY'])\nchat_session = Langchain::Chat.new(llm: llm)\n\n# 设置上下文角色\nchat_session.set_context(\"你是一名旅行代理 AI，帮助用户制定行程。\")\n\n# 发送消息，自动包含历史记录\nchat_session.message(\"请给我一个巴黎周末三日游的行程\")\n```\n该方案由社区贡献者构建，目前支持内存持久化。","https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fissues\u002F136",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},31372,"使用 Qdrant 进行向量搜索时为什么没有创建向量或报错？","维护者已为大多数向量数据库添加了 `get_default_schema()` 方法来解决此类架构初始化问题。如果你遇到类似错误，请确保在添加文本前调用了创建默认 schema 的方法（如 `create_default_schema`），并检查是否使用了最新版本的库，相关修复已合并到主分支（PR #235）。","https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fissues\u002F221",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},31373,"当使用非官方 OpenAI 兼容服务（如 Together AI、Ollama）指定 embedding_model 时报错怎么办？","当使用兼容 OpenAI API 的服务但指定了特殊的 `embeddings_model_name` 时，可能会因令牌验证逻辑报错（如 `undefined method 'encode' for nil:NilClass`）。\n解决方法是配置 `default_options` 明确指定模型，并注意当前版本可能对非标准模型的令牌长度验证存在缺陷。示例配置：\n```ruby\nllm = Langchain::LLM::OpenAI.new(\n  api_key: 'YOUR_KEY',\n  llm_options: {uri_base: 'https:\u002F\u002Fapi.together.xyz'},\n  default_options: {\n    chat_completion_model_name: \"Qwen\u002FQwen1.5-72B\",\n    embeddings_model_name: \"WhereIsAI\u002FUAE-Large-V1\"\n  }\n)\n```\n如果 `llm.embed` 仍然报错，可能需要等待库更新移除硬编码的令牌验证或参考 Ollama 的实现方式动态获取向量维度。","https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fissues\u002F598",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},31374,"是否有将 Assistant 与向量数据库（RAG）结合使用的具体示例？","虽然文档提到 Assistants 可以配置任何向量搜索数据库，但简易示例较少。核心原理是将向量数据库封装为 Tool（工具）提供给 Assistant。\n你需要创建一个自定义 Tool，其逻辑类似于现有的检索工具，并在初始化 Assistant 时注册该工具。Assistant 会将工具的 name 和 description 发送给 LLM 作为上下文，从而让 LLM 知道何时调用该工具进行向量检索。建议参考库中现有的 Tool 实现来编写自己的向量检索工具类。","https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fissues\u002F557",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},31375,"Langchain.rb 是否支持 pgvector 扩展？","是的，社区已经提交了接近合并的 Pull Request 来支持 pgvector。pgvector 是 PostgreSQL 的扩展，允许查询和索引向量数据。对于 Ruby\u002FRails 用户，也可以参考独立的 `pgvector-ruby` gem 或 `neighbor` gem。该功能旨在帮助偏好使用 Heroku Postgres 等托管服务的用户直接在关系型数据库中进行向量搜索。","https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fissues\u002F41",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},31376,"如何运行涉及真实 API 密钥的集成测试？","项目正在讨论添加仅在发布前或按需运行的集成测试。目前有用户尝试过使用 Jupyter Notebook 进行此类测试（参考 boxcars gem 中的示例），但由于环境依赖复杂且容易出错，维护成本较高。建议关注仓库后续是否正式引入带有标记（tags）的 RSpec 集成测试套件，以便在设置好环境变量（如 `OPENAI_API_KEY`）后单独运行。","https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fissues\u002F144",[148,153,158,163,168,173,178,183,188,193,198,203,208,213,218,223,228,233,238,243],{"id":149,"version":150,"summary_zh":151,"released_at":152},231073,"0.19.5","## 变更内容\n* [安全] 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F934 中将 rack 从 3.1.10 升级至 3.1.12\n* [安全] 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F935 中将 uri 从 1.0.2 升级至 1.0.3\n* [安全] 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F925 中将 nokogiri 从 1.18.2 升级至 1.18.3\n* [安全] 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F892 中将 json-schema 的依赖更新为 >= 4, \u003C 6，取代之前的 ~> 4\n* [安全] 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F938 中将 nokogiri 从 1.18.3 升级至 1.18.6\n* [安全] 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F936 中将 graphql 从 2.3.16 升级至 2.3.21\n* 修复 Langchain::Vectorsearch::Milvus 初始化器，通过传递 :api_key 参数，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F939 中完成\n* [安全] 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F940 中将 pry-byebug 的依赖从 ~> 3.10.0 更新为 ~> 3.11.0\n* 由 @sergiobayona 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F947 中添加了带有元数据的 pgvector 搜索示例\n* 由 @aellispierce 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F859 中为文档添加了元数据支持\n* 由 @kforjan 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F945 中移除了 AWS 推理配置文件 ID 的前缀\n* 修复：处理 OpenAI LLM 流式输出中的 nil 响应，由 @sergiobayona 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F953 中完成\n* 支持 ruby-anthropic gem，由 @koic 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F951 中实现\n* 933 vectorsearchelasticsearch   对哈希实例调用 undefined method body，引发 NoMethodError 错误，由 @sergiobayona 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F954 中报告\n* 功能：添加对 Anthropic 'thinking' 参数的支持，由 @sergiobayona 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F955 中实现\n* 废弃 Epsilla 向量数据库，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F958 中宣布\n* 废弃 `Langchain::LLM::LlamaCpp` 类，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F961 中宣布\n* 废弃 `Langchain::LLM::AI21` 类，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F962 中宣布\n* 修复（Anthropic）：处理空工具输入，由 @TheBerg 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F960 中完成\n* [安全] 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F965 中将 nokogiri 从 1.18.6 升级至 1.18.8\n* [文档] 将 GitHub 组织名称更新为 patterns-ai-core，由 @koic 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F968 中完成\n* 添加对 OpenAI store 参数的支持，由 @ajsharp 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F967 中实现\n* 由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F971 中排除自动添加到 OpenAI LLM 参数中的 `temperature`\n* [文档] 修复超链接中的拼写错误 b","2025-05-01T17:37:16",{"id":154,"version":155,"summary_zh":156,"released_at":157},231074,"0.19.4","## 变更内容\n* 功能 支持在 Langchain::Assistant 的工具输出中使用图片 URL，由 @Eth3rnit3 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F894 中实现\n* [安全] 将 googleauth 从 1.11.0 升级至 1.13.1，由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F911 中完成\n* 将 ErrorClass 拆分为独立文件，由 @rishirajkumar97 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F913 中完成\n* [安全] 将 nokogiri 从 1.18.1 升级至 1.18.2，由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F914 中完成\n* [安全] 将 net-imap 从 0.4.11 升级至 0.4.19，由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F918 中完成\n* [安全] 将 rack 从 3.1.8 升级至 3.1.10，由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F919 中完成\n* 允许 o3-mini 与工具一起使用，由 @almathie 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F921 中实现\n* 0.19.4，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F923 中发布\n\n## 新贡献者\n* @Eth3rnit3 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F894 中完成了首次贡献\n* @almathie 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F921 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.19.3...0.19.4","2025-02-17T13:52:21",{"id":159,"version":160,"summary_zh":161,"released_at":162},231075,"0.19.3","## 变更内容\n* 默认将 Ollama 配置为使用 llama3.2，由 @WToa 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F889 中完成\n* 应用针对 Chroma 查询的临时解决方案，由 @justi 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F890 中完成\n* [安全] 将 rails-html-sanitizer 从 1.6.0 升级至 1.6.1，由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F893 中完成\n* Langchain::Tool::Database#describe_table 支持 COMMENT 参数，由 @Bahanix 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F891 中完成\n* [安全] 将 actionpack 从 7.1.3.3 升级至 7.1.5.1，由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F895 中完成\n* [安全] 更新 dotenv-rails 的依赖版本，从 ~> 2.7.6 调整为 ~> 3.1.6，由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F899 中完成\n* 使用 AnthropicMessage 时，若 content 为 nil，则不应设置空文本内容，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F900 中完成\n* 0.19.3 版本，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F905 中发布\n\n## 新贡献者\n* @justi 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F890 中完成了首次贡献\n* @Bahanix 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F891 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.19.2...0.19.3","2025-01-13T16:25:55",{"id":164,"version":165,"summary_zh":166,"released_at":167},231076,"0.19.2","## 变更内容\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F884 中添加了 assistant.tool_execution_callback\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F885 中发布了 0.19.2 版本\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F888 中修复了错误的发布版本\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.19.1...0.19.2","2024-11-26T22:27:33",{"id":169,"version":170,"summary_zh":171,"released_at":172},231077,"0.19.1","## 变更内容\n* 在自定义工具的创建说明中，将 `include` 替换为 `extend`，由 @jeduardo824 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F857 中完成。\n* 更新 `README.md` 文件，由 @palladius 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F862 中完成。\n* 【安全】将 `rexml` 从 3.3.6 升级至 3.3.9，由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F863 中完成。\n* Anthropic 现在可以接受包含图片的消息，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F858 中实现。\n* 改进向 Anthropic 传递最大 token 数量的方式，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F864 中完成。\n* `Langchain::Assistant` 现已支持 AWS Bedrock 托管的 Anthropic 模型，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F849 中实现。\n* 功能增强：重构不同消息类中的 `to_hash` 方法，使其按角色拆分，由 @rishirajkumar97 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F867 中完成。\n* Anthropic 的工具调用始终伴随文本内容。我们也应将其一并返回，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F869 中提出并实现。\n* 847 提供了在使用 Ollama 时向助手发送图片的功能，由 @sergiobayona 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F870 中实现。\n* 允许向 Ollama 传递选项哈希，由 @chalmagean 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F871 中完成。\n* 0.19.1 版本更新，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F879 中发布。\n\n## 新贡献者\n* @jeduardo824 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F857 中完成了首次贡献。\n* @rishirajkumar97 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F867 中完成了首次贡献。\n* @sergiobayona 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F870 中完成了首次贡献。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.19.0...0.19.1","2024-11-21T17:03:41",{"id":174,"version":175,"summary_zh":176,"released_at":177},231078,"0.19.0","## 变更内容\n* Anthropic 工具：如果无参数，则添加默认 `input_schema`，由 @dghirardo 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F837 中实现。\n* 修复清除指令时的问题，由 @qarol 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F836 中实现。\n* 允许在 Langchain::LLM::GoogleGemini 和 Langchain::LLM::GoogleVertexAI 构造函数的 `default_options` 中设置 `safety_setting: []`，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F838 中实现。\n* 增强代码注释，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F846 中实现。\n* 修复 MistralAIMessage 对“Tool”输出的处理问题，由 @dkaplan88 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F850 中实现。\n* 缩短模型名称参数，由 @bborn 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F840 中实现。\n* 0.19.0 版本，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F854 中发布。\n\n## 新贡献者\n* @qarol 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F836 中完成了首次贡献。\n* @dkaplan88 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F850 中完成了首次贡献。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.18.0...0.19.0","2024-10-23T18:47:36",{"id":179,"version":180,"summary_zh":181,"released_at":182},231079,"0.18.0","## 变更内容\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F819 中升级了 anthropic gem\n* @chalmagean 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F809 中添加了对 Anthropic 的流式支持\n* @khaile 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F801 中修复了 AWS Bedrock 聊天模型始终返回 `nil` 的问题\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F822 中修复了启用 eager_load 时的 zeitwerk 错误\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F823 中重构了助手确定工具角色的方法\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F824 中引入了 `support_system_message?` 方法\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F827 中引入了 `Langchain::Assistant#parallel_tool_calls` 选项，用于控制是否允许 LLM 执行多个并行工具调用\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F828 中发布了 0.18.0 版本\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.17.1...0.18.0","2024-10-12T20:56:02",{"id":184,"version":185,"summary_zh":186,"released_at":187},231080,"0.17.1","## 变更内容\n* 将适配器相关类移至单独文件，由 @khaile 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F807 中完成\n* 修复 Langchain::Tool::Database#describe_table 方法，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F814 中完成\n* 0.17.1 版本，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F815 中发布\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.17.0...0.17.1","2024-10-07T17:32:05",{"id":189,"version":190,"summary_zh":191,"released_at":192},231081,"0.17.0","## 变更内容\n* 由 @dependabot 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F797 中将 webrick 从 1.8.1 升级至 1.8.2\n* 当使用 OpenAI 时，Langchain::Assistant 现在接受包含 image_url 的消息，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F799 中实现\n* 当使用 MistralAI 时，Langchain::Assistant 现在接受包含 image_url 的消息，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F803 中实现\n* 向量搜索提供者应使用全局的 Langchain.logger，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F804 中提出\n* 移除 Langchain::LLM::GooglePalm，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F805 中完成\n* 0.17.0 版本，由 @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F806 中发布\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.16.1...0.17.0","2024-10-02T20:55:27",{"id":194,"version":195,"summary_zh":196,"released_at":197},231082,"0.16.1","## 变更内容\n* @chalmagean 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F760 中添加了流式传输支持\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F789 中弃用了 Langchain::LLM::GooglePalm\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F788 中允许在 Langchain::LLM::Base 的任何子类实例上显式设置客户端对象\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F766 中允许在初始化受支持的 Langchain::LLM::* 类时设置 response_object: {} 参数\n* @andreibondarev 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F793 中更新了 README.md\n* @dferrazm 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F796 中改进了日志记录\n* @dferrazm 在 https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F798 中发布了 0.16.1 版本\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.16.0...0.16.1","2024-09-30T15:09:16",{"id":199,"version":200,"summary_zh":201,"released_at":202},231083,"0.16.0","## What's Changed\r\n* Remove `Langchain::Thread` class by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F783\r\n* Support `cohere` provider for `Langchain::LLM::AwsBedrock#embed` by @khaile in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F782\r\n* Output meaning errors when GoogleGemini or GoogleVertexAI fail by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F784\r\n* Patch up ContextualLogger by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F785\r\n* 0.16.0 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F787\r\n\r\n## New Contributors\r\n* @khaile made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F782\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.15.6...0.16.0","2024-09-19T16:46:31",{"id":204,"version":205,"summary_zh":206,"released_at":207},231084,"0.15.6","## What's Changed\r\n* Add Meta models support for AWS Bedrock LLM by @Fodoj in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F764\r\n* Update azure_spec.rb by @scottwater in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F778\r\n* Assistant fixes by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F780\r\n* 0.15.6 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F781\r\n\r\n## New Contributors\r\n* @Fodoj made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F764\r\n* @scottwater made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F778\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.15.5...0.15.6","2024-09-16T19:56:35",{"id":209,"version":210,"summary_zh":211,"released_at":212},231085,"0.15.5","## What's Changed\r\n* prompt: support nested json data in `#format` by @rvmtz in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F751\r\n* Require common libs at top-level by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F754\r\n* Fix annonymous block issue by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F757\r\n* Fix annonymous block issue by @gbs0 in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F759\r\n* Prepend system message by @chalmagean in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F761\r\n* Bump unicode gem version by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F765\r\n* Add `add_message_callback` to `Langchain::Assistant` constructor to invoke an optional function when any message is added to the conversation by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F767\r\n* Adding Assistant syntactic sugar with `#run!` and `#add_message_and_run!` by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F768\r\n* 0.15.5 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F771\r\n\r\n## New Contributors\r\n* @rvmtz made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F751\r\n* @gbs0 made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F759\r\n* @chalmagean made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F761\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.15.4...0.15.5","2024-09-10T13:44:21",{"id":214,"version":215,"summary_zh":216,"released_at":217},231086,"0.15.4","## What's Changed\r\n* Improve Database tool by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F743\r\n* Allow explicitly setting `tool_choice` on the Assistant instance by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F744\r\n* Add support for bulk embedding in Ollama by @bricolage in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F735\r\n* fix: LLM::Azure not applying full default_options by @namiwang in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F746\r\n* Langchain::Assistant supports MistralAI LLM by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F748\r\n* 0.15.4 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F749\r\n\r\n## New Contributors\r\n* @namiwang made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F746\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.15.3...0.15.4","2024-08-30T15:01:51",{"id":219,"version":220,"summary_zh":221,"released_at":222},231087,"0.15.3","## What's Changed\r\n* Fix OpenAI#embed when text-embedding-ada-002 is used by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F741\r\n* 0.15.3 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F742\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.15.2...0.15.3","2024-08-27T18:44:07",{"id":224,"version":225,"summary_zh":226,"released_at":227},231088,"0.15.2","## What's Changed\r\n* Add `Assistant#add_messages()` method and fix `Assistant#messages=` method by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F731\r\n* Update Gemini Key instructions by @palladius in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F734\r\n* Bump rexml from 3.3.3 to 3.3.6 by @dependabot in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F736\r\n* 0.15.2 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F737\r\n\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.15.1...0.15.2","2024-08-23T13:01:33",{"id":229,"version":230,"summary_zh":231,"released_at":232},231089,"0.15.1","## What's Changed\r\n* drop Colorize due to GPL license by @Azdaroth in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F727\r\n* Improve Langchain::Tool::Weather tool by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F728\r\n* remove to_bool gem by @Azdaroth in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F729\r\n* 0.15.1 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F730\r\n\r\n## New Contributors\r\n* @Azdaroth made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F727\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.15.0...0.15.1","2024-08-19T13:50:40",{"id":234,"version":235,"summary_zh":236,"released_at":237},231090,"0.15.0","## What's Changed\r\n* Rewrite Assistant tools definition for easier configuration by @dghirardo in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F708\r\n* Get rid of requiring `activesupport` and add `deep_merge` gem by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F709\r\n* Improvements to Langchain::Assistant support for Ollama by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F711\r\n* Update default chat completions model to gpt-4o-mini by @edudepetris in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F712\r\n* Update CHANGELOG.md by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F713\r\n* Introducing a factory\u002Fadapter patterns to clean up the Langchain::Assistant supporting multiple different LLMs. by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F714\r\n* Fix Langchain::Assistant::LLM::Adapters::Ollama class by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F715\r\n* Revert Style\u002FArgumentsForwarding Rubocop rule by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F703\r\n* Add Support for Ollama WebUI Security by @rience in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F721\r\n* Bump rexml from 3.3.1 to 3.3.3 by @dependabot in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F719\r\n* Weaviate initializer does not require api_key by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F722\r\n* Fix `GoogleGemini#chat` method by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F723\r\n* Fix Langchain::Assistant when llm is Anthropic by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F724\r\n* 0.15.0 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F725\r\n\r\n## New Contributors\r\n* @edudepetris made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F712\r\n* @rience made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F721\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.14.0...0.15.0","2024-08-14T20:59:33",{"id":239,"version":240,"summary_zh":241,"released_at":242},231091,"0.14.0","## What's Changed\r\n* Update milvus.rb by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F691\r\n* Bump anthropic gem by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F692\r\n* Track tokens count at the Assistant level by @dferrazm in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F693\r\n* Instructions are ignored for Anthropic if tools are not used by @victorivanov in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F695\r\n* Issue 697 - Show API error when calling `.complete` on Anthropic client by @Jbrito6492 in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F698\r\n* Delete token_length validators by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F704\r\n* Assistant that does Function Calling with the Ollama Mistral model by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F702\r\n* Fix for Ollama Assistant that does not use tools by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F707\r\n* 0.14.0 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F706\r\n\r\n## New Contributors\r\n* @victorivanov made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F695\r\n* @Jbrito6492 made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F698\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.13.5...0.14.0","2024-07-12T16:38:27",{"id":244,"version":245,"summary_zh":246,"released_at":247},231092,"0.13.5","## What's Changed\r\n* ids need to be passed as strings to Chroma#remove_texts() by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F673\r\n* Update loader.rb by @michelson in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F676\r\n* fix: GoogleGemini generation_config param by @mazenkhalil in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F665\r\n* State machine for Assistant's execution phases by @dghirardo in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F677\r\n* chore: update replicate.rb by @eltociear in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F680\r\n* Swap test pdf file by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F687\r\n* Add Milvus#remove_texts() method by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F689\r\n* 0.13.5 by @andreibondarev in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F690\r\n\r\n## New Contributors\r\n* @mazenkhalil made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F665\r\n* @dghirardo made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F677\r\n* @eltociear made their first contribution in https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fpull\u002F680\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fpatterns-ai-core\u002Flangchainrb\u002Fcompare\u002F0.13.4...0.13.5","2024-07-01T19:04:01"]