Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
agentchat
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李伟@五瓣科技
agentchat
Commits
0fa9d4df
Commit
0fa9d4df
authored
Jun 03, 2025
by
Wade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add search query curl
parent
c15b60f7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
218 additions
and
9 deletions
+218
-9
README.md
README.md
+137
-0
go.mod
go.mod
+8
-5
go.sum
go.sum
+17
-0
main.go
main.go
+4
-4
main_test.go
main_test.go
+52
-0
No files found.
README.md
View file @
0fa9d4df
...
...
@@ -2,6 +2,96 @@
# milvus
http://54.92.111.204:9091/webui/collections
curl -X POST http://localhost:8000/indexDocuments
\
-H "Content-Type: application/json"
\
-d '{"content": "Paris is the capital of France?", "metadata": {"user_id": "user456", "username": "Bob"}}'
curl -X POST http://localhost:8000/indexDocuments
\
-H "Content-Type: application/json"
\
-d '{"content": "USA is the largest importer of coffee?", "metadata": {"user_id": "user456", "username": "Bob"}}'
curl -X POST http://localhost:8000/indexDocuments
\
-H "Content-Type: application/json"
\
-d '{"content": "Water exists in 3 states - solid, liquid and gas?", "metadata": {"user_id": "user456", "username": "Bob"}}'
curl -X POST 'http://54.92.111.204:19530/v1/vector/query'
\
-H 'Content-Type: application/json'
\
-H 'Accept: application/json'
\
-d '{
"collectionName": "useridx",
"output_fields":
[
"text", "metadata"
]
,
"filter": "id >= 0",
"consistency_level": "Bounded",
"limit": 10000
}'
curl -X POST 'http://54.92.111.204:19530/v1/vector/query'
\
-H 'Content-Type: application/json'
\
-H 'Accept: application/json'
\
-d '{
"collectionName": "useridx",
"output_fields":
[
"text", "metadata"
]
,
"filter": "id >= 0",
"consistency_level": "Bounded",
"limit": 10000
}'
go test -v -run TestGenerateEmbedding
curl -X POST 'http://54.92.111.204:19530/v1/vector/search'
\
-H 'Content-Type: application/json'
\
-H 'Accept: application/json'
\
-d '{
"collectionName": "useridx",
"vector":
[
0.03843782,-0.10801815,-0.0035926814,-0.032693874,0.056900613,0.0008304928,-0.01797009,-0.04407662,0.028722305,0.035475362,0.012025777,0.029417625,0.0110262055,-0.0056345984,0.014061109,-0.02962587,-0.006755365,0.0427251,0.010741998,-0.0027486754,-0.011494913,0.014012163,-0.052847106,0.030533107,0.009317728,-0.046866167,0.05694148,-0.10013145,-0.008522527,0.04721908,-0.0935844,0.01525563,-0.045407284,-0.018691462,-0.012562303,-0.04597733,0.011337631,0.046569165,-0.027993403,0.04749836,-0.047419142,0.0045363186,-0.054364458,-0.01753046,0.038755823,-0.046353877,-0.011006325,-0.0007375204,0.009074053,-0.010157847,0.017491907,-0.00954587,0.066316284,0.0019034654,0.0057822997,-0.05477185,-0.021970555,-0.0010239695,-0.01607411,0.0014950585,0.006363975,-0.013846755,-0.029795729,0.108403504,0.019004984,-0.032896034,0.0060955286,0.01751849,0.08429002,-0.036379814,-0.018664123,-0.020807538,0.042101983,-0.085952275,-0.029209964,-0.061416525,-0.054797087,0.060695596,0.032199714,-0.033211406,-0.040252347,-0.048212383,-0.021892065,-0.007480298,-0.0123305945,0.017129714,-0.037697818,-0.0017359223,-0.059629463,0.063662216,-0.024002736,0.024401622,0.013918808,-0.07851171,-0.023397831,0.047224253,-0.008561025,0.003333451,0.009866563,-0.01003198,0.01773248,-0.033277538,-0.04143109,0.04302292,0.057809904,0.014543673,-0.026988465,0.05021075,-0.013174102,0.02797813,-0.063146524,0.02169135,-0.003975126,0.02197511,0.027379813,0.01036559,-0.041078504,0.016345913,-0.008343955,0.0009706061,0.027580908,0.019550655,0.030760653,0.0036855882,0.013893162,0.027626673,0.0011957875,0.05266148,-0.011196996,0.01972624,0.027441168,-0.014437115,0.021325465,0.010016581,0.0286445,0.053278413,0.060899243,-0.02569211,0.06738633,-0.0003625518,0.008291838,0.052956663,-0.013242047,0.042226885,-0.0058189365,0.019142745,-0.0018542466,-0.0884387,0.019708745,-0.037007075,-0.039165843,-0.0038330376,-0.020685727,0.002137646,0.07027587,0.03518618,-0.030722804,-0.007358352,0.020176003,-0.0041375197,0.031176096,0.013450053,0.028787,-0.0020090516,-0.017547552,-0.020471439,0.053509634,0.034363378,0.016745571,-0.010689201,-0.0004696568,-0.021028008,-0.012343767,-0.02550123,0.007090246,-0.044418834,-0.016250396,-0.0086489795,-0.02585847,-0.033675477,-0.020478738,-0.01872456,0.011485122,-0.011701649,0.021184927,-0.019761706,0.037907097,-0.019539472,-0.025849065,0.027579935,-0.015540514,-0.035462152,-0.019292327,-0.022316614,-0.032853737,-0.0046322835,-0.005645606,-0.009486374,0.013942138,-0.047477145,-0.02784789,0.04943112,0.022930803,-0.023028154,0.0054635513,-0.0029833561,0.09663836,-0.08132662,-0.055230737,0.053583585,-0.046705246,-0.019914608,-0.062459424,0.035461556,0.033540323,-0.008629142,0.07065029,-0.011131455,0.006748144,-0.026757697,0.008806499,0.013059393,0.00055636454,-0.007769469,0.009478725,0.031457435,0.00858889,-0.048824117,-0.010520719,-0.05175352,-0.0409364,0.043944433,0.023581086,-0.025504746,0.042948272,0.037335046,0.03305401,0.011610304,0.027044967,-0.016982887,-0.06568399,-0.014548956,0.060233794,0.046012785,-0.048627976,-0.025827475,-0.028141076,-0.010040662,0.022237075,0.02736023,-0.034950055,-0.01623169,0.048911132,0.047720775,-0.05130803,0.016685862,-0.07295039,-0.004899238,-0.0043403734,0.003088271,0.036508102,0.017506996,0.032738738,-0.015836785,-0.0013161921,0.0361747,-0.012067375,-0.070750274,-0.0333092,0.014063581,0.019375961,-0.06256034,0.0017063153,-0.012136579,-0.011229105,0.028304802,-0.07528331,0.06016997,0.029876763,-0.06395304,0.018585209,0.02975133,0.0028785008,-0.04924631,-0.043987665,-0.009941707,-0.055947542,0.013884691,0.037246287,-0.017856054,-0.05137497,-0.048647474,-0.0023736819,-0.02097837,-0.08181237,-0.005045473,-0.06783967,0.053175204,0.058839116,0.002499179,-0.044353765,0.018165607,0.010746604,-0.07590331,0.0058653834,-0.017330524,-0.025738854,-0.040734474,0.013614571,0.012065889,0.028441897,-0.062838145,-0.07294751,0.02001647,0.0007125493,0.045819327,0.025182892,0.029725231,-0.010736619,0.09262206,0.0012555165,0.07174206,0.049362436,-0.020202195,-0.0018069926,-0.008525045,0.0017738127,0.07568828,0.026272647,-0.03250389,0.0019000544,0.012771353,-0.071174614,0.054063544,0.021146003,0.04374504,-0.00060066825,0.035537522,-0.038593676,0.04771156,0.04203235,0.010245813,-0.00235554,-0.023127967,-0.013158689,0.031120904,0.015238158,-0.0128886625,0.07628496,-0.02310663,0.0049422635,0.040248256,-0.021316642,-0.00080234784,-0.04902802,-0.0090737445,0.046291407,-0.003604421,0.063522205,-0.038646687,-0.07702935,0.038741115,-0.026668169,0.0019375713,-0.012160694,-0.0075221728,0.020110747,0.0019848133,-0.0016097312,0.0045474414,0.003488366,0.00469658,0.015401817,0.0028999213,0.0033466578,-0.015722046,-0.07937359,0.0040238434,-0.018728433,-0.008615699,-0.018277144,-0.029722715,0.06308558,0.02747852,0.023718102,-0.01945246,-0.0021234846,0.043668415,-0.0077830027,-0.000046238987,0.0016559111,0.021699231,0.013173144,0.025017582,-0.030180639,0.012013951,-0.025960943,-0.017600875,0.03018518,-0.012639231,-0.0012533896,-0.008609881,0.018118052,-0.009618411,-0.05527289,-0.01931072,-0.052839328,-0.031092139,0.0012166839,-0.0062457602,0.067721024,0.018339036,0.04792489,-0.04823303,-0.026953172,-0.027333282,0.04068963,-0.04834921,0.023894843,0.082817584,0.018735636,0.022978166,-0.011063285,-0.004295578,-0.044304732,-0.031063922,-0.0076035853,0.0026813871,0.024401488,-0.02101709,0.046551276,0.035206564,-0.005318038,-0.041359857,-0.024637321,-0.067124374,0.03334972,0.0019507223,-0.032958914,0.021708334,-0.0105287,-0.0066022375,0.028227085,0.04198249,-0.11609742,-0.019205382,-0.03305458,-0.0134911835,0.011170767,-0.07622374,0.020747215,-0.045790035,-0.00055858045,-0.054602053,-0.05993622,-0.06972769,0.013321911,0.048117246,-0.045701638,0.03200826,0.020918777,-0.0233393,-0.004020572,-0.048618045,0.020268548,0.0038998018,0.024773447,0.013144061,0.04321931,0.01800262,-0.012426906,-0.025510177,-0.0016893614,0.057901636,-0.0020053675,0.0045196135,-0.034931004,-0.0014150724,-0.037426088,-0.033266198,0.01643143,-0.024206428,0.0486749,0.032961223,-0.029839497,0.041842952,0.02268545,-0.020682879,-0.014362875,0.03580479,-0.04809911,0.024257628,-0.038557447,0.0023051384,-0.018996917,-0.025063388,-0.045062415,-0.021734884,0.0043491824,0.013081417,0.005029725,-0.042347617,-0.03879548,-0.024494866,0.066701815,-0.06986873,0.012743599,0.006759854,-0.02953009,-0.015046655,0.0006723915,0.016235502,-0.0043912837,0.006860745,0.019004779,0.03154714,0.012958628,0.048807457,0.057284165,-0.009824063,0.008037203,-0.001331536,-0.1324089,-0.013416185,-0.037767302,-0.013199997,0.034174956,0.053463183,-0.10178892,0.0060007875,0.0033546693,0.040941097,-0.03946203,-0.04135147,-0.024251232,-0.028510451,-0.018926073,0.036001626,0.087967224,0.020472396,-0.0005375871,-0.016304435,-0.010142697,0.011056987,0.014712494,0.003878636,0.015348929,-0.056971747,-0.0036313592,0.002476419,-0.026496837,-0.025325615,-0.013806501,-0.023463268,0.045808807,-0.051661372,-0.027449891,0.037827387,0.0041856677,-0.058483418,-0.073383115,-0.009435511,0.018742751,-0.006449073,0.11232101,0.05219001,-0.0044432585,0.024387227,0.06527803,-0.0061585326,-0.028151052,0.008557303,0.038960703,0.0031750035,0.054188415,-0.010951798,0.057138752,-0.019067472,0.002403626,-0.036895093,-0.0016023847,0.00009474349,-0.011695137,0.011138796,0.0076994505,0.10477774,0.022854181,0.054656964,0.055053733,0.05250508,-0.042696957,0.028732788,-0.00043513018,0.0132617215,0.036658082,0.021649256,-0.01052684,0.0129563995,-0.0014551458,-0.015237829,0.0347423,-0.050486915,0.041249175,-0.0027445664,-0.0031073985,0.03755217,-0.02502292,0.0047116913,-0.066570505,0.025984047,-0.011073829,-0.03437807,0.015215991,-0.01920109,-0.00046103404,-0.020339169,0.035763685,-0.01302836,0.021347135,-0.021851663,0.06411822,-0.015544492,-0.023034595,-0.028390259,0.053352203,0.0014498043,0.0020170521,-0.012576962,0.019091347,0.024778945,0.022792315,0.029053282,-0.0016118597,-0.01335711,-0.044073258,0.008068568,-0.023724945,-0.017707447,0.031818114,-0.035340257,-0.04644913,-0.0009944814,0.028104724,-0.028160615,0.033014968,0.12304963,0.033116627,-0.05225309,-0.0177489,0.020387227,-0.033281643,-0.041645706,0.011079419,-0.027180828,0.037914414,-0.03198912,-0.05688515,-0.057961848,0.01796609,-0.0045953603,-0.01214499,0.028735612,0.002434496,0.038295057,-0.038296636,-0.019474015,-0.037487578,-0.039340846,-0.03123182,0.044120025,-0.013044836,0.030975817,0.026351977,-0.006351776,0.033150315,0.04635382,-0.041898567,-0.02942466,0.012956598,-0.009453329,-0.006535657,-0.03331614,-0.016319979,-0.00937613,-0.034845177,0.008653715,0.06742186,0.0075705387,-0.022165032,-0.008388943,0.02006902,0.010607576,-0.05950851,-0.035042312,0.12647206,0.011953123,0.030103208,-0.026901055,-0.007572808,0.03579223,-0.009801378,-0.0704989,-0.029652314,-0.006752585,-0.0048610684,-0.014324836,-0.013467202,0.030755645,0.025676837,0.029660994,0.040610775,-0.042911142,-0.05377423,0.04263892,-0.010766625,-0.033704326,0.013111667,-0.015244707,-0.000034227425,0.046604767,0.06113486,0.032315064,0.031093886,-0.025785316,-0.048322752,0.051937714,-0.08809941,0.020804005,-0.026868736,0.006706912,0.10312094,0.0167206,-0.01909287,-0.0034649465,-0.035236653,0.0948521,0.003023375,0.001908022,0.00755883,-0.05999634,0.0020193893,-0.0030316054,-0.007999254,0.051412076,0.03285594,-0.00617675,-0.02589824,0.0374277,-0.01807927,-0.06921412,-0.040555634,0.014909444,-0.019136429,0.03623242,0.04555616,0.009243677,0.0018954773,0.022733297,0.0022532232,-0.014581746,-0.03628447,-0.01626001,0.035858408,0.038414206,-0.005562079,0.018296504,0.021874206,0.008055072
]
,
"topk": 10,
"metric_type": "L2",
"consistency_level": "Bounded",
"output_fields":
[
"id"
]
,
"filter": "id >= 0"
}'
curl -X POST 'http://54.92.111.204:19530/v1/vector/query'
\
-H 'Content-Type: application/json'
\
-H 'Accept: application/json'
\
-d '{
"collectionName": "useridx",
"output_fields":
[
"text", "metadata"
]
,
"filter": "id IN
[
458341973210780985, 458455329819611103, 458455329819611105, 458455329819611107, 458455329819611109, 458455329819611113, 458455329819611111
]
",
"consistency_level": "Bounded",
"limit": 10
}'
# graph
http://54.92.111.204:5670/
curl -d '{"content": "What is the capital of UK?"}' http://localhost:8000/chat
...
...
@@ -19,6 +109,13 @@ curl -X POST http://localhost:8000/indexDocuments \
curl -X POST http://localhost:8000/indexDocuments
\
-H "Content-Type: application/json"
\
-d '{"content": "What is the capital of UK 11111 ?", "metadata": {"user_id": "user456", "username": "Bob"}}'
curl -X POST http://localhost:8000/indexGraph
\
...
...
@@ -28,3 +125,43 @@ curl -X POST http://localhost:8000/indexGraph \
{"result": "Document indexed successfully"}
curl -X POST http://localhost:8000/indexDocuments
\
-H "Content-Type: application/json"
\
-d '{"content": "What is the capital of UK?", "metadata": {"user_id": "user456", "username": "Bob"}}'
{"result": "Document indexed successfully"}
go.mod
View file @
0fa9d4df
...
...
@@ -9,8 +9,9 @@ require (
require (
cloud.google.com/go v0.118.0 // indirect
cloud.google.com/go/auth v0.16.0 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/auth v0.16.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/compute/metadata v0.7.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
...
...
@@ -37,7 +38,7 @@ require (
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
github.com/googleapis/gax-go/v2 v2.14.
1
// indirect
github.com/googleapis/gax-go/v2 v2.14.
2
// indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
...
...
@@ -86,14 +87,16 @@ require (
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.25.0 // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.33.0 // indirect
google.golang.org/api v0.235.0 // indirect
google.golang.org/genai v1.5.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250
414145226-207652e42e2e
// indirect
google.golang.org/grpc v1.72.
0
// indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250
512202823-5a2f75b736a9
// indirect
google.golang.org/grpc v1.72.
1
// indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
...
...
go.sum
View file @
0fa9d4df
...
...
@@ -3,8 +3,14 @@ cloud.google.com/go v0.118.0 h1:tvZe1mgqRxpiVa3XlIGMiPcEUbP1gNXELgD4y/IXmeQ=
cloud.google.com/go v0.118.0/go.mod h1:zIt2pkedt/mo+DQjcT4/L3NDxzHPR29j5HcclNH+9PM=
cloud.google.com/go/auth v0.16.0 h1:Pd8P1s9WkcrBE2n/PhAwKsdrR35V3Sg2II9B+ndM3CU=
cloud.google.com/go/auth v0.16.0/go.mod h1:1howDHJ5IETh/LwYs3ZxvlkXF48aSqqJUM+5o02dNOI=
cloud.google.com/go/auth v0.16.1 h1:XrXauHMd30LhQYVRHLGvJiYeczweKQXZxsTbV9TiguU=
cloud.google.com/go/auth v0.16.1/go.mod h1:1howDHJ5IETh/LwYs3ZxvlkXF48aSqqJUM+5o02dNOI=
cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc=
cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c=
cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I=
cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
cloud.google.com/go/compute/metadata v0.7.0 h1:PBWF+iiAerVNe8UCHxdOt6eHLVc3ydFeOCw78U8ytSU=
cloud.google.com/go/compute/metadata v0.7.0/go.mod h1:j5MvL9PprKL39t166CoB1uVHfQMs4tFQZZcKwksXUjo=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM=
...
...
@@ -141,6 +147,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU
github.com/googleapis/enterprise-certificate-proxy v0.3.6/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA=
github.com/googleapis/gax-go/v2 v2.14.1 h1:hb0FFeiPaQskmvakKu5EbCbpntQn48jyHuvrkurSS/Q=
github.com/googleapis/gax-go/v2 v2.14.1/go.mod h1:Hb/NubMaVM88SrNkvl8X/o8XWwDJEPqouaLeN2IUxoA=
github.com/googleapis/gax-go/v2 v2.14.2 h1:eBLnkZ9635krYIPD+ag1USrOAI0Nr0QYF3+/3GqO0k0=
github.com/googleapis/gax-go/v2 v2.14.2/go.mod h1:ON64QhlJkhVtSqp4v1uaK92VyZ2gmvDQsweuyLV+8+w=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
...
...
@@ -399,6 +407,8 @@ golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
...
...
@@ -477,6 +487,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.235.0 h1:C3MkpQSRxS1Jy6AkzTGKKrpSCOd2WOGrezZ+icKSkKo=
google.golang.org/api v0.235.0/go.mod h1:QpeJkemzkFKe5VCE/PMv7GsUfn9ZF+u+q1Q7w6ckxTg=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genai v1.5.0 h1:6wB3MCW4JpCMHURJH2gBNxCU/9iN1YjKYQj362mDTbY=
...
...
@@ -488,8 +500,11 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24=
google.golang.org/genproto v0.0.0-20250106144421-5f5ef82da422 h1:6GUHKGv2huWOHKmDXLMNE94q3fBDlEHI+oTRIZSebK0=
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 h1:1tXaIXCracvtsRxSBsYDiSBN0cuJvM7QYW+MrpIRY78=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250512202823-5a2f75b736a9 h1:IkAfh6J/yllPtpYFU0zZN1hUPYdT0ogkBT/9hMxHjvg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250512202823-5a2f75b736a9/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
...
...
@@ -499,6 +514,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA=
google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
...
...
main.go
View file @
0fa9d4df
...
...
@@ -130,7 +130,7 @@ func main() {
UserName
:
input
.
Username
,
}
resDocName
:=
""
resDocName
:=
""
if
v
,
ok
:=
input
.
Metadata
[
graphrag
.
DocNameKey
];
!
ok
{
// Generate random docName.
...
...
@@ -140,10 +140,10 @@ func main() {
}
input
.
Metadata
[
graphrag
.
DocNameKey
]
=
docName
resDocName
=
docName
}
else
{
}
else
{
if
str
,
isString
:=
v
.
(
string
);
isString
{
resDocName
=
str
}
}
}
doc
:=
ai
.
DocumentFromText
(
input
.
Content
,
input
.
Metadata
)
...
...
@@ -154,7 +154,7 @@ func main() {
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"index document: %w"
,
err
)
}
return
fmt
.
Sprintf
(
"Document indexed successfully, docname %s"
,
resDocName
),
nil
return
fmt
.
Sprintf
(
"Document indexed successfully, docname %s"
,
resDocName
),
nil
})
// Define a simple flow that generates jokes about a given topic
...
...
main_test.go
0 → 100644
View file @
0fa9d4df
package
main
import
(
"context"
"encoding/json"
"log"
"testing"
"github.com/firebase/genkit/go/ai"
"github.com/firebase/genkit/go/genkit"
"github.com/firebase/genkit/go/plugins/googlegenai"
)
// func TestGenerateEmbedding(t *testing.T)
func
TestGenerateEmbedding
(
t
*
testing
.
T
){
ctx
:=
context
.
Background
()
// Initialize Genkit with Google AI plugin
g
,
err
:=
genkit
.
Init
(
ctx
,
genkit
.
WithPlugins
(
&
googlegenai
.
GoogleAI
{
APIKey
:
"AIzaSyCoYBOmnwRWlH_-nT25lpn8pMg3T18Q0uI"
,
}))
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to initialize Genkit: %v"
,
err
)
}
// Initialize the embedder
embedder
:=
googlegenai
.
GoogleAIEmbedder
(
g
,
"embedding-001"
)
if
embedder
==
nil
{
log
.
Fatal
(
"embedder is not defined"
)
}
// Create EmbedRequest for the query
query
:=
"What is the capital of UK?"
request
:=
&
ai
.
EmbedRequest
{
Input
:
[]
*
ai
.
Document
{
ai
.
DocumentFromText
(
query
,
nil
)},
// Wrap the query in a Document
}
// Generate embedding
embedding
,
err
:=
embedder
.
Embed
(
ctx
,
request
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to generate embedding: %v"
,
err
)
}
// Print the embedding
embeddingJSON
,
err
:=
json
.
Marshal
(
embedding
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to marshal embedding: %v"
,
err
)
}
log
.
Printf
(
"Embedding for '%s': %s"
,
query
,
string
(
embeddingJSON
))
//log.Printf("Embedding dimension: %d", len(embedding))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment