3e99b37683
- Added base_url and model fields to HarnessConfig in json_types.hpp - Removed base_url and model from OllamaConfig in ollama_client.hpp - Updated OllamaClient constructor to accept base_url and model as separate parameters - Updated main.cpp to use HarnessConfig for base_url and model - Updated agent_tool.cpp to use new OllamaClient constructor - Added test_harness_config.sh to verify the new config fields - Updated README.md to document the config fields
62 lines
2.4 KiB
Bash
Executable File
62 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# test_harness_config.sh - Tests for HarnessConfig with base_url and model fields
|
|
|
|
# Test 1: Verify config is saved with base_url and model in new conversations
|
|
echo '{"choices":[{"delta":{"content":"Response","role":"assistant"},"finish_reason":"stop"}],"usage":{"completion_tokens":10,"prompt_tokens":5,"total_tokens":15}}' | "${DRHARNESS}" \
|
|
-F "${TEST_TEMP_DIR}/chat.json" \
|
|
-n \
|
|
-d \
|
|
-m "test" 2>/dev/null
|
|
|
|
# Verify config contains base_url and model
|
|
BASE_URL=$(cat "${TEST_TEMP_DIR}/chat.json" | jq -r '.config.base_url')
|
|
MODEL=$(cat "${TEST_TEMP_DIR}/chat.json" | jq -r '.config.model')
|
|
|
|
if [ -z "$BASE_URL" ] || [ "$BASE_URL" = "null" ]; then
|
|
echo "FAIL: Expected config.base_url to be set"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$MODEL" ] || [ "$MODEL" = "null" ]; then
|
|
echo "FAIL: Expected config.model to be set"
|
|
exit 1
|
|
fi
|
|
|
|
# Test 2: Verify -M flag sets model in config
|
|
echo '{"choices":[{"delta":{"content":"Response","role":"assistant"},"finish_reason":"stop"}],"usage":{"completion_tokens":10,"prompt_tokens":5,"total_tokens":15}}' | "${DRHARNESS}" \
|
|
-F "${TEST_TEMP_DIR}/chat2.json" \
|
|
-n \
|
|
-d \
|
|
-M "custom-model" \
|
|
-m "test" 2>/dev/null
|
|
|
|
MODEL2=$(cat "${TEST_TEMP_DIR}/chat2.json" | jq -r '.config.model')
|
|
if [ "$MODEL2" != "custom-model" ]; then
|
|
echo "FAIL: Expected config.model to be 'custom-model', got '${MODEL2}'"
|
|
exit 1
|
|
fi
|
|
|
|
# Test 3: Verify backward compatibility - loading file without base_url and model
|
|
echo '{"history":[{"role":"user","content":"hello"}],"tools":[],"config":{"max_tool_iterations":16,"verbose":false,"depth":0}}' > "${TEST_TEMP_DIR}/old_format.json"
|
|
|
|
echo '{"choices":[{"delta":{"content":"Response","role":"assistant"},"finish_reason":"stop"}],"usage":{"completion_tokens":10,"prompt_tokens":5,"total_tokens":15}}' | "${DRHARNESS}" \
|
|
-F "${TEST_TEMP_DIR}/old_format.json" \
|
|
-d \
|
|
-m "test" 2>/dev/null
|
|
|
|
# Verify the saved file now has base_url and model with defaults
|
|
SAVED_BASE_URL=$(cat "${TEST_TEMP_DIR}/old_format.json" | jq -r '.config.base_url')
|
|
SAVED_MODEL=$(cat "${TEST_TEMP_DIR}/old_format.json" | jq -r '.config.model')
|
|
|
|
if [ -z "$SAVED_BASE_URL" ] || [ "$SAVED_BASE_URL" = "null" ]; then
|
|
echo "FAIL: Expected saved config.base_url to be set"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$SAVED_MODEL" ] || [ "$SAVED_MODEL" = "null" ]; then
|
|
echo "FAIL: Expected saved config.model to be set"
|
|
exit 1
|
|
fi
|
|
|
|
echo "All harness config tests passed"
|