Integrate OpenWebUI bot with AI service

This commit is contained in:
Iyeoluwa Akinrinola
2025-05-20 02:18:46 +01:00
parent 730009ae87
commit 0a27103875
46 changed files with 1749 additions and 3012 deletions
+2 -53
View File
@@ -34,61 +34,10 @@ if pgrep -f "run_ai_service.py" > /dev/null; then
echo "Check ai_service.log for output"
echo "To stop the service, run: pkill -f \"run_ai_service.py\""
# Test the health endpoint
echo -e "\nTesting health endpoint..."
# Check the health endpoint
echo -e "\nChecking health endpoint..."
curl -s http://localhost:5252/health
echo -e "\n"
# Test creating a chat and sending a message
echo "Testing chat creation and message sending..."
if [ -f "$PYTHON_PATH" ]; then
# Create a simple test script
cat > test_api.py << 'EOF'
import requests
import json
# Create a chat
response = requests.post(
"http://localhost:5252/chats",
json={
"user_id": "test_user",
"title": "Test Chat",
"model_id": "llama3.1"
}
)
if response.status_code == 200:
chat_id = response.json()["id"]
print(f"Chat created with ID: {chat_id}")
# Send a message with parameters
response = requests.post(
f"http://localhost:5252/chats/{chat_id}/messages",
json={
"message": "Hello, AI!",
"user_id": "test_user",
"temperature": 0.7,
"max_tokens": 100
}
)
if response.status_code == 200:
print("Message sent successfully")
print(f"Response: {response.json()['content'][:100]}...")
else:
print(f"Error sending message: {response.status_code}")
print(response.text)
else:
print(f"Error creating chat: {response.status_code}")
print(response.text)
EOF
# Run the test script with the virtual environment's Python
$PYTHON_PATH test_api.py
rm test_api.py
else
echo "Skipping API test as virtual environment Python is not available"
fi
else
echo "Failed to start AI Service. Check ai_service.log for errors."
exit 1