-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_model.py
More file actions
40 lines (30 loc) · 1012 Bytes
/
Copy pathdebug_model.py
File metadata and controls
40 lines (30 loc) · 1012 Bytes
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
31
32
33
34
35
36
37
38
39
40
import os
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_core.messages import HumanMessage
from dotenv import load_dotenv
load_dotenv()
model_name = "gemini-3-flash-preview"
print(f"Testing model: {model_name}")
if not os.getenv("GOOGLE_API_KEY"):
print("Error: GOOGLE_API_KEY not found.")
exit(1)
llm = ChatGoogleGenerativeAI(model=model_name)
msg = HumanMessage(content="Hello, are you working?")
print("Invoking LLM without tools...")
try:
response = llm.invoke([msg])
print(f"Response: {response.content}")
except Exception as e:
print(f"Error without tools: {e}")
print("\nInvoking LLM WITH tools...")
from langchain_core.tools import tool
@tool
def dummy_tool(x: int):
"""dummy"""
return x + 1
llm_with_tools = llm.bind_tools([dummy_tool])
try:
response = llm_with_tools.invoke([msg])
print(f"Response with tools: {response.content}")
except Exception as e:
print(f"Error with tools: {e}")