|
| 1 | +import enum |
| 2 | +from typing import Optional, Dict, Any |
| 3 | + |
| 4 | +import ravendb.serverwide.server_operation_executor |
| 5 | +from ravendb.documents.operations.ai.azure_open_ai_settings import AzureOpenAiSettings |
| 6 | +from ravendb.documents.operations.ai.embedded_settings import EmbeddedSettings |
| 7 | +from ravendb.documents.operations.ai.google_settings import GoogleSettings |
| 8 | +from ravendb.documents.operations.ai.hugging_face_settings import HuggingFaceSettings |
| 9 | +from ravendb.documents.operations.ai.mistral_ai_settings import MistralAiSettings |
| 10 | +from ravendb.documents.operations.ai.ollama_settings import OllamaSettings |
| 11 | +from ravendb.documents.operations.ai.open_ai_settings import OpenAiSettings |
| 12 | +from ravendb.documents.operations.connection_strings import ConnectionString |
| 13 | + |
| 14 | + |
| 15 | +class AiModelType(enum.Enum): |
| 16 | + TEXT_EMBEDDINGS = "TextEmbeddings", |
| 17 | + CHAT = "Chat" |
| 18 | + |
| 19 | + |
| 20 | +class AiConnectionString(ConnectionString): # todo kuba |
| 21 | + def __init__( |
| 22 | + self, |
| 23 | + name: str, |
| 24 | + identifier: str, |
| 25 | + openai_settings: Optional[OpenAiSettings] = None, |
| 26 | + azure_openai_settings: Optional[AzureOpenAiSettings] = None, |
| 27 | + ollama_settings: Optional[OllamaSettings] = None, |
| 28 | + embedded_settings: Optional[EmbeddedSettings] = None, |
| 29 | + google_settings: Optional[GoogleSettings] = None, |
| 30 | + huggingface_settings: Optional[HuggingFaceSettings] = None, |
| 31 | + mistral_ai_settings: Optional[MistralAiSettings] = None, |
| 32 | + model_type: AiModelType = None |
| 33 | + ): |
| 34 | + super().__init__(name) |
| 35 | + self.identifier = identifier |
| 36 | + self.openai_settings = openai_settings |
| 37 | + self.azure_openai_settings = azure_openai_settings |
| 38 | + self.ollama_settings = ollama_settings |
| 39 | + self.embedded_settings = embedded_settings |
| 40 | + self.google_settings = google_settings |
| 41 | + self.huggingface_settings = huggingface_settings |
| 42 | + self.mistral_ai_settings = mistral_ai_settings |
| 43 | + self.model_type = model_type |
| 44 | + |
| 45 | + @property |
| 46 | + def get_type(self): |
| 47 | + return ravendb.serverwide.server_operation_executor.ConnectionStringType.AI.value |
| 48 | + |
| 49 | + def to_json(self) -> Dict[str, Any]: |
| 50 | + return { |
| 51 | + "Name": self.name, |
| 52 | + "Identifier": self.identifier, |
| 53 | + "OpenaiSettings": self.openai_settings, |
| 54 | + "AzureOpenaiSettings": self.azure_openai_settings, |
| 55 | + "ollama_settings": self.ollama_settings, |
| 56 | + "EmbeddedSettings": self.embedded_settings, |
| 57 | + "GoogleSettings": self.google_settings, |
| 58 | + "HuggingfaceSettings": self.huggingface_settings, |
| 59 | + "MistralAiSettings": self.mistral_ai_settings, |
| 60 | + "ModelType": self.model_type, |
| 61 | + "Type": ravendb.serverwide.server_operation_executor.ConnectionStringType.OLAP, |
| 62 | + } |
0 commit comments