added strict format to o1

This commit is contained in:
MaxRobinsonTheGreat 2024-10-06 22:54:51 -05:00
parent f3961c6086
commit 2e84595772
2 changed files with 3 additions and 13 deletions

View file

@ -35,8 +35,6 @@ export class Prompter {
chat.api = 'anthropic'; chat.api = 'anthropic';
else if (chat.model.includes('meta/') || chat.model.includes('mistralai/') || chat.model.includes('replicate/')) else if (chat.model.includes('meta/') || chat.model.includes('mistralai/') || chat.model.includes('replicate/'))
chat.api = 'replicate'; chat.api = 'replicate';
// OH GOD GROQ HAS A LOT MORE MODELS NOW WHERE DID THEY ALL COME FROM
// i literally need to use a "groq/" thing because theres so many
else if (chat.model.includes("groq/") || chat.model.includes("groqcloud/")) else if (chat.model.includes("groq/") || chat.model.includes("groqcloud/"))
chat.api = 'groq'; chat.api = 'groq';
else else

View file

@ -1,5 +1,6 @@
import OpenAIApi from 'openai'; import OpenAIApi from 'openai';
import { getKey, hasKey } from '../utils/keys.js'; import { getKey, hasKey } from '../utils/keys.js';
import { strictFormat } from '../utils/text.js';
export class GPT { export class GPT {
constructor(model_name, url) { constructor(model_name, url) {
@ -18,26 +19,17 @@ export class GPT {
} }
async sendRequest(turns, systemMessage, stop_seq='***') { async sendRequest(turns, systemMessage, stop_seq='***') {
let messages = [{'role': 'system', 'content': systemMessage}].concat(turns); let messages = [{'role': 'system', 'content': systemMessage}].concat(turns);
const pack = { const pack = {
model: this.model_name || "gpt-3.5-turbo", model: this.model_name || "gpt-3.5-turbo",
messages,
stop: stop_seq, stop: stop_seq,
}; };
if (this.model_name.includes('o1')) { if (this.model_name.includes('o1')) {
// system role and stop_seq not supported by o1 models pack.messages = strictFormat(messages);
messages = messages.map((msg) => {
if (msg.role == 'system') {
msg.role = 'user';
msg.content = 'SYSTEM: ' + msg.content;
}
return msg;
});
delete pack.stop; delete pack.stop;
} }
pack.messages = messages;
let res = null; let res = null;
try { try {