Spaces:
Sleeping
Sleeping
add gemini refferences
Browse files- src/agents/gemini_chatbot.py +15 -5
src/agents/gemini_chatbot.py
CHANGED
|
@@ -17,8 +17,11 @@ from langgraph.graph import StateGraph, END
|
|
| 17 |
from langchain_core.prompts import ChatPromptTemplate
|
| 18 |
from langchain_core.messages import HumanMessage, AIMessage, SystemMessage
|
| 19 |
|
| 20 |
-
from src.
|
|
|
|
| 21 |
from src.config.paths import CONVERSATIONS_DIR
|
|
|
|
|
|
|
| 22 |
|
| 23 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 24 |
logger = logging.getLogger(__name__)
|
|
@@ -42,9 +45,18 @@ class GeminiState(TypedDict):
|
|
| 42 |
class GeminiRAGChatbot:
|
| 43 |
"""Gemini File Search RAG chatbot (Beta version)"""
|
| 44 |
|
| 45 |
-
def __init__(self):
|
| 46 |
"""Initialize the Gemini chatbot"""
|
|
|
|
| 47 |
logger.info("🤖 INITIALIZING: Gemini File Search Chatbot (Beta)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Initialize Gemini File Search client
|
| 50 |
try:
|
|
@@ -151,8 +163,7 @@ class GeminiRAGChatbot:
|
|
| 151 |
|
| 152 |
# Use LLM to intelligently add document references and format nicely
|
| 153 |
try:
|
| 154 |
-
|
| 155 |
-
llm = get_llm_client()
|
| 156 |
|
| 157 |
# Prepare document summaries for the LLM
|
| 158 |
doc_summaries = []
|
|
@@ -389,4 +400,3 @@ Return ONLY the enhanced, well-formatted response with references added and any
|
|
| 389 |
def get_gemini_chatbot():
|
| 390 |
"""Get Gemini chatbot instance"""
|
| 391 |
return GeminiRAGChatbot()
|
| 392 |
-
|
|
|
|
| 17 |
from langchain_core.prompts import ChatPromptTemplate
|
| 18 |
from langchain_core.messages import HumanMessage, AIMessage, SystemMessage
|
| 19 |
|
| 20 |
+
from src.config.loader import load_config
|
| 21 |
+
from src.llm.adapters import get_llm_client
|
| 22 |
from src.config.paths import CONVERSATIONS_DIR
|
| 23 |
+
from src.gemini.file_search import GeminiFileSearchClient, GeminiFileSearchResult
|
| 24 |
+
|
| 25 |
|
| 26 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 27 |
logger = logging.getLogger(__name__)
|
|
|
|
| 45 |
class GeminiRAGChatbot:
|
| 46 |
"""Gemini File Search RAG chatbot (Beta version)"""
|
| 47 |
|
| 48 |
+
def __init__(self, config_path: str = "src/config/settings.yaml"):
|
| 49 |
"""Initialize the Gemini chatbot"""
|
| 50 |
+
|
| 51 |
logger.info("🤖 INITIALIZING: Gemini File Search Chatbot (Beta)")
|
| 52 |
+
self.config = load_config(config_path)
|
| 53 |
+
|
| 54 |
+
# Get LLM provider from config
|
| 55 |
+
reader_config = self.config.get("reader", {})
|
| 56 |
+
default_type = reader_config.get("default_type", "INF_PROVIDERS")
|
| 57 |
+
provider_name = default_type.lower()
|
| 58 |
+
|
| 59 |
+
self.llm_adapter = get_llm_client(provider_name, self.config)
|
| 60 |
|
| 61 |
# Initialize Gemini File Search client
|
| 62 |
try:
|
|
|
|
| 163 |
|
| 164 |
# Use LLM to intelligently add document references and format nicely
|
| 165 |
try:
|
| 166 |
+
llm = self.llm_adapter
|
|
|
|
| 167 |
|
| 168 |
# Prepare document summaries for the LLM
|
| 169 |
doc_summaries = []
|
|
|
|
| 400 |
def get_gemini_chatbot():
|
| 401 |
"""Get Gemini chatbot instance"""
|
| 402 |
return GeminiRAGChatbot()
|
|
|