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
{'meta': {'id': '703a85c1-4548-4803-8309-2cc0481eaf60',
'node': 'asia-southeast1',
'ms': 0,
'api_balance': 13.058023},
'data': {'output': '์ฐ์ค์๋ ์ธ๊ณ ์ต๊ณ ์ ๋ํ ์ค ํ๋์ ์กธ์
์์ ์ฐธ์ํ ์ ์์ด ์๊ด์ผ๋ก ์๊ฐํ๋ค. ๊ทธ๋ ๋ํ์ ์กธ์
ํ์ง ๋ชปํ์ง๋ง ์ด๋ฒ ์กธ์
์์ด ๋ํ ์กธ์
์ ๊ฐ์ฅ ๊ฐ๊น์ด ๊ฒฝํ์ด๋ผ ์๊ฐํ๋ค. ๊ทธ๋ ์ฒญ์ค๋ค๊ณผ ์์ ์ ์ถ์์ ์ธ ๊ฐ์ง ์ด์ผ๊ธฐ๋ฅผ ๋๋ ๊ณํ์ด๋ค. ์ฐ์ค์๋ ์ด๊ฒ์ด ํฐ ์ผ์ด๋ผ๊ณ ์๊ฐํ์ง ์๋๋ค. ๊ทธ๊ฐ ๋๋ ์ด์ผ๊ธฐ๋ ์ฒญ์ค๋ค์๊ฒ ํฅ๋ฏธ๋ก์ธ ์ ์๋ค. ์ฐ์ค์๋ ๊ทธ๊ฐ ๋๋ ์ด์ผ๊ธฐ์ ๋ํด ์ถ๊ฐ์ ์ธ ์ธ๋ถ ์ ๋ณด๋ฅผ ์ ๊ณตํ์ง ์๋๋ค. ์ฒญ์ค๋ค์ ๊ทธ ์ด์ผ๊ธฐ๋ค์ด ํต์ฐฐ๋ ฅ ์๊ฑฐ๋ ๋งค๋ ฅ์ ์ผ ์ ์๋ค. ์ฐ์ค์์ ๋ํ ํ์ ๋ถ์ฌ๋ ๊ทธ์ ์ถ์ ๊ฒฝํ์ ๊ฐ์น๋ฅผ ๋จ์ด๋จ๋ฆฌ์ง ์๋๋ค. ์ฐ์ค์๋ ์ฒญ์ค๋ค์๊ฒ ์๊ฐ๊ณผ ๋๊ธฐ๋ถ์ฌ๋ฅผ ์ฃผ๊ธฐ ์ํด ์ฐ์คํ ์๋์ด๋ค.',
'tokens': 0}}
- 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
{'meta': {'id': '6cb208c8-ec06-4bcd-a2f7-cdf5d5ee9feb',
'node': 'asia-southeast1',
'ms': 0,
'api_balance': 13.058023},
'data': {'output': 'Midjourney๋ ํ
์คํธ์์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๊ฑฐ๋ ์ด๋ฏธ์ง๋ฅผ ํ
์คํธ์ ์ฝ์
ํ ์ ์๋ ์ธ๊ณต์ง๋ฅ ์ฐ๊ตฌ์์
๋๋ค. ์ด ์ํํธ์จ์ด๋ ํ์ค์ ์ด๊ณ ์ถ์์ ์ธ ์์ ์ ํํ์ ํนํ๋์ด ์์ผ๋ฉฐ, ์
๋ ฅ ํค์๋์ ๋ฐ๋ผ ๋งํ ์คํ์ผ์ ๊ทธ๋ฆผ๋ ์์ฑํ ์ ์์ต๋๋ค. Midjourney๋ ๋ฌด๋ฃ ์ฒดํ ๋ฒ์ ์ ์ ๊ณตํ์ฌ ์ฌ์ฉ์๊ฐ ์ต๋ 25๊ฐ์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ ์ ์์ง๋ง, ๋ ๋ง์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ ค๋ฉด ์ ๋ฃ ๊ตฌ๋
์ด ํ์ํฉ๋๋ค. ๊ทธ๋ฌ๋ ์ด ์ํํธ์จ์ด๋ ์๋ฒฝํ์ง ์์ผ๋ฉฐ, ๋ง์กฑ์ค๋ฌ์ด ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฅํ ์ ์์ด ๋์ ๋ญ๋นํ ์ ์์ต๋๋ค. Midjourney๋ ์ฝ๋ก๋ผ๋ ์ฃผ ๋ฐ๋ํ์ ๋์งํธ ์ํธ ๋ถ๋ฌธ์์ 1์๋ฅผ ์ฐจ์งํ ์ฐ์ฃผ ์คํ๋ผ ๊ทน์ฅ์ ๋น๋กฏํ ๋ค์ํ ์์ ์ํ์ ๋ง๋๋ ๋ฐ ์ฌ์ฉ๋์์ต๋๋ค. ๊ทธ๋ฌ๋ Midjourney์ ์ฌ์ฉ์ ๋ํ ๋
ผ๋์ด ์์์ผ๋ฉฐ, ์ผ๋ถ ์์ ๊ฐ๋ค์ ์ด ์ํํธ์จ์ด๊ฐ ์ ์๊ถ์ ์นจํดํ๋ค๊ณ ์ฃผ์ฅํ์ต๋๋ค. ํ ์ฌ๋ก์์๋ Midjourney์์ ์์ฑ๋ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ ์์ค์ ์ ์๊ถ์ด ๋ฏธ๊ตญ ์ ์๊ถ๊ตญ์ ์ํด ์ทจ์๋์์ง๋ง, ์ ์๊ฐ ์ง์ ํธ์งํ๊ณ ์ด ๋ถ๋ถ์ ์ ์๊ถ์ ์ธ์ ๋์์ต๋๋ค. Midjourney๋ Waifu Labs์ ํ๋ ฅํ์ฌ Midjourney์ ์ ๋๋ฉ์ด์
์คํ์ผ ๊ทธ๋ฆผ์ ํนํ๋ AI ๋ชจ๋ธ์ธ Niji Journey๋ฅผ ๋ง๋ค์์ต๋๋ค. ์ด ์ํํธ์จ์ด๋ Ilya Kuvshinov์ Mika Pikazo์ ๊ฐ์ ์ธ๊ธฐ ์ผ๋ฌ์คํธ๋ ์ดํฐ์ ์ ์ฌํ ๋ค์ํ ๊ทธ๋ฆผ ์คํ์ผ์ ์์ฑํ ์ ์์ง๋ง, ์์ผ๋ก ๊ทธ๋ฆฐ ์ด๋ฏธ์ง์ R-18 ํ๊ทธ ์ธ์์๋ ์ฌ์ ํ ์ฝ์ ์ด ์์ต๋๋ค. ๋ค๋ฅธ AI ๋๋ก์ ๋ด๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก Niji Journey๋ ์ผ์ ํ์ ์ดํ์๋ ์ ๋ฃ ๊ฒฐ์ ๊ฐ ํ์ํฉ๋๋ค.',
'tokens': 0}}
FastGPT API
from PyKagi import FastGPT
API_KEY = "your api key"
FGPT = FastGPT(API_KEY)
query = "python 3.11"
result = FGPT.fastgpt(
query = query,
)
result
{'meta': {'id': '8ee670fe-0dd4-469b-a076-2a0b0d410e66',
'node': 'asia-southeast1',
'ms': 0,
'api_balance': 13.058023},
'data': {'output': 'According to the provided context:\n\nPython 3.11 is a newer major release of the Python programming language. It contains many new features and optimizations compared to previous versions. Sources state that Python 3.11 is between 10-60% faster than Python 3.10, with an average speedup of around 25% [1].',
'tokens': 0,
'references': [{'title': "What's New In Python 3.11 โ Python 3.11.4 documentation",
'snippet': 'Python 3.11 is between 10-60% faster than Python 3.10. On average, we measured a 1.25x speedup on the standard benchmark suite. See Faster CPython for...',
'url': 'https://docs.python.org/3/whatsnew/3.11.html'}]}}
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.