Remove getTime model function

it lead to higher usage of tokens.
This commit is contained in:
Wroclaw 2023-12-13 17:42:59 +01:00
parent 722862ded3
commit 02a5b0f7b9
2 changed files with 1 additions and 28 deletions

View file

@ -8,7 +8,6 @@ import IQuota from "./IQuota";
import MessageCount from "./quota/messageCount"; import MessageCount from "./quota/messageCount";
export interface IConfigRequired { export interface IConfigRequired {
readonly calendarParams: Intl.DateTimeFormatOptions;
/** Tokens to authentiate with */ /** Tokens to authentiate with */
readonly tokens: { readonly tokens: {
readonly Discord: string; readonly Discord: string;
@ -52,15 +51,6 @@ function envAsNumber(key: string): number | undefined {
} }
const defaultConfig: IConfigRequired = { const defaultConfig: IConfigRequired = {
calendarParams: {
weekday: "short",
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
hour12: false,
},
tokens: { tokens: {
Discord: envAsString("TOKENS__DISCORD") ?? "", Discord: envAsString("TOKENS__DISCORD") ?? "",
OpenAI: envAsString("TOKENS__OPENAI") ?? "", OpenAI: envAsString("TOKENS__OPENAI") ?? "",

View file

@ -1,7 +1,5 @@
import { ChatCompletionCreateParams, ChatCompletionMessage, ChatCompletionMessageParam } from "openai/resources/chat"; import { ChatCompletionCreateParams, ChatCompletionMessage, ChatCompletionMessageParam } from "openai/resources/chat";
import { config } from "./index";
type parameterMap = { type parameterMap = {
string: string, string: string,
number: number, number: number,
@ -53,7 +51,7 @@ export default class FunctionManager {
store = new Map<string, OpenAIFunction>(); store = new Map<string, OpenAIFunction>();
constructor() { constructor() {
this.store.set("getTime", new GetTime()); // TODO: import functions from functions directory
} }
public getFunctions(): ChatCompletionFunctions[] { public getFunctions(): ChatCompletionFunctions[] {
@ -95,18 +93,3 @@ export default class FunctionManager {
}; };
} }
} }
// buildins
class GetTime extends OpenAIFunction<Record<string, never>> {
name = "getTime";
description = "Gets current date and time with a timezone attached";
parameters = {
type: "object" as const,
properties: {} as Record<string, never>,
};
execute(): string {
return `${Intl.DateTimeFormat().resolvedOptions().timeZone}): ${new Date().toLocaleString("en-US", config.calendarParams)}`;
}
}