-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquick_start.sh
More file actions
executable file
Β·213 lines (188 loc) Β· 7.64 KB
/
quick_start.sh
File metadata and controls
executable file
Β·213 lines (188 loc) Β· 7.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/bash
# π― HeySol API Client - Quick Start (Shell Script)
#
# Get up and running with HeySol in under 5 minutes!
#
# This script will:
# 1. Check your API key setup
# 2. Create a demo space (or reuse existing)
# 3. Ingest sample data
# 4. Perform a search
# 5. Show you the results
#
# Prerequisites:
# - Get your API key from https://core.heysol.ai/settings/api
# - Set environment variable: export HEYSOL_API_KEY="your-key-here"
# - Or create a .env file with: HEYSOL_API_KEY=your-key-here
# - Install the CLI: pip install heysol-api-client
#
# Run: bash quick_start.sh
set -e # Exit on any error
# Load environment variables from .env file if it exists
if [ -f ".env" ]; then
set -a
source .env
set +a
# Explicitly export the API keys
export HEYSOL_API_KEY_IDRDEX_MAMMOCHAT
export HEYSOL_API_KEY_HADLEYLABELABORATORY
export HEYSOL_API_KEY_IDRDEX_GMAIL
fi
echo "π HeySol API Client - Quick Start (Shell)"
echo "=========================================="
# Check API key - look for any variable starting with HEYSOL_API_KEY
# Try to find any HEYSOL_API_KEY* variable
for var in $(env | grep '^HEYSOL_API_KEY' | cut -d= -f1); do
if [ -n "${!var}" ]; then
HEYSOL_API_KEY="${!var}"
if [ "$var" = "HEYSOL_API_KEY_IDRDEX_MAMMOCHAT" ]; then
USER_NAME="iDrDex@MammoChat.com"
TARGET_API_KEY="${HEYSOL_API_KEY_HADLEYLABELABORATORY}"
elif [ "$var" = "HEYSOL_API_KEY_HADLEYLABELABORATORY" ]; then
USER_NAME="HadleyLaboratory@gmail.com"
TARGET_API_KEY="${HEYSOL_API_KEY_IDRDEX_MAMMOCHAT}"
elif [ "$var" = "HEYSOL_API_KEY_IDRDEX_GMAIL" ]; then
USER_NAME="iDrDex@gmail.com"
TARGET_API_KEY="${HEYSOL_API_KEY_HADLEYLABELABORATORY}"
else
USER_NAME=$(echo "$var" | sed 's/HEYSOL_API_KEY_//')
TARGET_API_KEY="${HEYSOL_API_KEY_HADLEYLABELABORATORY}"
fi
echo "β
Found API key from $var (user: $USER_NAME)"
break
fi
done
if [ -z "$HEYSOL_API_KEY" ]; then
echo "β No API key found!"
echo ""
echo "π To get started:"
echo "1. Visit: https://core.heysol.ai/settings/api"
echo "2. Generate an API key"
echo "3. Set environment variable:"
echo " export HEYSOL_API_KEY='your-api-key-here'"
echo "4. Or create a .env file with:"
echo " HEYSOL_API_KEY_xxx=your-api-key-here (any name starting with HEYSOL_API_KEY)"
echo ""
echo "Then run this script again!"
exit 1
fi
echo "β
API key found (ends with: ...${HEYSOL_API_KEY: -4})"
echo "π Validating API key..."
# Check if CLI is available
if ! command -v heysol-client &> /dev/null; then
echo "β heysol-client CLI not found!"
echo "Install with: pip install heysol-api-client"
exit 1
fi
echo "β
CLI available"
echo "β
API key validated!"
# Register instances from .env
echo ""
echo "π Checking registry configuration..."
python -c "from src.heysol.registry_config import RegistryConfig; registry = RegistryConfig(); print(f'β
Found {len(registry.get_instance_names())} registered instances')"
echo "β
Registry configured"
# Create demo space (or reuse existing)
echo ""
echo "ποΈ Setting up demo space..."
SPACE_NAME="Quick Start Demo $(date +%s)"
SPACE_DESC="Created by HeySol quick start script"
# Check for existing space
echo " Checking for existing spaces..."
EXISTING_SPACES=$(PYTHONPATH=/Users/idrdex/Library/Mobile\ Documents/com~apple~CloudDocs/Code/heysol_api_client python -m src.cli --user "$USER_NAME" spaces list 2>/dev/null || echo "[]")
# Extract space ID if it exists
SPACE_ID=$(echo "$EXISTING_SPACES" | python3 -c "
import sys, json
try:
spaces = json.load(sys.stdin)
if isinstance(spaces, list):
for space in spaces:
if isinstance(space, dict) and space.get('name') == '$SPACE_NAME':
print(space.get('id', ''))
sys.exit(0)
elif isinstance(spaces, dict) and 'spaces' in spaces:
for space in spaces['spaces']:
if isinstance(space, dict) and space.get('name') == '$SPACE_NAME':
print(space.get('id', ''))
sys.exit(0)
except:
pass
print('')
")
if [ -n "$SPACE_ID" ]; then
echo " Found existing space '$SPACE_NAME' with ID: $SPACE_ID"
else
echo " Creating new space: $SPACE_NAME"
CREATE_RESULT=$(PYTHONPATH=/Users/idrdex/Library/Mobile\ Documents/com~apple~CloudDocs/Code/heysol_api_client python -m src.cli --user "$USER_NAME" spaces create "$SPACE_NAME" --description "$SPACE_DESC")
SPACE_ID=$(echo "$CREATE_RESULT" | python3 -c "
import sys, json
try:
result = json.load(sys.stdin)
print(result.get('space_id', ''))
except:
print('')
")
if [ -z "$SPACE_ID" ]; then
echo " Warning: Could not extract space ID from creation response"
SPACE_ID="unknown"
fi
fi
echo "β
Using space: $SPACE_NAME"
# Ingest sample data
echo ""
echo "π Ingesting sample clinical data..."
SAMPLE_DATA=(
"Patient shows positive response to immunotherapy treatment"
"Clinical trial demonstrates 78% efficacy rate for new oncology drug"
"Biomarker analysis reveals key indicators for treatment success"
)
for i in "${!SAMPLE_DATA[@]}"; do
echo " Ingesting item $((i+1))/3..."
PYTHONPATH=/Users/idrdex/Library/Mobile\ Documents/com~apple~CloudDocs/Code/heysol_api_client python -m src.cli --user "$USER_NAME" memory ingest "${SAMPLE_DATA[$i]}" --space-id "$SPACE_ID" > /dev/null
echo " β
Ingested $((i+1))/3 items"
done
# Search
echo ""
echo "π Searching for 'treatment' (using global --user)..."
SEARCH_RESULTS=$(PYTHONPATH=/Users/idrdex/Library/Mobile\ Documents/com~apple~CloudDocs/Code/heysol_api_client python -m src.cli --user "$USER_NAME" memory search "treatment" --space-id "$SPACE_ID" --limit 3)
# Extract and display results
EPISODE_COUNT=$(echo "$SEARCH_RESULTS" | python3 -c "
import sys, json
try:
result = json.load(sys.stdin)
episodes = result.get('episodes', [])
print(len(episodes))
for i, episode in enumerate(episodes[:3], 1):
content = episode.get('content', '')[:60]
print(f' {i}. {content}{\"...\" if len(content) == 60 else \"\"}')
except:
print('0')
")
echo "β
Found $EPISODE_COUNT results"
# Demonstrate copy operation
echo ""
echo "π Demonstrating copy operation to another instance (using global --user)..."
# Check if there are other instances available
OTHER_INSTANCES=$(python -c "from src.heysol.registry_config import RegistryConfig; registry = RegistryConfig(); instances = registry.get_instance_names(); print('\n'.join([name for name in instances if name != '$USER_NAME']))")
if [ -n "$OTHER_INSTANCES" ]; then
TARGET_USER=$(echo "$OTHER_INSTANCES" | head -1)
echo " Copying 1 item to $TARGET_USER..."
PYTHONPATH=/Users/idrdex/Library/Mobile\ Documents/com~apple~CloudDocs/Code/heysol_api_client python -m src.cli --user "$USER_NAME" memory copy --target-user "$TARGET_USER" --space-id "$SPACE_ID" --limit 1 --confirm > /dev/null
echo " β
Copied data to $TARGET_USER"
else
echo " Only one instance available, skipping cross-instance copy demo"
fi
echo ""
echo "π Quick start completed successfully!"
echo ""
echo "π Next steps:"
echo "- Try the Python version: python quick_start.py"
echo "- Try the interactive notebook: jupyter notebook quick_start.ipynb"
echo "- Explore examples: ls examples/"
echo "- CLI help: heysol-client --help"
echo "- Documentation: https://core.heysol.ai/"
echo "- API vs MCP analysis: docs/API_VS_MCP_ANALYSIS.md"
echo ""
echo "π‘ Python Client Types:"
echo "- HeySolClient: Unified (recommended for most users)"
echo "- HeySolAPIClient: Direct API (high performance)"
echo "- HeySolMCPClient: MCP protocol (advanced features)"