ira/test_llm_interface.py

48 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Test script for the LLM interface with Groq.
This script tests the LLM interface with Groq models.
"""
import os
import time
from query.llm_interface import LLMInterface
def test_groq_model():
"""Test the Groq model."""
# Ask for the API key
api_key = input("Enter your Groq API key: ")
os.environ["GROQ_API_KEY"] = api_key
# Initialize the LLM interface with the Groq model
llm = LLMInterface(model_name="llama-3.1-8b-instant")
# Test queries
test_queries = [
"What are the latest advancements in quantum computing?",
"Compare renewable energy sources and their efficiency",
"Explain the impact of artificial intelligence on healthcare"
]
# Process each query
for query in test_queries:
print(f"\nProcessing query: '{query}'")
print("-" * 50)
start_time = time.time()
response = llm._enhance_query_impl(query)
end_time = time.time()
print(f"Processing time: {end_time - start_time:.2f} seconds")
print("\nEnhanced Query:")
print("-" * 50)
print(response)
print("-" * 50)
# Wait a bit between queries
time.sleep(1)
if __name__ == "__main__":
test_groq_model()