mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 09:16:19 +00:00
👽 fix(OpenaiLLMEngine): Add newest gpt-4-turbo model
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import gradio as gr
|
import gradio as gr
|
||||||
import openai
|
import openai
|
||||||
|
import logging
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
import orjson
|
import orjson
|
||||||
|
|
||||||
@@ -8,6 +9,7 @@ from .BaseLLMEngine import BaseLLMEngine
|
|||||||
OPENAI_POSSIBLE_MODELS = [ # Theese shall be the openai models supporting force_json
|
OPENAI_POSSIBLE_MODELS = [ # Theese shall be the openai models supporting force_json
|
||||||
"gpt-3.5-turbo-0125",
|
"gpt-3.5-turbo-0125",
|
||||||
"gpt-4-turbo-preview",
|
"gpt-4-turbo-preview",
|
||||||
|
"gpt-4-turbo",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -35,6 +37,9 @@ class OpenaiLLMEngine(BaseLLMEngine):
|
|||||||
frequency_penalty: float = 0,
|
frequency_penalty: float = 0,
|
||||||
presence_penalty: float = 0,
|
presence_penalty: float = 0,
|
||||||
) -> str | dict:
|
) -> str | dict:
|
||||||
|
logging.info(
|
||||||
|
f"Generating with OpenAI model {self.model} and system prompt: \n{system_prompt} and chat prompt: \n{chat_prompt[0:100]}..."
|
||||||
|
)
|
||||||
response = self.client.chat.completions.create(
|
response = self.client.chat.completions.create(
|
||||||
model=self.model,
|
model=self.model,
|
||||||
messages=[
|
messages=[
|
||||||
@@ -46,9 +51,9 @@ class OpenaiLLMEngine(BaseLLMEngine):
|
|||||||
top_p=top_p,
|
top_p=top_p,
|
||||||
frequency_penalty=frequency_penalty,
|
frequency_penalty=frequency_penalty,
|
||||||
presence_penalty=presence_penalty,
|
presence_penalty=presence_penalty,
|
||||||
response_format={"type": "json_object"}
|
response_format=(
|
||||||
if json_mode
|
{"type": "json_object"} if json_mode else openai._types.NOT_GIVEN
|
||||||
else openai._types.NOT_GIVEN,
|
),
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
response.choices[0].message.content
|
response.choices[0].message.content
|
||||||
|
|||||||
Reference in New Issue
Block a user