mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-06 16:07:17 +08:00
add logic to random pick a llm config
This commit is contained in:
@@ -19,6 +19,23 @@ export const sendLookForwardReplyEmotion = async (page: Page) => {
|
|||||||
await lookForwardReplyEmojiProxy!.click()
|
await lookForwardReplyEmojiProxy!.click()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pickLlmConfigFromList = (llmConfigList) => {
|
||||||
|
if (llmConfigList.length === 1) {
|
||||||
|
return llmConfigList[0]
|
||||||
|
}
|
||||||
|
llmConfigList = llmConfigList.filter((it) => it.enabled)
|
||||||
|
const pool: number[] = []
|
||||||
|
for (let i = 0; i < llmConfigList.length; i++) {
|
||||||
|
for (let j = 0; j < Math.floor(llmConfigList[i].serveWeight); j++) {
|
||||||
|
pool.push(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const index = Math.floor(pool.length * Math.random())
|
||||||
|
return llmConfigList[
|
||||||
|
pool[index]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
// let _index = 0
|
// let _index = 0
|
||||||
|
|
||||||
export const sendGptContent = async (page: Page, chatRecords) => {
|
export const sendGptContent = async (page: Page, chatRecords) => {
|
||||||
@@ -86,7 +103,9 @@ export const sendGptContent = async (page: Page, chatRecords) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log(chatList)
|
console.log(chatList)
|
||||||
const llmConfig = await readConfigFile('llm.json')
|
const llmConfigList = await readConfigFile('llm.json')
|
||||||
|
const llmConfig = pickLlmConfigFromList(llmConfigList)
|
||||||
|
console.log(llmConfig.providerCompleteApiUrl)
|
||||||
const res = await completes(
|
const res = await completes(
|
||||||
{
|
{
|
||||||
baseURL: llmConfig.providerCompleteApiUrl,
|
baseURL: llmConfig.providerCompleteApiUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user