examples-ai-go

module
v0.0.0-...-46865d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: Apache-2.0

README

AI Examples with Go

Prerequisites

  • docker
  • ollama
brew install ollama

Be sure that ollama running as a service in your machine.

brew services start ollama
ollama list

Vector stores backend

All run by docker-compose

docker-compose up or podman compose up

Examples

Use makefile to run it.

make
Chroma
make chroma-example
go run vectorstores/chroma/main.go
Results:
1. case: Up to 5 Cities in Japan
    result:
2. case: A City in South America
    result:
3. case: Large Cities in South America
    result: Rio de Janeiro, Sao Paulo
  • not work as expected, the query is not returning the expected results.
PGVector
make pgvector-example
go run vectorstores/pgvector/main.go
[{Tokyo map[area:2190 population:38] 0.6732199}]
[]
[]
  • looks that have some issues, to find others queries, db is not empty and we get all data but looks that vector search can't find the data.

+--------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+---------------------------------+------------
--------------------------+
| collection_id                        | embedding
                                                                                                                                                                                                                                               | document       | cmetadata                       | uuid
                          |
|--------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+---------------------------------+------------
--------------------------|
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-2.931465,-3.159482,-0.771489,-1.0922911,-2.9874356,3.225053,-0.38827032,1.8102368,-0.71587074,0.08164251,-0.1865315,-1.1149579,-2.8838854,-0.38923767,-1.0660964,0.6300274,2.5867085,-0.7275886,2.1767182,2.15741,1.4784691,1.1492847,0.9174938,3.0950696,1.1262578,
-1.5771776,-1.0194442,-5.5706205,2.076623,-0.106084585,-3.2737265,0.7914688,1.4182041,-3.7254252,2.271312,2.794512,-1.381062,0.018045222,0.292771,-1.7887782,-0.25094625,-1.7363861,0.2958556,-1.2852753,-0.13938048,-2.4600272,4.0479217,-... | Tokyo          | {"area":2190,"population":38}   | 479f4d55-71
42-434f-a020-c515b3f2db90 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-1.5166731,-2.5742595,3.4159904,2.4820077,-1.7949796,2.467023,0.008108478,0.35128325,2.117637,0.7051908,0.8145143,1.6260331,-0.03333599,1.4918437,-2.845873,1.5316619,1.615731,1.4784429,-2.4275444,-0.31520718,3.0192015,0.8292088,5.584265,0.0870759,-2.0774617,-1.
2681444,1.2438779,-2.149035,3.0647628,-1.5608386,-2.2165396,-0.34096804,-1.5022651,1.3045143,4.354492,-1.4945875,-2.0173628,0.49899867,-3.304937,-1.2164197,2.3508825,-2.269811,-2.2285843,-1.871356,0.8021824,-2.6277149,2.44842,-0.246114... | Paris          | {"area":105,"population":11}    | a7865305-42
c1-41fd-afb4-68e5a7b35a61 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-0.7644389,-5.018981,-0.35538372,1.0196193,-2.8508067,2.2410882,-3.123147,3.0757318,-1.3784521,1.5957321,0.10787586,0.04524422,0.17775281,1.6218021,-1.6676964,2.8394177,0.061899483,-0.13904895,-1.1503706,3.303471,2.6597605,-0.7923076,4.939548,1.0248806,0.600670
16,-1.3287073,0.16070342,-6.95929,0.030879932,-0.32311264,-0.42944148,1.4775789,-1.6127092,-3.1171062,3.532166,2.190679,-3.299086,0.4840341,-2.677577,-1.5989283,-1.169069,-0.76344323,1.8869836,-0.2807242,1.5781195,-7.049076,5.1998773,3... | London         | {"area":1572,"population":9.5}  | 3acc18e9-e1
3a-44e8-bf4e-7968beadae85 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-2.5155299,0.32917032,-0.14418335,2.7374854,-3.6577804,2.295267,-2.205355,1.4741124,-1.2500776,-0.949158,-0.47867432,-2.0001442,-2.3288894,-0.06909472,-1.6659825,2.3501108,-0.02808141,4.114279,-0.60917693,2.0060246,4.918935,-2.3316247,2.684518,-1.6645442,-0.717
4878,-2.6608853,4.732967,-4.425982,2.6598277,2.5658696,-4.241086,0.5425616,-1.4835773,-2.4304502,5.9724402,0.11691806,-2.3508904,-1.114342,-2.1215549,-2.7187607,-0.87204105,0.046112668,-2.341788,-2.6384618,0.3107513,-1.7496668,5.988973... | Santiago       | {"area":641,"population":6.9}   | b633542b-2e
27-4964-94f0-e21623115de7 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-1.9005774,-0.85420537,3.2474654,5.170169,-3.92789,-0.5265545,-2.9483516,1.4750404,1.2753507,1.1504366,2.1483133,-1.7112331,-0.34679362,-0.7891343,-1.1546783,0.7790943,0.78644615,1.7748499,-0.37429258,2.6000993,1.8390884,-0.666604,3.2914147,1.6470762,0.61067486
,2.705403,1.9279298,-3.031766,2.8919802,1.4690597,-2.0382144,-1.2939299,-2.3132691,-0.82389605,4.612077,1.2576267,-3.098985,1.156809,-3.4779897,-1.2421871,0.29660884,0.35416076,-0.1248038,-1.4433317,0.21138589,-1.7563651,4.516183,3.398... | Buenos Aires   | {"area":203,"population":15.5}  | e6151a42-eb
18-4e65-8ba1-2c8962dd4a58 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-1.6505234,-1.9956274,1.313637,2.6959128,-1.1110357,1.2065692,-5.239214,0.31526136,2.4880104,2.5185373,0.85364467,-2.0544431,0.2501672,-0.41428682,1.3077384,0.55939907,1.2710526,0.4263271,-1.6761698,2.595988,2.07704,0.5382606,2.1562064,2.9472835,-0.1656527,-0.5
0013673,4.5232897,0.7805829,4.0403905,0.5121336,-0.88939923,-0.32672104,-0.71925634,-1.5459478,2.066714,1.3053867,-1.9697137,-1.8486346,-2.7048676,-2.810047,0.86216486,-1.3233347,-1.4043283,0.61445045,-0.476398,-1.3093725,3.9643939,5.7... | Rio de Janeiro | {"area":1200,"population":13.7} | 420fbf48-56
37-44a6-881d-ebb94bdeda97 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-1.3778139,-0.796716,0.08025245,2.0052905,-1.8449464,3.0602455,-5.3618603,1.4143652,-0.27638492,3.02173,-0.591277,-1.1051335,-1.6263776,-0.37028787,0.093051404,-0.55636233,-0.6575013,-1.1421787,-0.57324076,2.0030649,4.0839105,-0.42033428,2.3643475,1.1955452,1.1
847508,-0.39757645,1.5579712,1.2366985,3.9415839,2.8613148,-1.2705083,-1.1571549,0.41427696,0.096256256,3.4040487,2.1170638,-1.9052057,-1.1412812,-2.468752,-4.752384,0.63480663,-1.2270863,-3.1931667,0.91037333,0.6577591,-2.8866205,4.22... | Sao Paulo      | {"area":1523,"population":22.6} | b40c6452-12
3b-4bd3-8d52-76d92a8a2870 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-2.931465,-3.159482,-0.771489,-1.0922911,-2.9874356,3.225053,-0.38827032,1.8102368,-0.71587074,0.08164251,-0.1865315,-1.1149579,-2.8838854,-0.38923767,-1.0660964,0.6300274,2.5867085,-0.7275886,2.1767182,2.15741,1.4784691,1.1492847,0.9174938,3.0950696,1.1262578,
-1.5771776,-1.0194442,-5.5706205,2.076623,-0.106084585,-3.2737265,0.7914688,1.4182041,-3.7254252,2.271312,2.794512,-1.381062,0.018045222,0.292771,-1.7887782,-0.25094625,-1.7363861,0.2958556,-1.2852753,-0.13938048,-2.4600272,4.0479217,-... | Tokyo          | {"area":2190,"population":38}   | 2ccda6ee-2f
6d-4cac-b2f1-6a77331184c1 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-1.5166731,-2.5742595,3.4159904,2.4820077,-1.7949796,2.467023,0.008108478,0.35128325,2.117637,0.7051908,0.8145143,1.6260331,-0.03333599,1.4918437,-2.845873,1.5316619,1.615731,1.4784429,-2.4275444,-0.31520718,3.0192015,0.8292088,5.584265,0.0870759,-2.0774617,-1.
2681444,1.2438779,-2.149035,3.0647628,-1.5608386,-2.2165396,-0.34096804,-1.5022651,1.3045143,4.354492,-1.4945875,-2.0173628,0.49899867,-3.304937,-1.2164197,2.3508825,-2.269811,-2.2285843,-1.871356,0.8021824,-2.6277149,2.44842,-0.246114... | Paris          | {"area":105,"population":11}    | 3dd85db7-6a
a1-4f7a-8c94-c3d10571d60a |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-0.7644389,-5.018981,-0.35538372,1.0196193,-2.8508067,2.2410882,-3.123147,3.0757318,-1.3784521,1.5957321,0.10787586,0.04524422,0.17775281,1.6218021,-1.6676964,2.8394177,0.061899483,-0.13904895,-1.1503706,3.303471,2.6597605,-0.7923076,4.939548,1.0248806,0.600670
16,-1.3287073,0.16070342,-6.95929,0.030879932,-0.32311264,-0.42944148,1.4775789,-1.6127092,-3.1171062,3.532166,2.190679,-3.299086,0.4840341,-2.677577,-1.5989283,-1.169069,-0.76344323,1.8869836,-0.2807242,1.5781195,-7.049076,5.1998773,3... | London         | {"area":1572,"population":9.5}  | d07e6fd7-7a
dc-4dd5-9fc8-aed9031d7485 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-2.5155299,0.32917032,-0.14418335,2.7374854,-3.6577804,2.295267,-2.205355,1.4741124,-1.2500776,-0.949158,-0.47867432,-2.0001442,-2.3288894,-0.06909472,-1.6659825,2.3501108,-0.02808141,4.114279,-0.60917693,2.0060246,4.918935,-2.3316247,2.684518,-1.6645442,-0.717
4878,-2.6608853,4.732967,-4.425982,2.6598277,2.5658696,-4.241086,0.5425616,-1.4835773,-2.4304502,5.9724402,0.11691806,-2.3508904,-1.114342,-2.1215549,-2.7187607,-0.87204105,0.046112668,-2.341788,-2.6384618,0.3107513,-1.7496668,5.988973... | Santiago       | {"area":641,"population":6.9}   | d1c097b8-96
60-4e50-b42b-d6ec6f15942b |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-1.9005774,-0.85420537,3.2474654,5.170169,-3.92789,-0.5265545,-2.9483516,1.4750404,1.2753507,1.1504366,2.1483133,-1.7112331,-0.34679362,-0.7891343,-1.1546783,0.7790943,0.78644615,1.7748499,-0.37429258,2.6000993,1.8390884,-0.666604,3.2914147,1.6470762,0.61067486
,2.705403,1.9279298,-3.031766,2.8919802,1.4690597,-2.0382144,-1.2939299,-2.3132691,-0.82389605,4.612077,1.2576267,-3.098985,1.156809,-3.4779897,-1.2421871,0.29660884,0.35416076,-0.1248038,-1.4433317,0.21138589,-1.7563651,4.516183,3.398... | Buenos Aires   | {"area":203,"population":15.5}  | 2b9eeacd-3e
69-4a3e-ac30-581e3979c270 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-1.6505234,-1.9956274,1.313637,2.6959128,-1.1110357,1.2065692,-5.239214,0.31526136,2.4880104,2.5185373,0.85364467,-2.0544431,0.2501672,-0.41428682,1.3077384,0.55939907,1.2710526,0.4263271,-1.6761698,2.595988,2.07704,0.5382606,2.1562064,2.9472835,-0.1656527,-0.5
0013673,4.5232897,0.7805829,4.0403905,0.5121336,-0.88939923,-0.32672104,-0.71925634,-1.5459478,2.066714,1.3053867,-1.9697137,-1.8486346,-2.7048676,-2.810047,0.86216486,-1.3233347,-1.4043283,0.61445045,-0.476398,-1.3093725,3.9643939,5.7... | Rio de Janeiro | {"area":1200,"population":13.7} | af1f4a1d-ac
e2-4769-b192-1bf95034cbc7 |
| 257e3e45-e8c8-42ff-a7ce-5cc9054246fb | [-1.3778139,-0.796716,0.08025245,2.0052905,-1.8449464,3.0602455,-5.3618603,1.4143652,-0.27638492,3.02173,-0.591277,-1.1051335,-1.6263776,-0.37028787,0.093051404,-0.55636233,-0.6575013,-1.1421787,-0.57324076,2.0030649,4.0839105,-0.42033428,2.3643475,1.1955452,1.1
847508,-0.39757645,1.5579712,1.2366985,3.9415839,2.8613148,-1.2705083,-1.1571549,0.41427696,0.096256256,3.4040487,2.1170638,-1.9052057,-1.1412812,-2.468752,-4.752384,0.63480663,-1.2270863,-3.1931667,0.91037333,0.6577591,-2.8866205,4.22... | Sao Paulo      | {"area":1523,"population":22.6} | 8ff40e56-61
2a-48d9-80fe-d07cb714aefe |
+--------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+---------------------------------+------------
--------------------------+
SELECT 14

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL