ai ollama backend
This commit is contained in:
parent
091a37cb57
commit
a7f89058b0
3 changed files with 34 additions and 5 deletions
12
app/backend/ai_api.ts
Normal file
12
app/backend/ai_api.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import ollama from 'ollama'
|
||||
|
||||
async function name(model: string, prompt: string, system: string,) {
|
||||
var message = [{ role: 'user', content: prompt }, { role: 'system', content: system }]
|
||||
var response = await ollama.chat({ model: model, messages: message, stream: true })
|
||||
for await (const part of response) {
|
||||
process.stdout.write(part.message.content)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue