This commit is contained in:
2024-02-14 17:49:51 +01:00
parent 79d81b96b1
commit 0594458865
22 changed files with 223 additions and 124 deletions

View File

@@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
from ..BaseEngine import BaseEngine
import openai
class BaseLLMEngine(BaseEngine):
@abstractmethod
def generate(self, system_prompt: str, chat_prompt: str, max_tokens: int, temperature: float, top_p: float, frequency_penalty: float, presence_penalty: float) -> str:
pass

View File

@@ -0,0 +1,29 @@
import openai
import gradio as gr
from abc import ABC, abstractmethod
from .BaseLLMEngine import BaseLLMEngine
OPENAI_POSSIBLE_MODELS = [
"gpt-3.5-turbo-0125",
"gpt-4-turbo-preview",
]
class OpenaiLLMEngine(BaseLLMEngine):
num_options = 1
name = "OpenAI"
description = "OpenAI language model engine."
def generate(self, system_prompt: str, chat_prompt: str, max_tokens: int = 512, temperature: float = 1.0, json_mode: bool= False, top_p: float = 1, frequency_penalty: float = 0, presence_penalty: float = 0) -> str:
... # TODO: Implement this method
def get_options(self) -> list:
return [
gr.Dropdown(
label="Model",
choices=OPENAI_POSSIBLE_MODELS,
max_choices=1,
value=OPENAI_POSSIBLE_MODELS[0]
)
]

View File

@@ -0,0 +1 @@
from .BaseLLMEngine import BaseLLMEngine