/yandexGPTapi

Small python yandexGPT api wrapper

Primary LanguagePython

Info

This is simple api wrapper for Yandex gpt api.

Installation

pip install git+https://github.com/freQuensy23-coder/yandexGPTapi.git

Usage

  1. Create your Yandex cloud, get access to yandex gpt, then create iam token
  2. Install this library
  3. Create api instance and use it
from ygpt.api import YandexGPT

api = YandexGPT(iam_token='your iam token', folder_id='your folder id')
text = 'This is very interesting film!!!'
text_vector = api.embed(text=text, embedding_type='EMBEDDING_TYPE_QUERY', model='general:embedding').embedding

instruction = 'You are ai assistant. You have to answer on user questions.'
text = 'What is the biggest plane in the world?'
print(api.generate_instruct(instruction_text=instruction, request_text=text).alternatives[0].text) 
# The biggest plane in the world is the Antonov An-225 Mriya, which has a wingspan of 366 feet and can carry up to 360...