repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import logging |
| #2 | from typing import Optional |
| #3 | |
| #4 | from embedchain.config import BaseLlmConfig |
| #5 | from embedchain.helpers.json_serializable import register_deserializable |
| #6 | from embedchain.llm.base import BaseLlm |
| #7 | |
| #8 | logger = logging.getLogger(__name__) |
| #9 | |
| #10 | |
| #11 | @register_deserializable |
| #12 | class AzureOpenAILlm(BaseLlm): |
| #13 | def __init__(self, config: Optional[BaseLlmConfig] = None): |
| #14 | super().__init__(config=config) |
| #15 | |
| #16 | def get_llm_model_answer(self, prompt): |
| #17 | return self._get_answer(prompt=prompt, config=self.config) |
| #18 | |
| #19 | @staticmethod |
| #20 | def _get_answer(prompt: str, config: BaseLlmConfig) -> str: |
| #21 | from langchain_openai import AzureChatOpenAI |
| #22 | |
| #23 | if not config.deployment_name: |
| #24 | raise ValueError("Deployment name must be provided for Azure OpenAI") |
| #25 | |
| #26 | chat = AzureChatOpenAI( |
| #27 | deployment_name=config.deployment_name, |
| #28 | openai_api_version=str(config.api_version) if config.api_version else "2024-02-01", |
| #29 | model_name=config.model or "gpt-4o-mini", |
| #30 | temperature=config.temperature, |
| #31 | max_tokens=config.max_tokens, |
| #32 | streaming=config.stream, |
| #33 | http_client=config.http_client, |
| #34 | http_async_client=config.http_async_client, |
| #35 | ) |
| #36 | |
| #37 | if config.top_p and config.top_p != 1: |
| #38 | logger.warning("Config option `top_p` is not supported by this model.") |
| #39 | |
| #40 | messages = BaseLlm._get_messages(prompt, system_prompt=config.system_prompt) |
| #41 | |
| #42 | return chat.invoke(messages).content |
| #43 |