-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from TarsLab/ollama
Add Ollama Vendor
- Loading branch information
Showing
9 changed files
with
78 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Ollama } from 'ollama' | ||
import { BaseOptions, Message, SendRequest, Vendor } from '.' | ||
|
||
const sendRequestFunc = (settings: BaseOptions): SendRequest => | ||
async function* (messages: Message[]) { | ||
const { parameters, ...optionsExcludingParams } = settings | ||
const options = { ...optionsExcludingParams, ...parameters } // 这样的设计,让parameters 可以覆盖掉前面的设置 optionsExcludingParams | ||
const { baseURL, model, ...remains } = options | ||
|
||
const ollama = new Ollama({ host: baseURL }) | ||
const response = await ollama.chat({ model, messages, stream: true, ...remains }) | ||
for await (const part of response) { | ||
yield part.message.content | ||
} | ||
} | ||
|
||
export const ollamaVendor: Vendor = { | ||
name: 'Ollama', | ||
defaultOptions: { | ||
apiKey: '', | ||
baseURL: 'http://127.0.0.1:11434', | ||
model: 'llama3.1', | ||
parameters: {} | ||
}, | ||
sendRequestFunc, | ||
models: [], | ||
websiteToObtainKey: 'https://ollama.com' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
"0.3.1": "1.5.8", | ||
"0.4.0": "1.5.8", | ||
"0.4.1": "1.5.8", | ||
"0.5.0": "1.5.8" | ||
"0.5.0": "1.5.8", | ||
"0.6.0": "1.5.8" | ||
} |