Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add linkup API #295

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions edenai_apis/api_keys/linkup_settings_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"api_key": ""
}
1 change: 1 addition & 0 deletions edenai_apis/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .ibm import IbmApi
from .jina import JinaApi
from .klippa import KlippaApi
from .linkup import LinkupApi
from .leonardo import LeonardoApi
from .lovoai import LovoaiApi
from .meaningcloud import MeaningcloudApi
Expand Down
1 change: 1 addition & 0 deletions edenai_apis/apis/linkup/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .linkup_api import LinkupApi
11 changes: 11 additions & 0 deletions edenai_apis/apis/linkup/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"text": {
"search": {
"version": "v1.0",
"constraints": {
"depth": ["standard", "deep"],
"outputType": ["searchResults", "sourcedAnswer"]
}
}
}
}
18 changes: 18 additions & 0 deletions edenai_apis/apis/linkup/linkup_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from edenai_apis.features.provider.provider_interface import ProviderInterface
from edenai_apis.loaders.loaders import load_provider, ProviderDataEnum
from linkup import LinkupClient
from typing import Dict
from edenai_apis.apis.linkup.linkup_search import LinkupSearch
from edenai_apis.apis.linkup.linkup_source import LinkupSource


class LinkupApi(ProviderInterface, LinkupSearch, LinkupSource):


provider_name = "linkup"

def __init__(self, api_keys: Dict = {}):
self.api_settings = load_provider(
ProviderDataEnum.KEY, self.provider_name, api_keys=api_keys
)
self.client = LinkupClient(api_key=self.api_settings["api_key"])
29 changes: 29 additions & 0 deletions edenai_apis/apis/linkup/linkup_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from edenai_apis.utils.exception import ProviderException
from linkup import LinkupClient
from typing import Optional, List


class LinkupSearch:


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary empty lines.

def __init__(self):
self.client = LinkupClient()

def text__search(
self,
query: str,
depth: str="deep",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not have a default value.

model: Optional[str] = None,
texts: Optional[List[str]] = None,
similarity_metric: str= "cosine"
):
try:
payload = {
"query": query,
"depth": depth,
"output_type": "searchResults",
}
return self.client.search(**payload)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace this with

return self.client.search({
  "query": query,
  "depth": depth,
  "output_type": "searchResults",
})

except Exception as e:
print("DEBUG - Exception occurred:", str(e))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably remove this debug print.

raise ProviderException(f"Error during Linkup API call: {str(e)}")
31 changes: 31 additions & 0 deletions edenai_apis/apis/linkup/linkup_source.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this file to linkup_answer.py

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from edenai_apis.utils.exception import ProviderException
from linkup import LinkupClient
from typing import Optional, List


class LinkupSource:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this class LinkupAnswer



Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unecessary empty lines

def __init__(self):
self.client = LinkupClient()

def text__question_answer(
self,
query: str,
depth: str="",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this default value really necessary?

examples_context: Optional[str] = None,
examples: Optional[List[List[str]]] = None,
model: Optional[str] = None,
texts: Optional[List[str]] = None,
similarity_metric: Optional[str] = None,
):
try:
payload = {
"query": query,
"depth": depth,
"output_type": "sourcedAnswer",
}
return self.client.search(**payload)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace this with

return self.client.search({
  "query": query,
  "depth": depth,
  "output_type": "sourcedAnswer",
})

except Exception as e:
print("DEBUG - Exception occurred:", str(e))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably remove this debug print.

