|
6 | 6 | import os |
7 | 7 | from collections.abc import Callable, Sequence |
8 | 8 | from pathlib import Path |
9 | | -from typing import TYPE_CHECKING, Any, Optional, Union |
| 9 | +from typing import TYPE_CHECKING, Any, Union |
10 | 10 |
|
11 | 11 | from autogen.agentchat.contrib.vectordb.base import VectorDBFactory |
12 | 12 | from autogen.agentchat.contrib.vectordb.mongodb import MongoDBAtlasVectorDB |
|
17 | 17 | from llama_index.core import SimpleDirectoryReader, StorageContext, VectorStoreIndex |
18 | 18 | from llama_index.core.embeddings import BaseEmbedding |
19 | 19 | from llama_index.core.schema import Document as LlamaDocument |
20 | | - from llama_index.llms.langchain.base import LLM |
21 | 20 | from llama_index.llms.openai import OpenAI |
22 | 21 | from llama_index.vector_stores.mongodb import MongoDBAtlasVectorSearch |
23 | 22 | from pymongo import MongoClient |
@@ -53,7 +52,7 @@ class MongoDBQueryEngine: |
53 | 52 | def __init__( # type: ignore[no-any-unimported] |
54 | 53 | self, |
55 | 54 | connection_string: str, |
56 | | - llm: Optional["LLM"] = None, |
| 55 | + llm: Any | None = None, # Changed from "LLM" to Any |
57 | 56 | database_name: str | None = None, |
58 | 57 | embedding_function: Union["BaseEmbedding", Callable[..., Any]] | None = None, # type: ignore[type-arg] |
59 | 58 | embedding_model: Union["BaseEmbedding", str] | None = None, |
@@ -81,7 +80,7 @@ def __init__( # type: ignore[no-any-unimported] |
81 | 80 | # ToDo: Is it okay if database_name is None? |
82 | 81 | self.database_name = database_name |
83 | 82 | self.collection_name = collection_name or DEFAULT_COLLECTION_NAME |
84 | | - self.llm: LLM = llm or OpenAI(model="gpt-4o", temperature=0.0) # type: ignore[no-any-unimported] |
| 83 | + self.llm: Any = llm or OpenAI(model="gpt-4o", temperature=0.0) # Changed from LLM to Any |
85 | 84 | self.embedding_model = embedding_model or "local:all-MiniLM-L6-v2" # type: ignore[no-any-unimported] |
86 | 85 |
|
87 | 86 | # encode is a method of SentenceTransformer, so we need to use a type ignore here. |
@@ -114,7 +113,7 @@ def _set_up(self, overwrite: bool) -> None: |
114 | 113 | logger.info("Vector database created.") |
115 | 114 | self.vector_search_engine = MongoDBAtlasVectorSearch( |
116 | 115 | mongodb_client=self.vector_db.client, # type: ignore[union-attr] |
117 | | - db_name=self.database_name, |
| 116 | + db_name=self.database_name or "default", # Provide default value if None |
118 | 117 | collection_name=self.collection_name, |
119 | 118 | ) |
120 | 119 | logger.info("Vector search engine created.") |
|
0 commit comments