Download backend/test_smart_jarvis.py from Paritosh-Sovereign/Friday-Subconscious: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/spaces/Paritosh-Sovereign/Friday-Subconscious/resolve/main/backend/test_smart_jarvis.py
- Command line
-
hf download hf://spaces/Paritosh-Sovereign/Friday-Subconscious/backend/test_smart_jarvis.py
-
curl -L -o test_smart_jarvis.py https://huggingface.co/spaces/Paritosh-Sovereign/Friday-Subconscious/resolve/main/backend/test_smart_jarvis.py
2.11 kB
| import sys | |
| import os | |
| # Add backend to path | |
| sys.path.append(os.path.join(os.getcwd(), "backend")) | |
| from app.services import llm | |
| from config import settings | |
| def list_registered_tools(): | |
| # Bypass registry import for isolated LLM test | |
| print("\n--- Registered Tools (Registry bypass for LLM test) ---") | |
| print(" [Skipping registry load to avoid dependency errors]") | |
| print("\n--- Testing JARVIS Multi-Step Reasoning ---") | |
| # Initialize LLM (Mock/Real) | |
| # Note: This requires .env to be set up correctly for OpenAI or Ollama to be running. | |
| # We will just verify if the loop runs without crashing and logs steps. | |
| messages = [ | |
| {"role": "user", "content": "Jarvis, what's the current time and what application am I using right now?"} | |
| ] | |
| print("User: " + messages[0]["content"]) | |
| try: | |
| response = llm.chat(messages, use_tools=True) | |
| print("\nJARVIS: " + response) | |
| except Exception as e: | |
| print(f"Error during agent test: {e}") | |
| def list_registered_tools(): | |
| print("\n--- Registered Tools ---") | |
| tools = registry.get_all_tools_schema() | |
| for t in tools: | |
| print(f" - {t['function']['name']}: {t['function'].get('description')}") | |
| def test_groq_connection(): | |
| print("\n--- Testing Groq (Free Cloud) connection ---") | |
| try: | |
| from app.services import llm | |
| from app.config import settings | |
| # Re-init with new settings | |
| llm.init( | |
| openai_api_key=settings.openai_api_key, | |
| openai_model=settings.openai_model, | |
| openai_base_url=settings.openai_base_url, | |
| use_cloud=True | |
| ) | |
| messages = [{"role": "user", "content": "Say 'Groq is active' if you can hear me."}] | |
| print(f"Base URL: {settings.openai_base_url}") | |
| print(f"Model: {settings.openai_model}") | |
| response = llm.chat(messages, use_tools=False) | |
| print(f"Response: {response}") | |
| except Exception as e: | |
| print(f"Connection failed: {e}") | |
| if __name__ == "__main__": | |
| list_registered_tools() | |
| test_groq_connection() | |