当前位置: 首页 > article >正文

How to see if openAI (node js) createModeration response “flagged“ is true

题意:如何查看 OpenAI (Node.js) createModeration 响应中的 "flagged" 是否为 true

问题背景:

Using the OpenAI createModeration feature, I am trying to see if the string gets flagged or not.

使用 OpenAI 的 createModeration 功能,我正在尝试查看字符串是否被标记(flagged)

I request the API by using this: `

翻译:我通过使用以下代码请求 API:`

const mod = await openai.createModeration({
      input: 'Some text to be flagged', // isn't actually this that would get flagged
});
console.log(mod.data.results)

When I log the resposne (and it's flagged) I get this:

当我记录响应(并且它被标记)时,我得到以下内容:

[
  {
      hate: 0.057017914950847626,
      'hate/threatening': 0.0013999055372551084,
      'self-harm': 1.523021175842132e-8,
      sexual: 0.000011195417755516246,
      'sexual/minors': 4.2277463307982543e-8,
      violence: 0.8440001010894775,
      'violence/graphic': 1.2527605974810285e-7
    },
    flagged: true
  }
]

However, if I try to get the "flagged" option by doing mod.data.results.flagged it returns unidentified.

然而,当我尝试通过 mod.data.results.flagged 获取 "flagged" 选项时,它返回未定义(unidentified)

问题解决:

mod.data.results is an array of objects. To get the first flagged value specify mod.data.results[0].flagged (or mod.data.results[0]?.flagged to account for an empty array)

mod.data.results 是一个对象数组。要获取第一个 flagged 的值,可以指定 mod.data.results[0].flagged(或使用 mod.data.results[0]?.flagged 来处理空数组)

UPDATE Actually something is not correct with your example object, it is missing a curly bracket.

更新:实际上,你的示例对象有些不对,缺少了一个花括号


http://www.kler.cn/news/307846.html

相关文章:

  • 代码随想录算法训练营第五十八天 | 拓扑排序精讲-软件构建
  • Arduino IDE离线配置第三方库文件-ESP32开发板
  • 8.JMeter+Ant(基于工具的实现接口自动化,命令行方式)
  • 常见的限流算法
  • 【C/C++】程序的构建(编译)过程概述
  • 【C++】函数重载
  • Python使用pymysql返回字典类型的数据
  • yum本地源配置
  • 基于 SpringBoot 的车辆充电桩管理系统
  • 医药|基于springboot的医药管理系统设计与实现(附项目源码+论文+数据库)
  • JAVA算法数据结构第一节稀疏矩阵
  • ADB ROOT开启流程
  • C# AutoResetEvent ManualResetEvent Mutex 对比
  • 54.【C语言】 字符函数和字符串函数(strncpy,strncat,strncmp函数)
  • ip映射域名,一般用于mysql和redis的固定映射,方便快捷打包
  • python基本数据类型简记
  • vue3 组合式API defineEmits() 与 emits 组件选项
  • I²C通信协议
  • 基于SpringBoot的考研助手系统+LW参考示例
  • 模拟实现通用型排序
  • Rust练手项目,写个有趣的小工具定时从一言网获取一段有趣的话并推送通知
  • STM32—I2C
  • OpenAI o1真的那么强吗
  • 天地一体化物联网:挑战与机遇
  • 移动订货小程序哪个好 批发订货系统源码哪个好
  • 【Elasticsearch系列八】高阶使用
  • 您的计算机已被.lcrypt勒索病毒感染?恢复您的数据的方法在这里!
  • 春秋云境靶场之CVE-2022-29464
  • element-plus弹窗内分页表格保留勾选项
  • 大数据-134 - ClickHouse 集群三节点 安装配置启动