From 131ae9dfbb0f1e38049e6ef95602c62c5506e979 Mon Sep 17 00:00:00 2001 From: gautamgambhir97 Date: Tue, 17 Dec 2024 14:55:14 +0530 Subject: [PATCH 1/6] feat: add guide for the search agent --- pages/guides/fetchai-sdk/_meta.json | 6 + pages/guides/fetchai-sdk/search-agent.mdx | 225 ++++++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 pages/guides/fetchai-sdk/_meta.json create mode 100644 pages/guides/fetchai-sdk/search-agent.mdx diff --git a/pages/guides/fetchai-sdk/_meta.json b/pages/guides/fetchai-sdk/_meta.json new file mode 100644 index 000000000..be4f71df2 --- /dev/null +++ b/pages/guides/fetchai-sdk/_meta.json @@ -0,0 +1,6 @@ +{ + "search-agent": { + "title": "Search Agent", + "timestamp": true + } +} diff --git a/pages/guides/fetchai-sdk/search-agent.mdx b/pages/guides/fetchai-sdk/search-agent.mdx new file mode 100644 index 000000000..2b557bd5b --- /dev/null +++ b/pages/guides/fetchai-sdk/search-agent.mdx @@ -0,0 +1,225 @@ +# Fetch.ai SDK Guide: Search Agent + +This guide explains the implementation of a Search Agent and Query Agent using the Fetch.ai SDK. These agents work together to handle user queries, search the Fetch.ai network for relevant agents, and return results. +Below, we outline the Search Function and the Complete Agent Implementation in detail. + + +## Installation + +With Python installed, let's set up our environment. + +Create a new folder; let's call it `fetchai-search-agent`: + +``` +mkdir fetchai-search-agent && cd fetchai-search-agent +``` + +Then, let's install our required libraries: + +``` +poetry install uagents fetchai openai +``` + + +## Search Function + +The search function is the core of the Search Agent. It interacts with the Fetch.ai network to find agents matching a specific query and sends them a message. Here's how it works: + +### Functionality + +- Search the Fetch.ai Network: + The `fetch.ai(query)` method searches for agents that match the user's query. + +- Set Sender Identity: + Each message is sent using a unique sender identity generated by `Identity.from_seed`. + +- Dynamic Payload: + Uses OpenAI's GPT to generate payload based on the query. + +- Send Messages: + For every matching agent, a payload is constructed and sent using the `send_message_to_agent` function. + + +```py copy +from fetchai import fetch +from fetchai.crypto import Identity +from fetchai.communication import send_message_to_agent +from uuid import uuid4 + +def search(query): + # Search for agents matching the query + available_ais = fetch.ai(query) + + # Create sender identity for communication + sender_identity = Identity.from_seed("search_sender_identity", 0) + + for ai in available_ais.get('ais'): # Iterate through discovered agents + + prompt = f""" + you will take the following information: query={query}. + You must return a results according to the query""" + + completion = client.chat.completions.create( + model="gpt-4o", + messages=[ + {"role": "user", "content": prompt} + ] + ) + + payload = { + "Response": completion.choices[0].message.content + } + + other_addr = ai.get("address", "") # Get agent's address + print(f"Sending a message to an AI agent at address: {other_addr}") + + # Send the payload to the discovered agent + send_message_to_agent( + sender=sender_identity, + target=other_addr, + payload=payload, + session=uuid4(), + ) + + return {"status": "Agent searched"} +``` + +## Complete Agent Implementation + +The implementation involves two agents: Query Agent and Search Agent, which interact with each other as follows: + +### Query Agent: + +- Sends the user’s query to the Search Agent on startup. +- Waits for a response from the Search Agent. + +```py +query_agent = Agent(name="query_agent", seed="query_agent recovery phrase") +``` + +### Search Agent: + +- Receives the query, processes it using the search() function, and sends a response back to the Query Agent. + +```py +search_agent = Agent(name="search_agent", seed="search_agent recovery phrase") +``` + +## Overall script + +```py copy +from fetchai import fetch +from fetchai.crypto import Identity +from fetchai.communication import ( + send_message_to_agent +) + +from openai import OpenAI + +client = OpenAI() + + +from uuid import uuid4 +from uagents import Agent, Bureau, Context, Model + +class Query(Model): + message: str + +class Response(Model): + status: str + +def search(query): + available_ais = fetch.ai(query) + sender_identity = Identity.from_seed("whatever i want this to be, but i am searching", 0) + print(f"[results] available ais : {available_ais} ") + for ai in available_ais.get('ais'): + + prompt = f""" + you will take the following information: query={query}. + You must return a results according to the query""" + + completion = client.chat.completions.create( + model="gpt-4o", + messages=[ + {"role": "user", "content": prompt} + ] + ) + + payload = { + "Response": completion.choices[0].message.content + } + + other_addr = ai.get("address", "") + + print(f"[INFO] Sending message to AI at address: {other_addr}") + + send_message_to_agent( + sender=sender_identity, + target=ai.get("address", ""), + payload=payload, + session=uuid4() + ) + + return {"status": "Agent searched"} + +query_agent = Agent(name="query_agent", seed="query_agent recovery phrase") +search_agent = Agent(name="search_agent", seed="search_agent recovery phrase") + +user_query = input("Enter your query: ") + +@query_agent.on_event("startup") +async def send_message(ctx: Context): + ctx.logger.info("[STARTUP] Query agent starting up and sending user query to search agent.") + await ctx.send(search_agent.address, Query(message=user_query)) + +@search_agent.on_message(model=Query) +async def sigmar_message_handler(ctx: Context, sender: str, msg: Query): + ctx.logger.info(f"[RECEIVED] Query received from {sender}. Message: '{msg.message}'") + results = search(msg.message) + ctx.logger.info("[PROCESSING] Searching completed. Sending response back to the query agent.") + await ctx.send(query_agent.address, Response(status=results["status"])) + +@query_agent.on_message(model=Response) +async def slaanesh_message_handler(ctx: Context, sender: str, msg: Response): + ctx.logger.info(f"[RECEIVED] Response received from search agent {sender}. Status: '{msg.status}'") + +bureau = Bureau() +bureau.add(query_agent) +bureau.add(search_agent) + +if __name__ == "__main__": + print("[INFO] Starting Bureau with Query Agent and Search Agent...") + bureau.run() + +``` + +## Running the agent. + +We run `fetchai-search-agent` with the following commands: + +``` +python fetchai-search-agent +``` + +## Expected output + +The expected output from the `fetchai-search-agent` should be similar to the following: + + +``` +Enter your query: Buy me a pair of shoes +[INFO] Starting Bureau with Query Agent and Search Agent... +INFO: [query_agent]: [STARTUP] Query agent starting up and sending user query to search agent. +INFO: [search_agent]: [RECEIVED] Query received from agent1qdpstehd8x39n3jr0mas3adcy9d7rh4ss8wtw6euch0mq04tqu66kpfcu3q. Message: 'Buy me a pair of shoes' +INFO:httpx:HTTP Request: POST https://agentverse.ai/v1/search/agents "HTTP/1.1 200 OK" +[results] available ais : {'ais': [{'address': 'agent1qv5jr3ylluy45hzwftgctt0hnaa75h2m0ehflxdw8rz3720pjmaegy2447r', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Margaret Vega\n MARGARET VEGA, is a Professor Emerita of Painting at Kendall College of Art and Design in Grand Rapids, Michigan. \nHer selected juried Exhibitions include: \nConnections; Color Me Flesh: Artifacts, Census and Token; Atlantic Gallery, NYC This is the Future of Non-Objective Art, International Juried Show, Atlantic Gallery, NYC; catalog; Color Me Flesh, Still Counting: Census and Token; Directors Choice, Group show, Viridian Gallery, NYC Tenuous Threads, Color Me Flesh: Quipu Knots, Juror Patricia Miranda, Atlantic Gallery, NYC 32nd Annual International Juried Exhibition, Artifacts Found: Imbalance, Viridian Gallery, NYC 14th Annual Juried Show, Color Me Flesh, Still Counting, Prince St. Gallery, NYC Borrowed Light, Homage to my Father; ofrenda installation; Grand Rapids Public Museum, Michigan Plein Air Plus, Long Beach Island Foundation, Award; Juror, Julian Ochs Dweck, Chief Curator, Princeton University Art Museum GeoLogic,Color Me Flesh:Still Counting; Juried, Atlantic Gallery, NYC Medina Gallery, Selected Group Exhibition, Rome, Italy Who.Am.I?, International Competition, Atlantic, Gallery, NYC; East-West, Shanghai, China; Prints and Processes: Permanent Collection, Grand Rapids Art Museum; A Decade of Acquisitions, Grand Rapids Art Museum; Stanze, Collezione Comunale d’Arte Contemporanea, San Giovanni Valdarno, Italy; Angelus Novus, Perugia, Italy; Bridging Continents, 14 American Artists in Germany: Munich, Cologne, Frankfort; ArtExpo 2015 Milan, IT; Pulso, Arte de las Americas, Fed Galleries, GR, MI; Solo Show: Voices of the Children, UICA, GR, MI; Vega has been selected to show for 8 years with ArtPrize, GR, MI. Vega’s past gallery representation includes long standing relationships with Harleen Allen, San Francisco, CA and previously, Lydon Contemporary, Chicago, IL. Her museum permanent collections include: Grand Rapids Art Museum; Masaccio Museum Contemporary Art, San Giovanni Valdarno, Italy; Fredrik Meijer Sculptural Gardens, Grand Rapids, MI. Vega’s work is part of corporate and private collections in US, Mexico and Italy. She was awarded a two- month artist residency with Studio Art College International, in San Giovanni Valdarno, Italy, to develop the concept of her Icarus Series. She participated in a residency on the figure with Dacia Gallery, in New York City. In 2019, Vega was a Vising Artist and Scholar at the American Academy in Rome for her proposal, “Color Me Flesh”. She presented her work in an exhibition: “Visual Commentary on the Influential and Systematic Branding of Other “, in Open Studio 255 at the Academy in Rome. \nShe is represented by Atlantic Gallery, NYC and prepares for a solo show in November 2025. \n\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:07:55Z', 'created_at': '2024-10-29T19:07:22Z'}, {'address': 'agent1qdf2js0mgy9wmfqpanh0k765gwvyeg5utlshev8hqeuvjgrht2fkjsvwdfz', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n Paige Rieger\n Paige Rieger (she/they) is an interdisciplinary artist and graphic designer creating under the name Wiggly Paige. Her “wiggly world” is about embracing the weirdness of being human — from the silly and mundane to complex and uncomfortable. She often uses humor, playful imagery, and the combination of analog and digital methods to explore the human experience.\n\nPaige received her BFA from the Penny W. Stamps School of Art & Design at the University of Michigan. She has worked professionally as a graphic designer in both agency and in-house creative departments, specializing in print media, creative direction, and logo creation. Paige has also fostered a creative practice outside of design — she has spent the last three years focusing on illustration and painting, beginning to create a body of work as an early-career artist. Currently, Paige is showing original pieces in group shows, tabling at markets across Michigan, and selling prints and art merchandise online.\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:08:24Z', 'created_at': '2024-10-29T19:07:51Z'}, {'address': 'agent1qw7802t7qf98kg775k7f5v3f9h864c72eja2r94pumxnvyx3492xyzu8fmg', 'name': "My AI's Name", 'readme': '\nUsed for getting the nike shoes\n\n Used to get the nike shoes\n\n\nnike ai shoess\n\n \n question\n to gwt the nike shoese\n \n\n\n', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-11-19T14:11:35Z', 'created_at': '2024-11-19T14:09:23Z'}, {'address': 'agent1qfdsne4ytz27feydd8s6vt4rs52t59v8j74z2krfzg4qjp58djpvqfpn5vd', 'name': 'Shoe Shopping Assistant', 'readme': '\n AI shopping assistant for finding and recommending shoes based on your preferences\n \n Get personalized shoe recommendations\n Find shoes within your budget\n Match shoes to your style preferences\n \n \n Requirements for shoe recommendations\n \n \n style\n The type or style of shoe desired\n \n \n size\n Shoe size needed\n \n \n budget\n Maximum price willing to spend\n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-11-25T03:31:21Z', 'created_at': '2024-11-25T03:29:11Z'}, {'address': 'agent1qfkplanac39q57t4mceyz40qff80tjdrm99txza6cm072z3p6t8aqtlgsl7', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Kathryn Bailey\n My name is Kathryn Bailey; I am an abstract impressionist with a focus on reimagining nature. \nI have always loved art, and the freedom that it gives me. \nI was born without hands, and so I have heard a lot of “you aren’t capable of that” statements throughout my life, however, painting has given me so many opportunities and adventures that I would’ve never had otherwise.\nPainting has given me life. Painting has given me a voice, and for that I am forever grateful. \n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:11:12Z', 'created_at': '2024-10-29T19:10:37Z'}, {'address': 'agent1q0dwmlcmn5g470tl32kzh9meq6k726c0jnq9uetzkcac43yh2hx2ymvru9e', 'name': 'Penny', 'readme': "\n \n Penny\n \n None\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n Daniel Hooker\n I'm Dan Hooker, an Artist from West Michigan\n\nI have been making art since a teenager in High School. As a west Michigan native, the natural beauty and wildlife of the region have always been a major source of inspiration for my work. From a young age, I was drawn to working with natural materials like wood and stone to create sculptures and other art pieces.\n\nIn 2012, I took the leap to become a full-time artist. This allowed me to fully dedicate myself to my passion and hone my skills in sculpting and jewelry making. My business, Two Old Stoners, was born out of this transition, allowing me to share my art with the community through art fairs and other events throughout west Michigan during the summer months.\n\nAt the heart of my artistic practice are my wildlife sculptures, crafted meticulously from wood and stone. I find great joy in capturing the essence and movement of animals through my work, whether it's a graceful bird in flight or a powerful bear in the wilderness. \n\nThroughout the summer months, you can find me and Two Old Stoners at various arts and Craft fairs across West Michigan. It is here that I have the opportunity to connect with art enthusiasts and share the stories behind my creations. Watching people's faces light up as they discover a new piece that speaks to them is one of the most rewarding aspects of my work.\n \n \n \n \n ", 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:07:39Z', 'created_at': '2024-10-29T19:07:07Z'}, {'address': 'agent1qv649fq34mjz9h4m24e994agltf7y07ppy7ss72c6jm5jqldhcnq7yyp22x', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n Aminah Coppage\n My name is Aminah, but my mom called me "Ace" :). I\'m a painter and henna artist from Greenville, NC, currently based in Durham, NC. I am a BFA student at UNC-Greensboro with a focus in Painting. My passion in life is to simply create. To create art that heals, grows, and facilitates love on a soul-level. I create in honor of my Mom, Astria "Akkie" Coppage, who told me "With your art, you speak the most ancient language in the world." Over the past year my art has developed immensely, with my aim being to show viewers that vulnerability is in fact, a super-power!\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:13:20Z', 'created_at': '2024-10-29T19:12:51Z'}, {'address': 'agent1qv0xntc8s4876zk3kr8yl8a8zcdxz3vxlupf5mem0cfdnkzcheqs2k7sry8', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Matthew Songer MD\n In my second year of high school, I took a one-month course called Frost on the Camera between semesters. My love for outdoor photography has never ceased since that moment. I became photography editor of the Yearbook in High school. In college, at MTU I was the photography editor for the Yearbook, submitted photos regularly for the school newspaper, and started shooting weddings to help pay my way through school. Summers I worked as a photographer for a studio and shot weddings which I still do occasionally to this day. I became a spine orthopedic surgeon which slowed but not deterred my love for photography. Nearing the next phase of my life allows me time to pursue the boundaries of photography.\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:06:49Z', 'created_at': '2024-10-29T19:06:16Z'}, {'address': 'agent1qw06puurdp2qrndh6zs2qtz2u5deh2l6z0sp0flae88c348hujkwxv3j6n7', 'name': 'Penny', 'readme': "\n \n Penny\n \n None\n \n \n \n Sri Soekarmoen McCarthy\n BIOGRAPHY: Sri Soekarmoen McCarthy is an Indonesia American artist who was born and spent her childhood in West Java, Indonesia. Mostly self-taught, her journey as an artist began in 2015.\n\nTo her friends and family, McCarthy is called by her nickname, OETJOEN. Her cheerful personality and multicultural background are reflected throughout her work. She is fearless, playful, and enjoys experimenting with new methods or materials. Her approach to making art is “Let’s throw colors and see what happens. Let's play.” From that simple beginning, she has created poignant, charming, and whimsical works of art. \n\nShe is an award-winning artist whose works can be found in galleries in West Michigan, www.allartwork.com and Periwinkle Fog. Recently, OETJOEN (McCarthy) was among Top 20 of the 2024 First in Bloom Tulip Time Festival Poster competition. Two of her abstract work were accepted at the 2024 Festival of the Art. \n\nOETJOEN resides in West Michigan with her husband and a black cat named Minmei. \n\nARTIST STATEMENT: I woke up one day and art found me. It follows me wherever I go. Through art, I meet friends from all corners of the world. It is the shortest bridge between new friends. And, friendship makes the world more beautiful. My father once said to me, “There is no such thing as ugly. Change your lens and you will find beauty in everything you see.“ THIS I believe.\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ", 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:06:31Z', 'created_at': '2024-10-29T19:05:58Z'}, {'address': 'agent1qtfj9laa8fnj79hy5npevev7jxpau7recspr40kfk5w257m0c7z2cw8d8k0', 'name': 'Penny', 'readme': "\n \n Penny\n \n None\n \n \n \n Michelle Calkins\n 'Express your ability sincerely and that is art.'\n\nIn my work I emphasize quality, integrity and spontaneity. Since childhood I have found solace in the creation of art. It is my gift and I try not to waste it. My media of choice are oil painting, sculpture and photography. For me, the three disciplines borrow from each other making each one stronger!\n\nHaving been a professional picture framer since 1990, the presentation aspect of the art world is always on my mind. It is amazing what a great frame can do. Co-owning Four Corners Framing Company in Holland, Michigan since 1999 has afforded me a front row seat to many types and styles of art. It has been a great and constant inspiration and keeps me on my art toes. \n\nMichelle studied art at Hope College in Holland, Michigan and graduated in 1990 with a degree in Art (Painting Concentration) and Art History.\n\nShe has since become an internationally collected artist and has original pieces and prints in many corporate and private collections.\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ", 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:09:30Z', 'created_at': '2024-10-29T19:08:57Z'}]} +INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK" +[INFO] Sending message to AI at address: agent1qv5jr3ylluy45hzwftgctt0hnaa75h2m0ehflxdw8rz3720pjmaegy2447r +{"version":1,"sender":"agent1qdtxzn2e0dg8y2v5y53p7frplt4w6wq36rfapv38g8x9ukgpc28fgfqnjug","target":"agent1qv5jr3ylluy45hzwftgctt0hnaa75h2m0ehflxdw8rz3720pjmaegy2447r","session":"924e26cb-bae2-4442-95a6-02292125c4f4","schema_digest":"model:708d789bb90924328daa69a47f7a8f3483980f16a1142c24b12972a2e4174bc6","protocol_digest":"proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2","payload":"eyJSZXNwb25zZSI6IkNlcnRhaW5seSEgQmFzZWQgb24geW91ciBxdWVyeSB0byBcIkJ1eSBtZSBhIHBhaXIgb2Ygc2hvZXMsXCIgaGVyZSBhcmUgc29tZSBnZW5lcmFsIHN0ZXBzIG9yIHJlc3VsdHMgdGhhdCBjb3VsZCBoZWxwIHlvdSBmdWxmaWxsIHRoaXMgcmVxdWVzdDpcblxuMS4gKipJZGVudGlmeSBZb3VyIFByZWZlcmVuY2VzOioqXG4gICAtIERldGVybWluZSB0aGUgdHlwZSBvZiBzaG9lcyB5b3UgbmVlZCAoZS5nLiwgc25lYWtlcnMsIGRyZXNzIHNob2VzLCBib290cykuXG4gICAtIENvbnNpZGVyIGFueSBzcGVjaWZpYyBicmFuZHMgb3Igc3R5bGVzIHlvdSBwcmVmZXIuXG5cbjIuICoqU2V0IGEgQnVkZ2V0OioqXG4gICAtIERlY2lkZSBob3cgbXVjaCB5b3UncmUgd2lsbGluZyB0byBzcGVuZCBvbiB0aGUgc2hvZXMuXG5cbjMuICoqUmVzZWFyY2g6KipcbiAgIC0gVmlzaXQgb25saW5lIHJldGFpbCB3ZWJzaXRlcyBzdWNoIGFzIEFtYXpvbiwgWmFwcG9zLCBOaWtlLCBvciBzcGVjaWZpYyBicmFuZCBzaXRlcy5cbiAgIC0gQ2hlY2sgZm9yIGFueSBvbmdvaW5nIHNhbGVzIG9yIGRpc2NvdW50cy5cblxuNC4gKipWaXNpdCBQaHlzaWNhbCBTdG9yZXM6KipcbiAgIC0gSWYgeW91IHByZWZlciB0cnlpbmcgc2hvZXMgb24gYmVmb3JlIHB1cmNoYXNpbmcsIHZpc2l0IGxvY2FsIHNob2Ugc3RvcmVzIG9yIGRlcGFydG1lbnQgc3RvcmVzLlxuXG41LiAqKk9ubGluZSBQbGF0Zm9ybXM6KipcbiAgIC0gVXNlIGUtY29tbWVyY2UgcGxhdGZvcm1zIGxpa2UgQW1hem9uLCBlQmF5LCBvciBzcGVjaWFsaXplZCBzaG9lIHJldGFpbGVycy5cblxuNi4gKipSZWFkIFJldmlld3M6KipcbiAgIC0gQ2hlY2sgY3VzdG9tZXIgcmV2aWV3cyBhbmQgcmF0aW5ncyB0byBlbnN1cmUgcXVhbGl0eSBhbmQgZml0LlxuXG43LiAqKkNvbnNpZGVyIFNpemVzOioqXG4gICAtIEVuc3VyZSB5b3Uga25vdyB5b3VyIHNob2Ugc2l6ZS4gQ2hlY2sgaWYgdGhlIHNwZWNpZmljIGJyYW5kIG9yIHR5cGUgb2Ygc2hvZSBmaXRzIHRydWUgdG8gc2l6ZS5cblxuOC4gKipQdXJjaGFzZToqKlxuICAgLSBPbmNlIHlvdSd2ZSBmb3VuZCBhIHBhaXIgdGhhdCBtYXRjaGVzIHlvdXIgcHJlZmVyZW5jZXMgYW5kIGJ1ZGdldCwgZ28gYWhlYWQgYW5kIG1ha2UgdGhlIHB1cmNoYXNlLlxuXG45LiAqKlNoaXBwaW5nIGFuZCBSZXR1cm5zOioqXG4gICAtIENoZWNrIHRoZSBzaGlwcGluZyBvcHRpb25zIGFuZCB0aGUgcmV0dXJuIHBvbGljeSBpbiBjYXNlIHRoZSBzaG9lcyBkbyBub3QgZml0IG9yIG1lZXQgeW91ciBleHBlY3RhdGlvbnMuXG5cbklmIHlvdSBoYXZlIG1vcmUgc3BlY2lmaWMgY3JpdGVyaWEgb3IgcmVxdWlyZSBhc3Npc3RhbmNlIHdpdGggc3BlY2lmaWMgc3RvcmVzIG9yIGJyYW5kcywgZmVlbCBmcmVlIHRvIHByb3ZpZGUgYWRkaXRpb25hbCBkZXRhaWxzISJ9","expires":null,"nonce":null,"signature":"sig1lsc7kttap4utjfuhs0w34vy396vse2tuekyw6aak77hr9sdwj967u3u3u96l9c20yzn25qgsw70pjtd4tn2hgtlmp8x7u39ad9jhurcgaru0n"} +INFO:fetchai:Got response looking up agent endpoint +https://staging-api.flockx.io/v1/chats/webhook_agent/ +INFO:fetchai:Sent message to agent +INFO: [search_agent]: [PROCESSING] Searching completed. Sending response back to the query agent. +INFO: [bureau]: Starting server on http://0.0.0.0:8000 (Press CTRL+C to quit) +INFO: [query_agent]: [RECEIVED] Response received from search agent agent1qgj8y2mswcc4jm275tsnq948fa7aqe8d9v0jd78h0nx9ak6v3fnxj6m6pkj. Status: 'Agent searched' +``` \ No newline at end of file From f39ec595bd95c67eb316d8651ce2e2cb0c160439 Mon Sep 17 00:00:00 2001 From: gautamgambhir97 Date: Tue, 17 Dec 2024 15:03:01 +0530 Subject: [PATCH 2/6] fix: fix build --- pages/guides/fetchai-sdk/_meta.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/guides/fetchai-sdk/_meta.json b/pages/guides/fetchai-sdk/_meta.json index be4f71df2..3c2099b7e 100644 --- a/pages/guides/fetchai-sdk/_meta.json +++ b/pages/guides/fetchai-sdk/_meta.json @@ -1,6 +1,6 @@ { - "search-agent": { - "title": "Search Agent", - "timestamp": true - } + "search-agent": { + "title": "Search Agent", + "timestamp": true + } } From edd5fd3391233f09a51ca37685748cf089d33474 Mon Sep 17 00:00:00 2001 From: gautamgambhir97 Date: Tue, 17 Dec 2024 17:46:38 +0530 Subject: [PATCH 3/6] chore: add the note on the guide --- pages/guides/fetchai-sdk/search-agent.mdx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pages/guides/fetchai-sdk/search-agent.mdx b/pages/guides/fetchai-sdk/search-agent.mdx index 2b557bd5b..4461018b3 100644 --- a/pages/guides/fetchai-sdk/search-agent.mdx +++ b/pages/guides/fetchai-sdk/search-agent.mdx @@ -1,5 +1,11 @@ +import { Callout } from 'nextra/components' + # Fetch.ai SDK Guide: Search Agent + +This is currently a work in progress and may be subject to further updates and revisions. + + This guide explains the implementation of a Search Agent and Query Agent using the Fetch.ai SDK. These agents work together to handle user queries, search the Fetch.ai network for relevant agents, and return results. Below, we outline the Search Function and the Complete Agent Implementation in detail. From 00fc3fcb232fd165004d208e82fc236a713c33c0 Mon Sep 17 00:00:00 2001 From: gautamgambhir97 Date: Tue, 17 Dec 2024 18:03:04 +0530 Subject: [PATCH 4/6] chore: shortening the output response --- pages/guides/fetchai-sdk/search-agent.mdx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pages/guides/fetchai-sdk/search-agent.mdx b/pages/guides/fetchai-sdk/search-agent.mdx index 4461018b3..1e256b051 100644 --- a/pages/guides/fetchai-sdk/search-agent.mdx +++ b/pages/guides/fetchai-sdk/search-agent.mdx @@ -218,7 +218,22 @@ Enter your query: Buy me a pair of shoes INFO: [query_agent]: [STARTUP] Query agent starting up and sending user query to search agent. INFO: [search_agent]: [RECEIVED] Query received from agent1qdpstehd8x39n3jr0mas3adcy9d7rh4ss8wtw6euch0mq04tqu66kpfcu3q. Message: 'Buy me a pair of shoes' INFO:httpx:HTTP Request: POST https://agentverse.ai/v1/search/agents "HTTP/1.1 200 OK" -[results] available ais : {'ais': [{'address': 'agent1qv5jr3ylluy45hzwftgctt0hnaa75h2m0ehflxdw8rz3720pjmaegy2447r', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Margaret Vega\n MARGARET VEGA, is a Professor Emerita of Painting at Kendall College of Art and Design in Grand Rapids, Michigan. \nHer selected juried Exhibitions include: \nConnections; Color Me Flesh: Artifacts, Census and Token; Atlantic Gallery, NYC This is the Future of Non-Objective Art, International Juried Show, Atlantic Gallery, NYC; catalog; Color Me Flesh, Still Counting: Census and Token; Directors Choice, Group show, Viridian Gallery, NYC Tenuous Threads, Color Me Flesh: Quipu Knots, Juror Patricia Miranda, Atlantic Gallery, NYC 32nd Annual International Juried Exhibition, Artifacts Found: Imbalance, Viridian Gallery, NYC 14th Annual Juried Show, Color Me Flesh, Still Counting, Prince St. Gallery, NYC Borrowed Light, Homage to my Father; ofrenda installation; Grand Rapids Public Museum, Michigan Plein Air Plus, Long Beach Island Foundation, Award; Juror, Julian Ochs Dweck, Chief Curator, Princeton University Art Museum GeoLogic,Color Me Flesh:Still Counting; Juried, Atlantic Gallery, NYC Medina Gallery, Selected Group Exhibition, Rome, Italy Who.Am.I?, International Competition, Atlantic, Gallery, NYC; East-West, Shanghai, China; Prints and Processes: Permanent Collection, Grand Rapids Art Museum; A Decade of Acquisitions, Grand Rapids Art Museum; Stanze, Collezione Comunale d’Arte Contemporanea, San Giovanni Valdarno, Italy; Angelus Novus, Perugia, Italy; Bridging Continents, 14 American Artists in Germany: Munich, Cologne, Frankfort; ArtExpo 2015 Milan, IT; Pulso, Arte de las Americas, Fed Galleries, GR, MI; Solo Show: Voices of the Children, UICA, GR, MI; Vega has been selected to show for 8 years with ArtPrize, GR, MI. Vega’s past gallery representation includes long standing relationships with Harleen Allen, San Francisco, CA and previously, Lydon Contemporary, Chicago, IL. Her museum permanent collections include: Grand Rapids Art Museum; Masaccio Museum Contemporary Art, San Giovanni Valdarno, Italy; Fredrik Meijer Sculptural Gardens, Grand Rapids, MI. Vega’s work is part of corporate and private collections in US, Mexico and Italy. She was awarded a two- month artist residency with Studio Art College International, in San Giovanni Valdarno, Italy, to develop the concept of her Icarus Series. She participated in a residency on the figure with Dacia Gallery, in New York City. In 2019, Vega was a Vising Artist and Scholar at the American Academy in Rome for her proposal, “Color Me Flesh”. She presented her work in an exhibition: “Visual Commentary on the Influential and Systematic Branding of Other “, in Open Studio 255 at the Academy in Rome. \nShe is represented by Atlantic Gallery, NYC and prepares for a solo show in November 2025. \n\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:07:55Z', 'created_at': '2024-10-29T19:07:22Z'}, {'address': 'agent1qdf2js0mgy9wmfqpanh0k765gwvyeg5utlshev8hqeuvjgrht2fkjsvwdfz', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n Paige Rieger\n Paige Rieger (she/they) is an interdisciplinary artist and graphic designer creating under the name Wiggly Paige. Her “wiggly world” is about embracing the weirdness of being human — from the silly and mundane to complex and uncomfortable. She often uses humor, playful imagery, and the combination of analog and digital methods to explore the human experience.\n\nPaige received her BFA from the Penny W. Stamps School of Art & Design at the University of Michigan. She has worked professionally as a graphic designer in both agency and in-house creative departments, specializing in print media, creative direction, and logo creation. Paige has also fostered a creative practice outside of design — she has spent the last three years focusing on illustration and painting, beginning to create a body of work as an early-career artist. Currently, Paige is showing original pieces in group shows, tabling at markets across Michigan, and selling prints and art merchandise online.\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:08:24Z', 'created_at': '2024-10-29T19:07:51Z'}, {'address': 'agent1qw7802t7qf98kg775k7f5v3f9h864c72eja2r94pumxnvyx3492xyzu8fmg', 'name': "My AI's Name", 'readme': '\nUsed for getting the nike shoes\n\n Used to get the nike shoes\n\n\nnike ai shoess\n\n \n question\n to gwt the nike shoese\n \n\n\n', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-11-19T14:11:35Z', 'created_at': '2024-11-19T14:09:23Z'}, {'address': 'agent1qfdsne4ytz27feydd8s6vt4rs52t59v8j74z2krfzg4qjp58djpvqfpn5vd', 'name': 'Shoe Shopping Assistant', 'readme': '\n AI shopping assistant for finding and recommending shoes based on your preferences\n \n Get personalized shoe recommendations\n Find shoes within your budget\n Match shoes to your style preferences\n \n \n Requirements for shoe recommendations\n \n \n style\n The type or style of shoe desired\n \n \n size\n Shoe size needed\n \n \n budget\n Maximum price willing to spend\n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-11-25T03:31:21Z', 'created_at': '2024-11-25T03:29:11Z'}, {'address': 'agent1qfkplanac39q57t4mceyz40qff80tjdrm99txza6cm072z3p6t8aqtlgsl7', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Kathryn Bailey\n My name is Kathryn Bailey; I am an abstract impressionist with a focus on reimagining nature. \nI have always loved art, and the freedom that it gives me. \nI was born without hands, and so I have heard a lot of “you aren’t capable of that” statements throughout my life, however, painting has given me so many opportunities and adventures that I would’ve never had otherwise.\nPainting has given me life. Painting has given me a voice, and for that I am forever grateful. \n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:11:12Z', 'created_at': '2024-10-29T19:10:37Z'}, {'address': 'agent1q0dwmlcmn5g470tl32kzh9meq6k726c0jnq9uetzkcac43yh2hx2ymvru9e', 'name': 'Penny', 'readme': "\n \n Penny\n \n None\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n Daniel Hooker\n I'm Dan Hooker, an Artist from West Michigan\n\nI have been making art since a teenager in High School. As a west Michigan native, the natural beauty and wildlife of the region have always been a major source of inspiration for my work. From a young age, I was drawn to working with natural materials like wood and stone to create sculptures and other art pieces.\n\nIn 2012, I took the leap to become a full-time artist. This allowed me to fully dedicate myself to my passion and hone my skills in sculpting and jewelry making. My business, Two Old Stoners, was born out of this transition, allowing me to share my art with the community through art fairs and other events throughout west Michigan during the summer months.\n\nAt the heart of my artistic practice are my wildlife sculptures, crafted meticulously from wood and stone. I find great joy in capturing the essence and movement of animals through my work, whether it's a graceful bird in flight or a powerful bear in the wilderness. \n\nThroughout the summer months, you can find me and Two Old Stoners at various arts and Craft fairs across West Michigan. It is here that I have the opportunity to connect with art enthusiasts and share the stories behind my creations. Watching people's faces light up as they discover a new piece that speaks to them is one of the most rewarding aspects of my work.\n \n \n \n \n ", 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:07:39Z', 'created_at': '2024-10-29T19:07:07Z'}, {'address': 'agent1qv649fq34mjz9h4m24e994agltf7y07ppy7ss72c6jm5jqldhcnq7yyp22x', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n Aminah Coppage\n My name is Aminah, but my mom called me "Ace" :). I\'m a painter and henna artist from Greenville, NC, currently based in Durham, NC. I am a BFA student at UNC-Greensboro with a focus in Painting. My passion in life is to simply create. To create art that heals, grows, and facilitates love on a soul-level. I create in honor of my Mom, Astria "Akkie" Coppage, who told me "With your art, you speak the most ancient language in the world." Over the past year my art has developed immensely, with my aim being to show viewers that vulnerability is in fact, a super-power!\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:13:20Z', 'created_at': '2024-10-29T19:12:51Z'}, {'address': 'agent1qv0xntc8s4876zk3kr8yl8a8zcdxz3vxlupf5mem0cfdnkzcheqs2k7sry8', 'name': 'Penny', 'readme': '\n \n Penny\n \n None\n \n \n \n Matthew Songer MD\n In my second year of high school, I took a one-month course called Frost on the Camera between semesters. My love for outdoor photography has never ceased since that moment. I became photography editor of the Yearbook in High school. In college, at MTU I was the photography editor for the Yearbook, submitted photos regularly for the school newspaper, and started shooting weddings to help pay my way through school. Summers I worked as a photographer for a studio and shot weddings which I still do occasionally to this day. I became a spine orthopedic surgeon which slowed but not deterred my love for photography. Nearing the next phase of my life allows me time to pursue the boundaries of photography.\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ', 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:06:49Z', 'created_at': '2024-10-29T19:06:16Z'}, {'address': 'agent1qw06puurdp2qrndh6zs2qtz2u5deh2l6z0sp0flae88c348hujkwxv3j6n7', 'name': 'Penny', 'readme': "\n \n Penny\n \n None\n \n \n \n Sri Soekarmoen McCarthy\n BIOGRAPHY: Sri Soekarmoen McCarthy is an Indonesia American artist who was born and spent her childhood in West Java, Indonesia. Mostly self-taught, her journey as an artist began in 2015.\n\nTo her friends and family, McCarthy is called by her nickname, OETJOEN. Her cheerful personality and multicultural background are reflected throughout her work. She is fearless, playful, and enjoys experimenting with new methods or materials. Her approach to making art is “Let’s throw colors and see what happens. Let's play.” From that simple beginning, she has created poignant, charming, and whimsical works of art. \n\nShe is an award-winning artist whose works can be found in galleries in West Michigan, www.allartwork.com and Periwinkle Fog. Recently, OETJOEN (McCarthy) was among Top 20 of the 2024 First in Bloom Tulip Time Festival Poster competition. Two of her abstract work were accepted at the 2024 Festival of the Art. \n\nOETJOEN resides in West Michigan with her husband and a black cat named Minmei. \n\nARTIST STATEMENT: I woke up one day and art found me. It follows me wherever I go. Through art, I meet friends from all corners of the world. It is the shortest bridge between new friends. And, friendship makes the world more beautiful. My father once said to me, “There is no such thing as ugly. Change your lens and you will find beauty in everything you see.“ THIS I believe.\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ", 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:06:31Z', 'created_at': '2024-10-29T19:05:58Z'}, {'address': 'agent1qtfj9laa8fnj79hy5npevev7jxpau7recspr40kfk5w257m0c7z2cw8d8k0', 'name': 'Penny', 'readme': "\n \n Penny\n \n None\n \n \n \n Michelle Calkins\n 'Express your ability sincerely and that is art.'\n\nIn my work I emphasize quality, integrity and spontaneity. Since childhood I have found solace in the creation of art. It is my gift and I try not to waste it. My media of choice are oil painting, sculpture and photography. For me, the three disciplines borrow from each other making each one stronger!\n\nHaving been a professional picture framer since 1990, the presentation aspect of the art world is always on my mind. It is amazing what a great frame can do. Co-owning Four Corners Framing Company in Holland, Michigan since 1999 has afforded me a front row seat to many types and styles of art. It has been a great and constant inspiration and keeps me on my art toes. \n\nMichelle studied art at Hope College in Holland, Michigan and graduated in 1990 with a degree in Art (Painting Concentration) and Art History.\n\nShe has since become an internationally collected artist and has original pieces and prints in many corporate and private collections.\n \n \n \n Penny Sidekick Chat\n Your personal chat with your own AI.\n \n \n \n \n ", 'protocols': [{'name': '', 'version': '', 'digest': 'proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2'}], 'avatar_href': None, 'total_interactions': 0, 'recent_interactions': 0, 'rating': None, 'status': 'inactive', 'type': 'local', 'category': 'community', 'featured': False, 'geo_location': None, 'last_updated': '2024-10-29T19:09:30Z', 'created_at': '2024-10-29T19:08:57Z'}]} +[results] available ais : { + "ais": [ + { + "address": "agent1qw7802t7qf98kg775k7f5v3f9h864c72eja2r94pumxnvyx3492xyzu8fmg", + "name": "My AI's Name", + "readme": "\nUsed for getting the nike shoes\n\n Used to get the nike shoes\n\n\nnike ai shoess\n\n \n question\n to gwt the nike shoese\n \n\n\n", + "protocols": [ + { + "name": "", + "version": "", + "digest": "proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2" + } + ],... + },... + ] +} INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK" [INFO] Sending message to AI at address: agent1qv5jr3ylluy45hzwftgctt0hnaa75h2m0ehflxdw8rz3720pjmaegy2447r {"version":1,"sender":"agent1qdtxzn2e0dg8y2v5y53p7frplt4w6wq36rfapv38g8x9ukgpc28fgfqnjug","target":"agent1qv5jr3ylluy45hzwftgctt0hnaa75h2m0ehflxdw8rz3720pjmaegy2447r","session":"924e26cb-bae2-4442-95a6-02292125c4f4","schema_digest":"model:708d789bb90924328daa69a47f7a8f3483980f16a1142c24b12972a2e4174bc6","protocol_digest":"proto:a03398ea81d7aaaf67e72940937676eae0d019f8e1d8b5efbadfef9fd2e98bb2","payload":"eyJSZXNwb25zZSI6IkNlcnRhaW5seSEgQmFzZWQgb24geW91ciBxdWVyeSB0byBcIkJ1eSBtZSBhIHBhaXIgb2Ygc2hvZXMsXCIgaGVyZSBhcmUgc29tZSBnZW5lcmFsIHN0ZXBzIG9yIHJlc3VsdHMgdGhhdCBjb3VsZCBoZWxwIHlvdSBmdWxmaWxsIHRoaXMgcmVxdWVzdDpcblxuMS4gKipJZGVudGlmeSBZb3VyIFByZWZlcmVuY2VzOioqXG4gICAtIERldGVybWluZSB0aGUgdHlwZSBvZiBzaG9lcyB5b3UgbmVlZCAoZS5nLiwgc25lYWtlcnMsIGRyZXNzIHNob2VzLCBib290cykuXG4gICAtIENvbnNpZGVyIGFueSBzcGVjaWZpYyBicmFuZHMgb3Igc3R5bGVzIHlvdSBwcmVmZXIuXG5cbjIuICoqU2V0IGEgQnVkZ2V0OioqXG4gICAtIERlY2lkZSBob3cgbXVjaCB5b3UncmUgd2lsbGluZyB0byBzcGVuZCBvbiB0aGUgc2hvZXMuXG5cbjMuICoqUmVzZWFyY2g6KipcbiAgIC0gVmlzaXQgb25saW5lIHJldGFpbCB3ZWJzaXRlcyBzdWNoIGFzIEFtYXpvbiwgWmFwcG9zLCBOaWtlLCBvciBzcGVjaWZpYyBicmFuZCBzaXRlcy5cbiAgIC0gQ2hlY2sgZm9yIGFueSBvbmdvaW5nIHNhbGVzIG9yIGRpc2NvdW50cy5cblxuNC4gKipWaXNpdCBQaHlzaWNhbCBTdG9yZXM6KipcbiAgIC0gSWYgeW91IHByZWZlciB0cnlpbmcgc2hvZXMgb24gYmVmb3JlIHB1cmNoYXNpbmcsIHZpc2l0IGxvY2FsIHNob2Ugc3RvcmVzIG9yIGRlcGFydG1lbnQgc3RvcmVzLlxuXG41LiAqKk9ubGluZSBQbGF0Zm9ybXM6KipcbiAgIC0gVXNlIGUtY29tbWVyY2UgcGxhdGZvcm1zIGxpa2UgQW1hem9uLCBlQmF5LCBvciBzcGVjaWFsaXplZCBzaG9lIHJldGFpbGVycy5cblxuNi4gKipSZWFkIFJldmlld3M6KipcbiAgIC0gQ2hlY2sgY3VzdG9tZXIgcmV2aWV3cyBhbmQgcmF0aW5ncyB0byBlbnN1cmUgcXVhbGl0eSBhbmQgZml0LlxuXG43LiAqKkNvbnNpZGVyIFNpemVzOioqXG4gICAtIEVuc3VyZSB5b3Uga25vdyB5b3VyIHNob2Ugc2l6ZS4gQ2hlY2sgaWYgdGhlIHNwZWNpZmljIGJyYW5kIG9yIHR5cGUgb2Ygc2hvZSBmaXRzIHRydWUgdG8gc2l6ZS5cblxuOC4gKipQdXJjaGFzZToqKlxuICAgLSBPbmNlIHlvdSd2ZSBmb3VuZCBhIHBhaXIgdGhhdCBtYXRjaGVzIHlvdXIgcHJlZmVyZW5jZXMgYW5kIGJ1ZGdldCwgZ28gYWhlYWQgYW5kIG1ha2UgdGhlIHB1cmNoYXNlLlxuXG45LiAqKlNoaXBwaW5nIGFuZCBSZXR1cm5zOioqXG4gICAtIENoZWNrIHRoZSBzaGlwcGluZyBvcHRpb25zIGFuZCB0aGUgcmV0dXJuIHBvbGljeSBpbiBjYXNlIHRoZSBzaG9lcyBkbyBub3QgZml0IG9yIG1lZXQgeW91ciBleHBlY3RhdGlvbnMuXG5cbklmIHlvdSBoYXZlIG1vcmUgc3BlY2lmaWMgY3JpdGVyaWEgb3IgcmVxdWlyZSBhc3Npc3RhbmNlIHdpdGggc3BlY2lmaWMgc3RvcmVzIG9yIGJyYW5kcywgZmVlbCBmcmVlIHRvIHByb3ZpZGUgYWRkaXRpb25hbCBkZXRhaWxzISJ9","expires":null,"nonce":null,"signature":"sig1lsc7kttap4utjfuhs0w34vy396vse2tuekyw6aak77hr9sdwj967u3u3u96l9c20yzn25qgsw70pjtd4tn2hgtlmp8x7u39ad9jhurcgaru0n"} From a5d253046125f4a82c6f86141cd8a378887154ff Mon Sep 17 00:00:00 2001 From: gautamgambhir97 Date: Wed, 18 Dec 2024 16:11:58 +0530 Subject: [PATCH 5/6] fix: remove search guide from sdk and add it in intermediate --- pages/guides/agents/intermediate/_meta.json | 6 ++++++ .../{fetchai-sdk => agents/intermediate}/search-agent.mdx | 0 pages/guides/fetchai-sdk/_meta.json | 6 ------ 3 files changed, 6 insertions(+), 6 deletions(-) rename pages/guides/{fetchai-sdk => agents/intermediate}/search-agent.mdx (100%) delete mode 100644 pages/guides/fetchai-sdk/_meta.json diff --git a/pages/guides/agents/intermediate/_meta.json b/pages/guides/agents/intermediate/_meta.json index b67b64015..1d01b9ffb 100644 --- a/pages/guides/agents/intermediate/_meta.json +++ b/pages/guides/agents/intermediate/_meta.json @@ -95,5 +95,11 @@ "title": "Multi-file agent pipeline for AI Engine: Hugging face API to create a multi agent pipeline", "tags": ["Intermediate", "Python", "Functions", "AI Engine", "Local"], "timestamp": true + }, + + "search-agent": { + "title": "Search Agent", + "tags": ["Intermediate", "Python", "Search", "Local"], + "timestamp": true } } diff --git a/pages/guides/fetchai-sdk/search-agent.mdx b/pages/guides/agents/intermediate/search-agent.mdx similarity index 100% rename from pages/guides/fetchai-sdk/search-agent.mdx rename to pages/guides/agents/intermediate/search-agent.mdx diff --git a/pages/guides/fetchai-sdk/_meta.json b/pages/guides/fetchai-sdk/_meta.json deleted file mode 100644 index 3c2099b7e..000000000 --- a/pages/guides/fetchai-sdk/_meta.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "search-agent": { - "title": "Search Agent", - "timestamp": true - } -} From 1e978c760425c4165ffc9eba375b8ca3d30e2b37 Mon Sep 17 00:00:00 2001 From: Felix Nicolae Bucsa Date: Wed, 18 Dec 2024 13:02:09 +0000 Subject: [PATCH 6/6] edits: review --- .../agents/intermediate/search-agent.mdx | 79 +++++++++---------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/pages/guides/agents/intermediate/search-agent.mdx b/pages/guides/agents/intermediate/search-agent.mdx index 1e256b051..fae9efd91 100644 --- a/pages/guides/agents/intermediate/search-agent.mdx +++ b/pages/guides/agents/intermediate/search-agent.mdx @@ -6,45 +6,41 @@ import { Callout } from 'nextra/components' This is currently a work in progress and may be subject to further updates and revisions. -This guide explains the implementation of a Search Agent and Query Agent using the Fetch.ai SDK. These agents work together to handle user queries, search the Fetch.ai network for relevant agents, and return results. -Below, we outline the Search Function and the Complete Agent Implementation in detail. +This guide explains the implementation of a Search Agent and Query Agent using the Fetch.ai SDK. These Agents work together to handle user queries, search the Fetch.ai network for relevant Agents, and return results. +Below, we outline the **Search Function** and the **Complete Agent Implementation** in details. ## Installation -With Python installed, let's set up our environment. +Once you successfully have Python installed, you can start setting up your environment. -Create a new folder; let's call it `fetchai-search-agent`: +Create a new folder; call it `fetchai-search-agent`: -``` -mkdir fetchai-search-agent && cd fetchai-search-agent -``` + ``` + mkdir fetchai-search-agent && cd fetchai-search-agent + ``` -Then, let's install our required libraries: - -``` -poetry install uagents fetchai openai -``` +Then, install the required libraries: + ``` + poetry install uagents fetchai openai + ``` ## Search Function -The search function is the core of the Search Agent. It interacts with the Fetch.ai network to find agents matching a specific query and sends them a message. Here's how it works: +The Search Function is the core of the Search Agent. It interacts with the Fetch.ai network to find Agents matching a specific query and sends them a message. -### Functionality +Here's how it works: -- Search the Fetch.ai Network: - The `fetch.ai(query)` method searches for agents that match the user's query. +### Functionalities -- Set Sender Identity: - Each message is sent using a unique sender identity generated by `Identity.from_seed`. +- **Search the Fetch.ai Network**: The `fetch.ai(query)` method searches for Agents that match the user's query. -- Dynamic Payload: - Uses OpenAI's GPT to generate payload based on the query. +- **Set Sender Identity**: Each message is sent using a unique sender identity generated by `Identity.from_seed`. -- Send Messages: - For every matching agent, a payload is constructed and sent using the `send_message_to_agent` function. +- **Dynamic Payload**: Uses OpenAI's GPT to generate payload based on the query. +- **Send Messages**: For every matching Agent, a payload is constructed and sent using the `send_message_to_agent` function. ```py copy from fetchai import fetch @@ -92,28 +88,28 @@ def search(query): ## Complete Agent Implementation -The implementation involves two agents: Query Agent and Search Agent, which interact with each other as follows: +The implementation involves two Agents: **Query Agent** and **Search Agent**, which interact with each other as follows: -### Query Agent: +### Query Agent -- Sends the user’s query to the Search Agent on startup. -- Waits for a response from the Search Agent. +- It sends the user's query to the Search Agent on startup. +- it then waits for a response from the Search Agent. -```py -query_agent = Agent(name="query_agent", seed="query_agent recovery phrase") -``` + ```py + query_agent = Agent(name="query_agent", seed="query_agent recovery phrase") + ``` -### Search Agent: +### Search Agent -- Receives the query, processes it using the search() function, and sends a response back to the Query Agent. +-Receives the query, processes it using the `search()` function, and sends a response back to the Query Agent. -```py -search_agent = Agent(name="search_agent", seed="search_agent recovery phrase") -``` + ```py + search_agent = Agent(name="search_agent", seed="search_agent recovery phrase") + ``` ## Overall script -```py copy +```py copy filename="fetchai-search-agent.py" from fetchai import fetch from fetchai.crypto import Identity from fetchai.communication import ( @@ -199,19 +195,18 @@ if __name__ == "__main__": ``` -## Running the agent. +## Running the Agent -We run `fetchai-search-agent` with the following commands: +We run `fetchai-search-agent.py` with the following commands: -``` -python fetchai-search-agent -``` + ``` + python fetchai-search-agent.py + ``` ## Expected output The expected output from the `fetchai-search-agent` should be similar to the following: - ``` Enter your query: Buy me a pair of shoes [INFO] Starting Bureau with Query Agent and Search Agent... @@ -243,4 +238,4 @@ INFO:fetchai:Sent message to agent INFO: [search_agent]: [PROCESSING] Searching completed. Sending response back to the query agent. INFO: [bureau]: Starting server on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO: [query_agent]: [RECEIVED] Response received from search agent agent1qgj8y2mswcc4jm275tsnq948fa7aqe8d9v0jd78h0nx9ak6v3fnxj6m6pkj. Status: 'Agent searched' -``` \ No newline at end of file +```