Ruby langchainrb gem and custom configuration for the model setup

题意 :Ruby 的 langchainrb gem 以及针对模型设置的自定义配置

问题背景:

I am working in a prototype using the gem langchainrb. I am using the module assistant module to implemente a basic RAG architecture.

我正在使用 langchainrb 这个 gem 来开发一个原型。我利用其中的 assistant 模块来实现一个基本的 RAG(Retrieval-Augmented Generation,检索增强生成)架构。

Everything works, and now I would like to customize the model configuration.

一切运行正常,现在我想自定义模型的配置。

In the documenation there is no clear way of setting up the Model. In my case, I would like to use OpenAi and use:

在文档中,没有明确的方法来设置模型。在我的情况下,我想使用 OpenAI 并使用以下配置:

  • temperature: 0.1
  • Model: gpt-4o

In the README, there is a mention about using llm_options.

在 README 文件中,提到了使用 llm_options

If I go to the OpenAI Module documentation:

如果我去查看 OpenAI 模块的文档:

It says I have to check here: 它说我要查看这里:

But there is not any mention of temperature, for example. Also, in the example in the Langchain::LLM::OpenAI documentation, the options are totally different.

但是在文档中并没有提到例如"温度"这样的设置。此外,在 Langchain::LLM::OpenAI 的文档示例中,给出的选项是完全不同的。

I am working in a prototype using the gem langchainrb. I am using the module assistant module to implemente a basic RAG architecture.

Everything works, and now I would like to customize the model configuration.

In the documenation there is no clear way of setting up the Model. In my case, I would like to use OpenAi and use:

In the README, there is a mention about using llm_options.

If I go to the OpenAI Module documentation:

It says I have to check here:

But there is not any mention of temperature, for example. Also, in the example in the Langchain::LLM::OpenAI documentation, the options are totally different.

ruby 复制代码
# ruby-openai options:

CONFIG_KEYS = %i[
  api_type
  api_version
  access_token
  log_errors
  organization_id
  uri_base
  request_timeout
  extra_headers
].freeze
python 复制代码
# Example in Class: Langchain::LLM::OpenAI documentation: 

{
  n: 1,
  temperature: 0.0,
  chat_completion_model_name: "gpt-3.5-turbo",
  embeddings_model_name: "text-embedding-3-small"
}.freeze

问题解决:

I have a conflict between llm_options and default_options. I thought it was the same with different priorities.

我在 llm_optionsdefault_options 之间遇到了冲突。我原本以为它们只是优先级不同的相同设置。

For the needs expressed in the question I have to use the default_options as in here:

针对问题中表达的需求,我必须按照这里的示例来使用 default_options

python 复制代码
llm =
  Langchain::LLM::OpenAI.new(
    api_key: <OPENAI_KEY>,
    default_options: {
      temperature: 0.0,
      chat_completion_model_name: "gpt-4o"
    }
  )
相关推荐
努力的小雨14 分钟前
把 Windows 桌面图标做成一个会自己运转的小世界
后端
武子康1 小时前
Search Console Platform Properties 扩大 SEO 资产边界:从 Page Ranking 到 Topic Coverage(5 类误读边界 + 3 表数据层设计)
前端·人工智能·后端
大模型码小白1 小时前
【Python零基础教程】继承、多态与魔法函数:面向对象编程三大核心特性详解
java·大数据·开发语言·人工智能·python·ai编程
腾渊信息科技公司2 小时前
Spring Boot对接MES实战:视觉检测数据自动同步方案
java·人工智能·spring boot·后端·计算机视觉·ai·软件需求
IT_陈寒3 小时前
Vue这个特性差点让我加班到凌晨,谁懂啊
前端·人工智能·后端
段一凡-华北理工大学3 小时前
向量数据库实战:选型、调优与落地~系列文章12:文本分块策略实战:chunk_size 怎么选?重叠多少?
开发语言·数据库·后端·oracle·rust·工业智能体·高炉智能化
Ljwuhe3 小时前
C++——多态
开发语言·c++
码事漫谈4 小时前
1999年的电商前夜和2026年的AI前夜 历史押韵但从不重复
后端
心平气和量大福大4 小时前
C#-WPF-Window主窗体
开发语言·c#·wpf
Conan在掘金4 小时前
鸿蒙报错速查:arkts-strict-typing Property does not exist on type 'object',object 装函数就炸,根因 + 真解法
后端