| """ |
| Test script to verify Ollama integration. |
| """ |
| from components.llm_integration import CustomLLMResponder |
|
|
| def test_ollama(): |
| |
| print("Initializing LLM with Ollama...") |
| llm = CustomLLMResponder( |
| use_ollama=True, |
| ollama_model="llama2", |
| ollama_base_url="http://localhost:11434" |
| ) |
| |
| |
| test_prompt = """ |
| Analyze the following ethical dilemma from multiple perspectives: |
| |
| A self-driving car must choose between hitting a pedestrian crossing illegally or swerving and risking the passenger's life. |
| |
| Please provide a detailed ethical analysis considering different frameworks. |
| """ |
| |
| print("\nSending request to Ollama...") |
| |
| response = llm.generate(test_prompt, max_length=100, temperature=0.7) |
| |
| print("\nResponse from Ollama:") |
| print("-" * 80) |
| print(response) |
| print("-" * 80) |
|
|
| if __name__ == "__main__": |
| test_ollama() |
|
|