Skip to main content

llama-index llms gigachat integration

Project description

LlamaIndex Llms Integration: Gigachat

This package provides a Gigachat integration as LLM Module.

Installation

using poetry:

poetry add llama-index-llms-gigachat-ru

or using pip:

pip install llama-index-llms-gigachat-ru

Basic Usage

To initialize the Gigachat integration, you need to provide the credentials and optionally set verify_ssl_certs to False if you want to disable SSL certificate verification.

Then you will be able to use the complete method to get the completion.

from llama_index.llms.gigachat import GigaChatLLM

llm = GigaChatLLM(
    credentials="NjI0M2M4MzctNmEwMi00ZjhmLWIzYmEtMTBlMzdhZjI4NzNhOjgzYjM3YzFkLWQ3MTEtNGVhYi04Y2Q0LTkwODM5ZjI4MDg1Zg==",
    verify_ssl_certs=False,
)
resp = llm.complete("What is the capital of France?")
print(resp)

Also, you can use it asynchronously:

import asyncio
from llama_index.llms.gigachat import GigaChatLLM

llm = GigaChatLLM(
    credentials="NjI0M2M4MzctNmEwMi00ZjhmLWIzYmEtMTBlMzdhZjI4NzNhOjgzYjM3YzFkLWQ3MTEtNGVhYi04Y2Q0LTkwODM5ZjI4MDg1Zg==",
    verify_ssl_certs=False,
)


async def main():
    resp = await llm.acomplete("What is the capital of France?")
    print(resp)


asyncio.run(main())

And as a chat module:

import asyncio

from llama_index.core.chat_engine import SimpleChatEngine
from llama_index.llms.gigachat import GigaChatLLM

llm = GigaChatLLM(
    credentials="NjI0M2M4MzctNmEwMi00ZjhmLWIzYmEtMTBlMzdhZjI4NzNhOjgzYjM3YzFkLWQ3MTEtNGVhYi04Y2Q0LTkwODM5ZjI4MDg1Zg==",
    verify_ssl_certs=False,
)

chat = SimpleChatEngine.from_defaults(
    llm=llm,
)


async def main():
    resp = await chat.achat("What is the capital of France?")
    print(resp)


asyncio.run(main())

And as streaming completion:

import asyncio

from llama_index.llms.gigachat import GigaChatLLM

llm = GigaChatLLM(
    credentials="NjI0M2M4MzctNmEwMi00ZjhmLWIzYmEtMTBlMzdhZjI4NzNhOjgzYjM3YzFkLWQ3MTEtNGVhYi04Y2Q0LTkwODM5ZjI4MDg1Zg==",
    verify_ssl_certs=False,
)


async def main():
    async for resp in await llm.astream_complete(
        "What is the capital of France?"
    ):
        print(resp)


asyncio.run(main())

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

llama_index_llms_gigachat_ru-0.4.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_llms_gigachat_ru-0.4.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_gigachat_ru-0.4.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_llms_gigachat_ru-0.4.0.tar.gz
Algorithm Hash digest
SHA256 eb43a71aeaa4280e0d49910ea0ec00d98d086a5b3c44c2d0e118b3c50ad4718f
MD5 955e633598f96f346be7f9607e415091
BLAKE2b-256 937a527587c1f1fb2cc4144e9474442672ecec4e4d30d28c3a151cec7eeae750

See more details on using hashes here.

File details

Details for the file llama_index_llms_gigachat_ru-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_llms_gigachat_ru-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed615dd6857266e2c81259486ead836841d75902badc0ca8bee6543b3280fc96
MD5 059ca7f6eb7676a01a1f0a6598cf180c
BLAKE2b-256 559778e49a1ed11d21b2d3de1b9b824de14f62bfd47e48fdccbce3b824f3119f

See more details on using hashes here.

Supported by

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