#!/usr/bin/env python3 """Test Ollama embedding API to understand format for reranking""" import requests import json def test_ollama_embed(): print("=== Testing Ollama Embedding API ===") # Test embedding with Jina rerank model test_data = { "model": "jina-reranker-v2:latest", "input": ["The capital of France is Paris.", "Tokyo is the capital of Japan."] } try: response = requests.post( "http://localhost:11434/api/embed", json=test_data, timeout=10 ) print(f"Status: {response.status_code}") if response.status_code == 200: result = response.json() print(f"Response keys: {list(result.keys())}") print(f"Model: {result.get('model')}") print(f"Embeddings length: {len(result.get('embeddings', []))}") if result.get('embeddings'): print(f"First embedding shape: {len(result['embeddings'][0])}") print(f"First embedding sample: {result['embeddings'][0][:5]}...") else: print(f"Error: {response.text}") except Exception as e: print(f"Error: {e}") if __name__ == "__main__": test_ollama_embed()