raise ProviderException(f"Error during Linkup API call: {str(e)}")
124 changes: 124 additions & 0 deletions edenai_apis/apis/linkup/outputs/text/search_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"results": [
{
"type": "text",
"name": "Rome in the square for LGBTQ+ rights: the fight continues",
"url": "https://www.notizie.it/en/rome-in-the-square-for-lbtq-rights-the-fight-continues/",
"content": "Le associazioni che operano a sostegno della comunit\u00e0 Lbtq+ a Roma hanno nuovamente preso posizione, scendendo in piazza per denunciare le violenze subite dai membri di questa comunit\u00e0. L\u2019ultimo episo"
},
{
"type": "text",
"name": "ITA Airways Rome-Tel Aviv flights return in February",
"url": "https://www.ansa.it/english/news/business/2025/01/20/ita-airways-rome-tel-aviv-flights-return-in-february_469157a5-96e6-48b1-b9fc-6bfa907d148b.html",
"content": "ITA Airways said Monday that it will resume flights between Rome's Fiumicino and Tel Aviv's Ben Gurion airports from February 1 after the ceasefire in Gaza came into force. (ANSA)"
},
{
"type": "text",
"name": "Police officers attacked during drug sweep in Rome",
"url": "https://www.ansa.it/english/news/2025/01/17/police-officers-attacked-during-drug-sweep-in-rome_010ecfda-5800-4b66-9e4a-45d8fda80687.html",
"content": "Some Italian police officers were attacked Thursday during a drug sweep in Quarticciolo, on the outskirts of Rome, police said Friday. (ANSA)"
},
{
"type": "text",
"name": "L\u2019American Academy in Rome organizza una residenza per curatori",
"url": "https://www.corrierenazionale.it/2025/01/19/lamerican-academy-in-rome-organizza-una-residenza-per-curatori/",
"content": "L\u2019American Academy in Rome organizza per la primavera 2025 una residenza destinata a curatori e curatrici italiani per una ricerca dedicata all\u2019arte italiana contemporanea."
},
{
"type": "text",
"name": "Get Ready, l'allenamento per Run Rome The Marathon \u00e8 spettacolo all'Olimpico",
"url": "https://www.tuttosport.com/news/altri-sport/running/2025/01/13-137476664/get_ready_l_allenamento_per_run_rome_the_marathon_spettacolo_all_olimpico",
"content": "Un altro record per la maratona di Roma che sabato ha fatto correre gratuitamente 650 persone nell\u2019allenamento di gruppo ufficiale che \u00e8 andato in scena al Foro Italico, Olimpico e Stadio dei Marmi"
},
{
"type": "text",
"name": "Corinthia Rome \u2013 Roma",
"url": "https://www.ilsole24ore.com/art/corinthia-rome-roma-AGXslCEC",
"content": "Sempre in estate \u00e8 prevista l\u2019apertura del Corinthia Rome, che sorger\u00e0 nella ex sede della Banca d\u2019Italia lungo via Nazionale, a pochi passi dal"
},
{
"type": "text",
"name": "Castello Sgr: il Leonardo Boutique Hotel Rome Monti nel portfolio Borgia Fund",
"url": "https://www.guidaviaggi.it/2025/01/16/leonardo-boutique-hotel-rome-monti-portfolio-borgia-fund/",
"content": "Castello Sgr si rafforza nell\u2019hotellerie a Roma. Leonardo Boutique Hotel Rome Monti nel portfolio di Borgia Fund con il brand Leonardo Hotels"
},
{
"type": "text",
"name": "Technical Glitch Slows Rome-Naples Line",
"url": "https://www.ilmattino.it/en/technical_glitch_slows_rome_naples_line-8599127.html",
"content": "On the Rome-Naples High-Speed Line towards Naples, rail traffic remains slowed since 6 this morning near Cassino due to a technical issue on the line. Effects on rail mobility: delays of up to"
},
{
"type": "text",
"name": "Italo-turca, Burcin \u00e8 la nuova protagonista di Rome is Woman",
"url": "https://www.corrieredellosport.it/news/altri-sport/running/maratona-di-roma/2025/01/15-137533613/italo-turca_burcin_la_nuova_protagonista_di_rome_is_woman",
"content": "Burcin vive a Roma e corre le maratone nonostante i tanti impegni e due figli. Come fa? Passione e organizzazione. E un sogno, quello di correre la Run Rome The"
},
{
"type": "text",
"name": "Serie B2 Women. \"Peri\", trip to Rome. High-risk match",
"url": "https://sport.quotidiano.net/en/locale/volley/serie-b2-femminile-peri-viaggio-a7a08ca2",
"content": "Trasferta ostica per la Volleyball Grosseto Giorgio Peri impegnata in casa della Fenice Roma. Dopo la vittoria nel recupero infrasettimanale, la quinta di fila per il team di Reddish Red, oggi alle 16"
},
{
"type": "text",
"name": "Rome - Wikipedia",
"url": "https://en.wikipedia.org/wiki/Rome",
"content": "Rome (Italian and Latin: Roma, pronounced \u24d8) is the capital city of Italy.It is also the capital of the Lazio region, the centre of the Metropolitan City of Rome Capital, and a special comune (municipality) named Comune di Roma Capitale.With 2,860,009 residents in 1,285 km 2 (496.1 sq mi), [2] Rome is the country's most populated comune and the third most populous city in the European Union ..."
},
{
"type": "text",
"name": "Roma - Wikipedia",
"url": "https://it.wikipedia.org/wiki/Roma",
"content": "Roma (AFI: /\u02c8roma/, [6] pronuncia \u24d8) \u00e8 la capitale della Repubblica Italiana. \u00c8 il capoluogo dell'omonima citt\u00e0 metropolitana e della regione Lazio.Il comune di Roma \u00e8 dotato di un ordinamento amministrativo speciale, denominato Roma Capitale e disciplinato dalla legge dello Stato. [7]Con 2 748 641 abitanti, [3] \u00e8 il comune pi\u00f9 popoloso d'Italia e il terzo dell'Unione europea dopo ..."
},
{
"type": "text",
"name": "Rome in a nutshell - Turismo Roma",
"url": "https://www.turismoroma.it/en/page/rome-nutshell",
"content": "Heart of Catholic Christianity, Rome is the only city in the world to host a foreign state, the enclave of the Vatican City: for this reason, it is often referred to as the \"Capital of two States.\" The 5 most visited monuments in Rome. They are unmissable and, absolutely, you cannot miss them during your first visit to the Eternal City. The ..."
},
{
"type": "text",
"name": "Rome, the eternal city: discovering the capital - Italia.it",
"url": "https://www.italia.it/en/lazio/rome/guide-history-facts",
"content": "Discover what to see in Rome, the city of Colosseum and Sistine Chapel. Find on Italia.it new ideas for your holidays in Italy."
},
{
"type": "text",
"name": "Rome Tourism and Travel Guide - Visitors Travel Guide",
"url": "https://www.rome.net/",
"content": "Travel guide of Rome with up to date tourist and general information on the city: accommodation, transport, maps, activities and top attractions."
},
{
"type": "text",
"name": "Things to Do in Rome - Top Attractions in Rome - Rome Tourism and ...",
"url": "https://www.rome.net/attractions",
"content": "Rome is a city full of history and offers countless things to see and do including museums, monuments and parks. Discover Rome's most popular attractions."
},
{
"type": "text",
"name": "Rome: Attractions to see & Things to do - Italia.it",
"url": "https://www.italia.it/en/lazio/rome",
"content": "Rome is wonderful and its surroundings are just as unique. Latium boasts an endless number of natural beauties and a broad range of cultural experiences. It is home to historic sites ideal for excursions and out-of-town trips starting from the Eternal City."
},
{
"type": "text",
"name": "Rome, Italy: All You Must Know Before You Go (2025) - Tripadvisor",
"url": "https://www.tripadvisor.com/Tourism-g187791-Rome_Lazio-Vacations.html",
"content": "Rome Tourism: Tripadvisor has 5,646,134 reviews of Rome Hotels, Attractions, and Restaurants making it your best Rome resource."
},
{
"type": "text",
"name": "THE 15 BEST Things to Do in Rome (2025) - Must-See Attractions",
"url": "https://www.tripadvisor.com/Attractions-g187791-Activities-Rome_Lazio.html",
"content": "Things to Do in Rome, Italy: See Tripadvisor's 5,646,134 traveler reviews and photos of Rome tourist attractions. Find what to do today, this weekend, or in January. We have reviews of the best places to see in Rome. Visit top-rated & must-see attractions."
},
{
"type": "text",
"name": "Sito turistico ufficiale - Turismo Roma",
"url": "https://www.turismoroma.it/en",
"content": "Countless exhibitions in Rome in public and private galleries, exhibition spaces and outdoor settings. Music Stadiums, auditoriums and churches: in Rome music is always in step with the times."
}
]
}