mirror of
https://github.com/nenadilic84/claudex.git
synced 2025-10-28 00:02:05 -07:00
Add setup.py for pip installation compatibility and example scripts
This commit is contained in:
parent
12e39cf7c9
commit
b55cd15de2
39
scripts/check_health.py
Executable file
39
scripts/check_health.py
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import unittest.mock
|
||||||
|
import requests
|
||||||
|
|
||||||
|
# Mock environment variables to allow proxy to initialize
|
||||||
|
with unittest.mock.patch.dict(os.environ, {
|
||||||
|
'TARGET_API_BASE': 'https://api.example.com',
|
||||||
|
'TARGET_API_KEY': 'mock-api-key',
|
||||||
|
'BIG_MODEL_TARGET': 'model-large',
|
||||||
|
'SMALL_MODEL_TARGET': 'model-small'
|
||||||
|
}):
|
||||||
|
# Import claudex with mocked environment
|
||||||
|
import uvicorn
|
||||||
|
import claudex.proxy
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Start server in the background
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
server_thread = threading.Thread(
|
||||||
|
target=uvicorn.run,
|
||||||
|
args=("claudex.proxy:app",),
|
||||||
|
kwargs={"host": "127.0.0.1", "port": 8082, "log_level": "error"},
|
||||||
|
daemon=True
|
||||||
|
)
|
||||||
|
server_thread.start()
|
||||||
|
|
||||||
|
# Wait for server to start
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# Check health endpoint
|
||||||
|
try:
|
||||||
|
response = requests.get("http://127.0.0.1:8082/")
|
||||||
|
print(f"Status code: {response.status_code}")
|
||||||
|
print(f"Response: {response.json()}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
22
scripts/run_proxy.py
Normal file
22
scripts/run_proxy.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Get directory containing this script
|
||||||
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
# Get project root directory (parent of script directory)
|
||||||
|
project_dir = os.path.abspath(os.path.join(script_dir, ".."))
|
||||||
|
# Add project directory to path to ensure module can be found
|
||||||
|
sys.path.insert(0, project_dir)
|
||||||
|
|
||||||
|
# Set environment variables for testing
|
||||||
|
os.environ.setdefault("TARGET_API_BASE", "https://api.example.com")
|
||||||
|
os.environ.setdefault("TARGET_API_KEY", "mock-api-key")
|
||||||
|
os.environ.setdefault("BIG_MODEL_TARGET", "model-large")
|
||||||
|
os.environ.setdefault("SMALL_MODEL_TARGET", "model-small")
|
||||||
|
|
||||||
|
# Now import and run
|
||||||
|
from claudex.main import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
x
Reference in New Issue
Block a user