mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-13 12:06:06 -05:00
Dependencies and Readme Updates (#74)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user