From f881ee955c75caad9d9f11ac37125e5bf7afd75c Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Fri, 23 Feb 2024 08:32:10 -0600 Subject: [PATCH] Update CLI argument parsing to use 'parseCLIArgs' --- bin/debug-answer-engine.ts | 4 ++-- bin/xbot.ts | 4 ++-- src/answer-engines/dexa-answer-engine.ts | 5 +++-- src/{cli-utils.ts => parse-cli-args.ts} | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) rename src/{cli-utils.ts => parse-cli-args.ts} (98%) diff --git a/bin/debug-answer-engine.ts b/bin/debug-answer-engine.ts index 99c0d78..19ea872 100644 --- a/bin/debug-answer-engine.ts +++ b/bin/debug-answer-engine.ts @@ -1,7 +1,7 @@ import type * as types from '../src/types.js' import { createAnswerEngine } from '../src/answer-engine-utils.js' -import { resolveCLIArgs } from '../src/cli-utils.js' import { openaiClient } from '../src/openai-client.js' +import { parseCLIArgs } from '../src/parse-cli-args.js' import { respondToNewMentions } from '../src/respond-to-new-mentions.js' import { getTwitterClient } from '../src/twitter-client.js' import { assert } from '../src/utils.js' @@ -14,7 +14,7 @@ import { assert } from '../src/utils.js' * ``` */ async function main() { - const argv = resolveCLIArgs({ + const argv = parseCLIArgs({ name: 'debug-answer-engine', forceReply: true }) diff --git a/bin/xbot.ts b/bin/xbot.ts index 271664e..2d90db3 100644 --- a/bin/xbot.ts +++ b/bin/xbot.ts @@ -3,8 +3,8 @@ import delay from 'delay' import * as db from '../src/db.js' import type * as types from '../src/types.js' import { createAnswerEngine } from '../src/answer-engine-utils.js' -import { resolveCLIArgs } from '../src/cli-utils.js' import { openaiClient } from '../src/openai-client.js' +import { parseCLIArgs } from '../src/parse-cli-args.js' import { respondToNewMentions } from '../src/respond-to-new-mentions.js' import { getTwitterClient } from '../src/twitter-client.js' import { maxTwitterId } from '../src/twitter-utils.js' @@ -16,7 +16,7 @@ import { maxTwitterId } from '../src/twitter-utils.js' * responses to twitter. */ async function main() { - const argv = resolveCLIArgs() + const argv = parseCLIArgs() const answerEngine = createAnswerEngine( argv.flags.answerEngine as types.AnswerEngineType ) diff --git a/src/answer-engines/dexa-answer-engine.ts b/src/answer-engines/dexa-answer-engine.ts index c48aace..8fcdc26 100644 --- a/src/answer-engines/dexa-answer-engine.ts +++ b/src/answer-engines/dexa-answer-engine.ts @@ -17,8 +17,9 @@ export class DexaAnswerEngine extends AnswerEngine { ): Promise { return this._dexaClient.generateResponse({ // TODO: Dexa API is throwing 500 if we pass entities - messages: query.answerEngineMessages.map(({ entities, ...msg }) => msg) - // entityMap: query.entityMap + // messages: query.answerEngineMessages.map(({ entities, ...msg }) => msg) + messages: query.answerEngineMessages, + entityMap: query.entityMap }) } } diff --git a/src/cli-utils.ts b/src/parse-cli-args.ts similarity index 98% rename from src/cli-utils.ts rename to src/parse-cli-args.ts index ab937d2..a2d3dbc 100644 --- a/src/cli-utils.ts +++ b/src/parse-cli-args.ts @@ -2,7 +2,7 @@ import { cli } from 'cleye' import * as config from './config.js' -export function resolveCLIArgs( +export function parseCLIArgs( overrides?: Record, argv: string[] = process.argv ) {