Zack Saadioui
8/27/2024
1
2
bash
ollama run mistral
1
2
3
dockerfile
FROM ankane/pgvector
COPY *.sql /docker-entrypoint-initdb.d/
1
init.sql
1
PostGIS
1
2
3
sql
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS pgvector;
1
docker-compose.yaml
1 2 3 4 5 6 7
- "5432:5432" environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: password POSTGRES_DB: mydatabase volumes: - pg_data:/var/lib/postgresql/data
1
Now start your PostGIS service with:
1
2
bash
psql -h localhost -U postgres -d mydatabase -c "SELECT PostGIS_Version();"
1
2
3
4
5
6
sql
CREATE TABLE locations (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
geom GEOMETRY(Point, 4326)
);
1
locations
1
2
sql
INSERT INTO locations (name, geom) VALUES ('Central Park', ST_SetSRID(ST_MakePoint(-73.9654, 40.7851), 4326));
1
2
3
4
5
javascript
const response = await ollama.chat({
prompt: 'Which parks are in New York?',
model: 'mistral',
});
1
2
sql
SELECT name FROM locations WHERE ST_DWithin(geom, ST_SetSRID(ST_MakePoint(-73.9654, 40.7851), 4326), 500);
1
2
3
4
5
javascript
const vectorResults = await getEmbedding(userPrompt);
const locationResults = await queryDatabase(vectorResults);
const answer = await ollama.chat(locationResults);
console.log(answer);
Copyright © Arsturn 2024