-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
163 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from singleton import Singleton | ||
from common.singleton import Singleton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from message import IrisMessage | ||
from domain.message import IrisMessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from generation_arguments import CompletionArguments | ||
from request_handler_interface import RequestHandlerInterface | ||
from basic_request_handler import BasicRequestHandler, BasicRequestHandlerModel | ||
from llm_manager import LlmManager | ||
from llm.generation_arguments import CompletionArguments | ||
from llm.request_handler_interface import RequestHandlerInterface | ||
from llm.llm_manager import LlmManager | ||
from llm.basic_request_handler import BasicRequestHandler, BasicRequestHandlerModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from llm_wrapper_interface import * | ||
from open_ai_chat_wrapper import * | ||
from ollama_wrapper import OllamaWrapper | ||
from llm.wrapper.llm_wrapper_interface import * | ||
from llm.wrapper.open_ai_chat_wrapper import * | ||
from llm.wrapper.ollama_wrapper import OllamaWrapper |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from openai import OpenAI | ||
from openai.lib.azure import AzureOpenAI | ||
|
||
from llm import CompletionArguments | ||
from llm.wrapper import LlmCompletionWrapperInterface | ||
|
||
|
||
class OpenAICompletionWrapper(LlmCompletionWrapperInterface): | ||
|
||
def __init__(self, model: str, api_key: str): | ||
self.client = OpenAI(api_key=api_key) | ||
self.model = model | ||
|
||
def __init__(self, client, model: str): | ||
self.client = client | ||
self.model = model | ||
|
||
def completion(self, prompt: str, arguments: CompletionArguments) -> any: | ||
response = self.client.completions.create( | ||
model=self.model, | ||
prompt=prompt, | ||
temperature=arguments.temperature, | ||
max_tokens=arguments.max_tokens, | ||
stop=arguments.stop, | ||
) | ||
return response | ||
|
||
def __str__(self): | ||
return f"OpenAICompletion('{self.model}')" | ||
|
||
|
||
class AzureCompletionWrapper(OpenAICompletionWrapper): | ||
|
||
def __init__( | ||
self, | ||
model: str, | ||
endpoint: str, | ||
azure_deployment: str, | ||
api_version: str, | ||
api_key: str, | ||
): | ||
client = AzureOpenAI( | ||
azure_endpoint=endpoint, | ||
azure_deployment=azure_deployment, | ||
api_version=api_version, | ||
api_key=api_key, | ||
) | ||
model = model | ||
super().__init__(client, model) | ||
|
||
def __str__(self): | ||
return f"AzureCompletion('{self.model}')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from openai import OpenAI | ||
from openai.lib.azure import AzureOpenAI | ||
|
||
from llm.wrapper import ( | ||
LlmEmbeddingWrapperInterface, | ||
) | ||
|
||
|
||
class OpenAIEmbeddingWrapper(LlmEmbeddingWrapperInterface): | ||
|
||
def __init__(self, model: str, api_key: str): | ||
self.client = OpenAI(api_key=api_key) | ||
self.model = model | ||
|
||
def __init__(self, client, model: str): | ||
self.client = client | ||
self.model = model | ||
|
||
def create_embedding(self, text: str) -> list[float]: | ||
response = self.client.embeddings.create( | ||
model=self.model, | ||
input=text, | ||
encoding_format="float", | ||
) | ||
return response.data[0].embedding | ||
|
||
def __str__(self): | ||
return f"OpenAIEmbedding('{self.model}')" | ||
|
||
|
||
class AzureEmbeddingWrapper(OpenAIEmbeddingWrapper): | ||
|
||
def __init__( | ||
self, | ||
model: str, | ||
endpoint: str, | ||
azure_deployment: str, | ||
api_version: str, | ||
api_key: str, | ||
): | ||
client = AzureOpenAI( | ||
azure_endpoint=endpoint, | ||
azure_deployment=azure_deployment, | ||
api_version=api_version, | ||
api_key=api_key, | ||
) | ||
model = model | ||
super().__init__(client, model) | ||
|
||
def __str__(self): | ||
return f"AzureEmbedding('{self.model}')" |