Skip to main content

Kagi API Python Wrapper

Project description

Kagi API Python Wrapper
๐Ÿš€pip install PyKagi --upgrade

PyPI Latest Release Downloads


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.

Source Distribution

PyKagi-0.0.4.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

PyKagi-0.0.4-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page