Skip to content

Commit

Permalink
feat: more DocsLookup results and revert toLowerCase (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored May 25, 2023
1 parent 24add88 commit 3ab13b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@effect/io": "^0.25.13",
"@effect/schema": "^0.19.3",
"@effect/stream": "^0.21.1",
"dfx": "^0.45.9",
"dfx": "^0.45.10",
"dotenv": "^16.0.3",
"effect-schema-class": "^0.2.4",
"openai": "^3.2.1"
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/DocsLookup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Discord, Ix } from "dfx"
import { Discord, Ix, Log } from "dfx"
import {
Cause,
Data,
Duration,
Effect,
Expand Down Expand Up @@ -73,7 +74,7 @@ class DocEntry extends SchemaClass({
)
}

return terms.map(_ => _.toLowerCase())
return terms
}
}

Expand All @@ -88,6 +89,7 @@ const retryPolicy = Schedule.fixed(Duration.seconds(3))

const make = Effect.gen(function* (_) {
const registry = yield* _(InteractionsRegistry)
const log = yield* _(Log.Log)

const buildDocs = (baseUrl: string) =>
Effect.gen(function* (_) {
Expand Down Expand Up @@ -180,13 +182,13 @@ ${entry.url}`,
_ => _.length >= 3,
_ => Effect.fail(new QueryTooShort({ actual: _.length, min: 3 })),
),
Effect.flatMap(_ => search(_.trim().toLowerCase())),
Effect.flatMap(search),
Effect.map(results =>
Ix.response({
type: Discord.InteractionCallbackType
.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT,
data: {
choices: results.slice(0, 15).map(
choices: results.slice(0, 25).map(
([{ entry }, index]): Discord.ApplicationCommandOptionChoice => ({
name: `${entry.signature} (${entry.package})`,
value: index.toString(),
Expand Down

0 comments on commit 3ab13b1

Please sign in to comment.