Merge branch 'main' into feat/knowledge-dark-mode
commit
684f7188f4
@ -0,0 +1,26 @@
|
||||
from typing import Any, Union
|
||||
|
||||
import requests
|
||||
|
||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||
from core.tools.tool.builtin_tool import BuiltinTool
|
||||
|
||||
|
||||
class GiteeAIToolRiskControl(BuiltinTool):
|
||||
def _invoke(
|
||||
self, user_id: str, tool_parameters: dict[str, Any]
|
||||
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||
headers = {
|
||||
"content-type": "application/json",
|
||||
"authorization": f"Bearer {self.runtime.credentials['api_key']}",
|
||||
}
|
||||
|
||||
inputs = [{"type": "text", "text": tool_parameters.get("input-text")}]
|
||||
model = tool_parameters.get("model", "Security-semantic-filtering")
|
||||
payload = {"model": model, "input": inputs}
|
||||
url = "https://ai.gitee.com/v1/moderations"
|
||||
response = requests.post(url, json=payload, headers=headers)
|
||||
if response.status_code != 200:
|
||||
return self.create_text_message(f"Got Error Response:{response.text}")
|
||||
|
||||
return [self.create_text_message(response.content.decode("utf-8"))]
|
||||
@ -0,0 +1,32 @@
|
||||
identity:
|
||||
name: risk control
|
||||
author: gitee_ai
|
||||
label:
|
||||
en_US: risk control identification
|
||||
zh_Hans: 风控识别
|
||||
icon: icon.svg
|
||||
description:
|
||||
human:
|
||||
en_US: Ensuring the protection and compliance of sensitive information through the filtering and analysis of data semantics
|
||||
zh_Hans: 通过对数据语义的过滤和分析,确保敏感信息的保护和合规性
|
||||
llm: This tool is used to risk control identification.
|
||||
parameters:
|
||||
- name: model
|
||||
type: string
|
||||
required: true
|
||||
default: Security-semantic-filtering
|
||||
label:
|
||||
en_US: Service Model
|
||||
zh_Hans: 服务模型
|
||||
form: form
|
||||
- name: input-text
|
||||
type: string
|
||||
required: true
|
||||
label:
|
||||
en_US: Input Text
|
||||
zh_Hans: 输入文本
|
||||
human_description:
|
||||
en_US: The text input for filtering and analysis.
|
||||
zh_Hans: 用于分析过滤的文本
|
||||
llm_description: The text input for filtering and analysis.
|
||||
form: llm
|
||||
@ -0,0 +1,35 @@
|
||||
export async function writeTextToClipboard(text: string): Promise<void> {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText)
|
||||
return navigator.clipboard.writeText(text)
|
||||
|
||||
return fallbackCopyTextToClipboard(text)
|
||||
}
|
||||
|
||||
async function fallbackCopyTextToClipboard(text: string): Promise<void> {
|
||||
const textArea = document.createElement('textarea')
|
||||
textArea.value = text
|
||||
textArea.style.position = 'fixed' // Avoid scrolling to bottom
|
||||
document.body.appendChild(textArea)
|
||||
textArea.focus()
|
||||
textArea.select()
|
||||
try {
|
||||
const successful = document.execCommand('copy')
|
||||
if (successful)
|
||||
return Promise.resolve()
|
||||
|
||||
return Promise.reject(new Error('document.execCommand failed'))
|
||||
}
|
||||
catch (err) {
|
||||
return Promise.reject(convertAnyToError(err))
|
||||
}
|
||||
finally {
|
||||
document.body.removeChild(textArea)
|
||||
}
|
||||
}
|
||||
|
||||
function convertAnyToError(err: any): Error {
|
||||
if (err instanceof Error)
|
||||
return err
|
||||
|
||||
return new Error(`Caught: ${String(err)}`)
|
||||
}
|
||||
Loading…
Reference in New Issue