-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refactoring-backend-muggtschibidi' into 'main'
Backend refactoren See merge request kicc/mucgpt!13
- Loading branch information
Showing
21 changed files
with
405 additions
and
340 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,46 +1,55 @@ | ||
|
||
|
||
from typing import Callable | ||
from langchain_openai import AzureChatOpenAI | ||
from langchain_core.language_models.chat_models import BaseChatModel | ||
from langchain.callbacks.streaming_aiter import AsyncIteratorCallbackHandler | ||
|
||
def getAzureChatGPT(chatgpt_model: str, | ||
max_tokens: int, | ||
n: int, | ||
openai_api_key: str, | ||
openai_api_base: str, | ||
openai_api_version: str, | ||
openai_api_type: str, | ||
temperature: float) -> BaseChatModel: | ||
return AzureChatOpenAI( | ||
model=chatgpt_model, | ||
max_tokens=max_tokens, | ||
n=n, | ||
deployment_name= "chat", | ||
openai_api_key=openai_api_key, | ||
azure_endpoint=openai_api_base, | ||
openai_api_version=openai_api_version, | ||
openai_api_type=openai_api_type, | ||
temperature=temperature | ||
) | ||
from langchain_core.runnables import ConfigurableField | ||
from langchain_community.llms.fake import FakeListLLM | ||
from langchain_core.runnables.base import RunnableSerializable | ||
from core.types.SupportedModels import SupportedModels | ||
|
||
def createAzureChatGPT(chatgpt_model: str, | ||
n: int, | ||
openai_api_key: str, | ||
openai_api_base: str, | ||
openai_api_version: str, | ||
openai_api_type: str,) -> Callable[[AsyncIteratorCallbackHandler], BaseChatModel]: | ||
return lambda max_tokens, temperature, callback : AzureChatOpenAI( | ||
model=chatgpt_model, | ||
def getModel(chatgpt_model: str, | ||
max_tokens: int, | ||
n: int, | ||
api_key: str, | ||
api_base: str, | ||
api_version: str, | ||
api_type: str, | ||
temperature: float, | ||
streaming: bool) -> RunnableSerializable: | ||
llm = AzureChatOpenAI( | ||
model=chatgpt_model, | ||
max_tokens=max_tokens, | ||
n=n, | ||
deployment_name= "chat", | ||
openai_api_key=openai_api_key, | ||
azure_endpoint=openai_api_base, | ||
openai_api_version=openai_api_version, | ||
openai_api_type=openai_api_type, | ||
openai_api_key=api_key, | ||
azure_endpoint=api_base, | ||
openai_api_version=api_version, | ||
openai_api_type=api_type, | ||
temperature=temperature, | ||
streaming=True, | ||
callbacks=[callback] | ||
) | ||
streaming=streaming, | ||
).configurable_fields( | ||
temperature=ConfigurableField( | ||
id="llm_temperature", | ||
name="LLM Temperature", | ||
description="The temperature of the LLM", | ||
), | ||
max_tokens= ConfigurableField( | ||
id="llm_max_tokens", | ||
name="LLM max Tokens", | ||
description="The token Limit of the LLM", | ||
), | ||
openai_api_key = ConfigurableField( | ||
id="llm_api_key", | ||
name="The api key", | ||
description="The api key"), | ||
streaming = ConfigurableField( | ||
id="llm_streaming", | ||
name="Streaming", | ||
description="Should the LLM Stream"), | ||
callbacks = ConfigurableField( | ||
id="llm_callbacks", | ||
name="Callbacks", | ||
description="Callbacks for the llm") | ||
|
||
).configurable_alternatives( | ||
ConfigurableField(id="llm"), | ||
default_key=SupportedModels.AZURE_CHATGPT.value, | ||
fake= FakeListLLM(responses=["Hi diggi"])) | ||
return llm |
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
Oops, something went wrong.