Kagi API Python Wrapper
Project description
PyKagi
PyKagi is a Python library that simplifies the use of the Kagi API. With this library, you can easily implement features like text summarization, web content summarization, and search with just a few lines of code.
Installation
pip install PyKagi --upgrade
Usage
Universal Summarizer API
- Text summarization
With the Universal Summarizer, you can generate a summary of a given text. You can specify the summarization engine, target language for translation, and caching preferences. Here's an example of how to use the Universal Summarizer to summarize a text.
from PyKagi import UniversalSummarizer
API_KEY = "your api key"
US = UniversalSummarizer(API_KEY)
text = f"""Thank you. I'm honored to be with you today for your commencement from one of the finest universities in the world. Truth be told, I never graduated from college, and this is the closest I've ever gotten to a college graduation. Today I want to tell you three stories from my life. That's it. No big deal. Just three stories. (...)"""
engine = "agnes"
target_language = "KO"
cache = True
result = US.summarize(
text = text,
engine = engine,
target_language = target_language,
cache = cache
)
result
- Web content summarization
The Universal Summarizer also provides the capability to summarize web page content. In the example code below, you can pass the URL of a web page to generate a summary of its content. Additionally, you can obtain a summary translated into the desired language.
from PyKagi import UniversalSummarizer
API_KEY = "your api key"
US = UniversalSummarizer(API_KEY)
url = "https://namu.wiki/w/Midjourney"
engine = "agnes"
target_language = "KO"
cache = True
result = US.summarize(
url = url,
engine = engine,
target_language = target_language,
cache = cache
)
result
Search API
from PyKagi import Search
API_KEY = "your api key"
S = Search(API_KEY)
query = "Steve Jobs"
limit = 10
result = S.search(
query=query,
limit=limit
)
result
Contributors
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.