Download test_debug.py from broskiiii/test: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/broskiiii/test/resolve/main/test_debug.py
- Command line
-
hf download hf://spaces/broskiiii/test/test_debug.py
-
curl -L -o test_debug.py https://huggingface.co/spaces/broskiiii/test/resolve/main/test_debug.py
1.25 kB
| 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() | |