File size: 1,246 Bytes
36bc547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import sys

# Add the project root to sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

from app.config import GEMINI_API_KEY, GEMINI_MODEL
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_core.messages import HumanMessage, SystemMessage

def test_debug():
    text = "Is the company 'DeepSeek' currently in the news for anything related to AI or data privacy? Could this be a scam related to them?"
    system = "Reply ONLY with valid JSON: {'risk_score': 0.0, 'threat_types': [], 'explanation': 'test'}"
    
    messages = [SystemMessage(content=system), HumanMessage(content=text)]
    tools = [{"googleSearch": {}}]
    
    llm = ChatGoogleGenerativeAI(model=GEMINI_MODEL, google_api_key=GEMINI_API_KEY, temperature=0.1)
    
    print("Invoking without tools...")
    resp_no_tools = llm.invoke(messages)
    print(f"Type: {type(resp_no_tools.content)}\nContent: {resp_no_tools.content}\n")
    
    print("Invoking with tools...")
    resp_with_tools = llm.invoke(messages, tools=tools)
    print(f"Type: {type(resp_with_tools.content)}\nContent: {resp_with_tools.content}\n")
    print(f"Response metadata: {resp_with_tools.response_metadata}")
    
test_debug()