Optimising Data retrieval with Serper API and Large Language Models - Example Accessing OSPF RFC Information
Disclaimer: All Writings And Opinions Are My Own And Are Interpreted Solely From My Understanding. Please Contact The Concerned Support Teams For A Professional Opinion, As Technology And Features Change Rapidly.
This series of blog posts will focus on one feature at a time to simplify understanding.
At this point, ChatGPT—or any Large Language Model (LLM)—needs no introduction. I’ve been exploring GPTs with relative success, and I’ve found that API interaction makes them even more effective.
But how can we turn this into a workflow, even a simple one? What are our use cases and advantages? For simplicity, we’ll use the OpenAI API rather than open-source, self-hosted LLMs like Meta’s Llama.
Let’s consider an example: searching for all OSPF-related RFCs on the web. Technically, we’ll use a popular search engine, but to do this programmatically, I’ll use Serper. You can find more details at https://serper.dev. Serper is a powerful search API that allows developers to programmatically access search engine results. It provides a simple interface to retrieve structured data from search queries, making it easier to integrate search functionality into applications and workflows.
Let’s build the first building block and try to fetch results using Serper. When you sign up, you’ll get free credits to try it out, so feel free to sign up and use it across your projects.
import requests
import json
url = "https://google.serper.dev/search"
payload = json.dumps({
"q": "OSPF RFCs from site rfc-editor.org"
})
headers = {
'X-API-KEY': 'xx',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Response
{
"searchParameters": {
"q": "OSPF RFCs from site rfc-editor.org",
"type": "search",
"engine": "google"
},
"organic": [
{
"title": "RFC 2328: OSPF Version 2",
"link": "https://www.rfc-editor.org/rfc/rfc2328",
"snippet": "This memo documents version 2 of the OSPF protocol. OSPF is a link-state routing protocol. It is designed to be run internal to a single Autonomous System.",
"position": 1
},
{
"title": "Information on RFC 2328",
"link": "https://www.rfc-editor.org/info/rfc2328",
"snippet": "This memo documents version 2 of the OSPF protocol. OSPF is a link- state routing protocol. [STANDARDS-TRACK] For the definition of Status, see RFC 2026.",
"position": 2
},
{
"title": "Information on RFC 2178 - ? RFC Editor",
"link": "https://www.rfc-editor.org/info/rfc2178",
"snippet": "This memo documents version 2 of the OSPF protocol. OSPF is a link-state routing protocol. It is designed to be run internal to a single Autonomous System.",
"position": 3
},
{
"title": "RFC 5340: OSPF for IPv6",
"link": "https://www.rfc-editor.org/rfc/rfc5340.html",
"snippet": "This document describes the modifications to OSPF to support version 6 of the Internet Protocol (IPv6).",
"position": 4
},
Now, we need a framework to process this data and determine the next steps. One example of such a framework is crew.ai.
Crew.ai is an open-source Python framework for creating collaborative AI agents to tackle complex tasks. It offers developers a versatile and robust platform for building and managing multi-agent systems, harnessing the power of large language models.
Using Crew.ai, you can design specialized AI agents, assign them specific roles, and establish workflows for them to follow. This framework facilitates the development of advanced AI applications capable of handling a wide array of tasks, ranging from data analysis to innovative problem-solving.
While I’ll explore the crew.ai structure in depth in a future post, let’s focus now on its capabilities and how it can be used to process data.
(crewaiproject) ubuntu@llama:~/crewaiproject/rfcfetcher$ crewai run
Running the crew
[2024-09-07 15:55:35][DEBUG]: == Working Agent: OSPF RFCs Senior Data Researcher
[2024-09-07 15:55:35][INFO]: == Starting Task: Conduct a search for any RFC from rfc-editor.org and programmatically parse the table of contents (TOC). Ensure that each subsection and title are included accurately.
> Entering new CrewAgentExecutor chain...
To accomplish the task, I need to search for OSPF RFCs on rfc-editor.org and then programmatically parse the table of contents (TOC) for each RFC. I will start by searching for OSPF RFCs on rfc-editor.org to gather the relevant URLs.
Action: Search the internet
Action Input: {"search_query": "OSPF RFC site:rfc-editor.org"}
^ above action will use serper.dev functionality to get the information and
this will be passed to OPENAI llm to organise this information
Sample redacted output
RFC Number - RFC 4750
Title - OSPF Version 2 Management Information Base
URL - [https://www.rfc-editor.org/rfc/rfc4750](https://www.rfc-editor.org/rfc/rfc4750)
Subsections:
- 1. Introduction
- 2. The SNMP Network Management Framework
- 3. Overview
- 4. Definitions
- 5. Object Definitions
- 6. Security Considerations
- 7. Acknowledgments
- 8. References
RFC Number - RFC 5613
Title - OSPF Link-Local Signaling
URL - [https://www.rfc-editor.org/rfc/rfc5613](https://www.rfc-editor.org/rfc/rfc5613)
Subsections:
- 1. Introduction
- 2. OSPF Link-Local Signaling Overview
- 3. OSPF LLS Data Block
- 4. LLS TLVs
- 5. Backward Compatibility
- 6. Security Considerations
- 7. IANA Considerations
- 8. Acknowledgments
- 9. References
Building workflows towards agentic workflows enables better organization of information, faster retrieval, and less need to memorize it. I’ll delve into building this in the next post.
-Rakesh
Co-Founder of Altrosyn and DIrector at CDTECH | Inventor | Manufacturer
1 个月The intersection of structured data like RFCs and the generative capabilities of LLMs presents fascinating possibilities. Automating access to this technical documentation through APIs like Serper can significantly enhance research workflows, particularly in fields reliant on network protocols. However, how do you envision bridging the gap between the factual nature of RFCs and the creative potential of LLMs for tasks like generating novel network configurations or troubleshooting scenarios?