Merge branch 'v2' into v2

This commit is contained in:
ycxom 2025-02-03 23:11:11 +08:00 committed by GitHub
commit 7ab7e00ed3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 561 additions and 678 deletions

View file

@ -117,26 +117,26 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient {
async sendMessage(text, opt = {}) {
let history = await this.getHistory(opt.parentMessageId)
let systemMessage = opt.system
if (systemMessage) {
history = history.reverse()
history.push({
role: 'model',
parts: [
{
text: 'ok'
}
]
})
history.push({
role: 'user',
parts: [
{
text: systemMessage
}
]
})
history = history.reverse()
}
// if (systemMessage) {
// history = history.reverse()
// history.push({
// role: 'model',
// parts: [
// {
// text: 'ok'
// }
// ]
// })
// history.push({
// role: 'user',
// parts: [
// {
// text: systemMessage
// }
// ]
// })
// history = history.reverse()
// }
const idThis = crypto.randomUUID()
const idModel = crypto.randomUUID()
const thisMessage = opt.functionResponse
@ -184,6 +184,11 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient {
* @type Array<Content>
*/
contents: history,
system_instruction: {
parts: {
text: systemMessage
}
},
safetySettings: [
{
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,