Dependencies and Readme Updates (#74)

This commit is contained in:
Kevin Dang
2024-06-17 19:21:46 -07:00
committed by GitHub
parent 06638fec1f
commit 1041f4ca0b
11 changed files with 433 additions and 901 deletions

View File

@@ -26,7 +26,7 @@ export const MessageStream: SlashCommand = {
openConfig('config.json', interaction.commandName, interaction.options.get('stream')?.value)
interaction.reply({
content: `Message streaming preferences for embed set to: \`${interaction.options.get('stream')?.value}\``,
content: `Message streaming preferences set to: \`${interaction.options.get('stream')?.value}\``,
ephemeral: true
})
}

View File

@@ -2,6 +2,7 @@ import { EmbedBuilder, Message } from 'discord.js'
import { ChatResponse, Ollama } from 'ollama'
import { ChatParams, UserMessage, streamResponse, blockResponse } from './index.js'
import { Queue } from '../queues/queue.js'
import { AbortableAsyncIterator } from 'ollama/src/utils.js'
/**
* Method to send replies as normal text on discord like any other user
@@ -19,7 +20,7 @@ export async function embedMessage(
stream: boolean
): Promise<string> {
// bot response
let response: ChatResponse | AsyncGenerator<ChatResponse, any, unknown>
let response: ChatResponse | AbortableAsyncIterator<ChatResponse>
let result: string = ''
// initial message to client

View File

@@ -2,6 +2,7 @@ import { Message } from 'discord.js'
import { ChatResponse, Ollama } from 'ollama'
import { ChatParams, UserMessage, streamResponse, blockResponse } from './index.js'
import { Queue } from '../queues/queue.js'
import { AbortableAsyncIterator } from 'ollama/src/utils.js'
/**
* Method to send replies as normal text on discord like any other user
@@ -19,7 +20,7 @@ export async function normalMessage(
stream: boolean
): Promise<string> {
// bot's respnse
let response: ChatResponse | AsyncGenerator<ChatResponse, any, unknown>
let response: ChatResponse | AbortableAsyncIterator<ChatResponse>
let result: string = ''
await message.channel.send('Generating Response . . .').then(async sentMessage => {

View File

@@ -1,12 +1,13 @@
import { ChatResponse } from "ollama"
import { ChatParams } from "./index.js"
import { AbortableAsyncIterator } from "ollama/src/utils.js"
/**
* Method to query the Ollama client for async generation
* @param params
* @returns Asyn
*/
export async function streamResponse(params: ChatParams): Promise<AsyncGenerator<ChatResponse, any, unknown>> {
export async function streamResponse(params: ChatParams): Promise<AbortableAsyncIterator<ChatResponse>> {
return await params.ollama.chat({
model: params.model,
messages: params.msgHist,
@@ -16,7 +17,7 @@ export async function streamResponse(params: ChatParams): Promise<AsyncGenerator
top_k: 70
},
stream: true
})
}) as unknown as AbortableAsyncIterator<ChatResponse>
}
/**