-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed all the typing errors. most of the actions had also a bad struc…
…tur or missing code from the action.ts
- Loading branch information
Showing
8 changed files
with
95 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
packages/plugin-openai/src/actions/moderateContentAction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
import type { Action } from "@elizaos/core"; | ||
import { validatePrompt, validateApiKey, callOpenAiApi } from "./action"; | ||
import { validatePrompt, validateApiKey, callOpenAiApi, buildRequestData } from "./action"; | ||
|
||
export const moderateContentAction: Action = { | ||
name: "moderateContent", | ||
description: "Moderate content using OpenAI", | ||
async handler(runtime, message, state) { | ||
const input = message.content.text?.trim() || ""; | ||
similes: [], | ||
async handler(_runtime, message, _state) { | ||
const input = (message.content.text as string)?.trim() || ""; | ||
validatePrompt(input); | ||
|
||
const apiKey = validateApiKey(); | ||
const requestData = { input }; | ||
const requestData = buildRequestData( | ||
"text-moderation-latest", | ||
input | ||
); | ||
|
||
const response = await callOpenAiApi( | ||
"https://api.openai.com/v1/moderations", | ||
requestData, | ||
apiKey, | ||
); | ||
) as { results: Array<{ flagged: boolean; categories: Record<string, boolean>; category_scores: Record<string, number> }> }; | ||
return response.results; | ||
}, | ||
validate: async (runtime, message) => { | ||
validate: async (runtime, _message) => { | ||
return !!runtime.getSetting("OPENAI_API_KEY"); | ||
}, | ||
examples: [], | ||
}; | ||
|
22 changes: 16 additions & 6 deletions
22
packages/plugin-openai/src/actions/transcribeAudioAction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters