From 96e88f2928f1a1344cb5528ed31e47b5661d1d77 Mon Sep 17 00:00:00 2001 From: rcholic Date: Wed, 24 Dec 2025 04:44:55 -0800 Subject: [PATCH 1/2] Agent abstraction Phase 1: --- examples/test_local_llm_agent.py | 86 ++++++ sentience/__init__.py | 14 +- sentience/agent.py | 355 ++++++++++++++++++++++++ sentience/llm_provider.py | 452 +++++++++++++++++++++++++++++++ tests/test_agent.py | 414 ++++++++++++++++++++++++++++ 5 files changed, 1320 insertions(+), 1 deletion(-) create mode 100644 examples/test_local_llm_agent.py create mode 100644 sentience/agent.py create mode 100644 sentience/llm_provider.py create mode 100644 tests/test_agent.py diff --git a/examples/test_local_llm_agent.py b/examples/test_local_llm_agent.py new file mode 100644 index 0000000..f2a5c1b --- /dev/null +++ b/examples/test_local_llm_agent.py @@ -0,0 +1,86 @@ +""" +Test script for LocalLLMProvider with Qwen2.5-3B-Instruct +Demonstrates using a local LLM with SentienceAgent +""" + +from sentience.llm_provider import LocalLLMProvider + +def test_local_llm_basic(): + """Test basic LLM response generation""" + print("="*70) + print("Testing LocalLLMProvider with Qwen2.5-3B-Instruct") + print("="*70) + + # Initialize local LLM + # Using the model from your local cache + llm = LocalLLMProvider( + model_name="Qwen/Qwen2.5-3B-Instruct", + device="auto", # Will use CUDA if available, else CPU + load_in_4bit=False, # Set to True to save memory + torch_dtype="auto" + ) + + print("\n" + "="*70) + print("Test 1: Simple question") + print("="*70) + + response = llm.generate( + system_prompt="You are a helpful web automation assistant.", + user_prompt="What is 2+2?", + max_new_tokens=50, + temperature=0.1 + ) + + print(f"Response: {response.content}") + print(f"Tokens: {response.total_tokens} (prompt: {response.prompt_tokens}, completion: {response.completion_tokens})") + + print("\n" + "="*70) + print("Test 2: Action parsing (for agent)") + print("="*70) + + system_prompt = """You are an AI web automation agent. + +GOAL: Click the search box + +VISIBLE ELEMENTS (sorted by importance, max 50): +[1]