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.1.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.1-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.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_llms_gigachat_ru-0.4.1.tar.gz
Algorithm Hash digest
SHA256 9af11de0954e5bf2a96f74e96dc6cc5f556bc84c9cfd60d9e6683108ddbb52d5
MD5 033f26015d4b8b8b982f49f791724bd6
BLAKE2b-256 b71e0a703e01e16468e16414975bc0362c347b51c360465453aa566213a9b973

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_llms_gigachat_ru-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 027dc0f5d5efaf9d2c8bbe93b306cc1ab3b53045d052b4fefd1d953e6e4c9e47
MD5 01c8e483237eb53ed3166cdc62b9d687
BLAKE2b-256 a32f3620eb10f1489ed8576e182191a7c71e43abdd889f3ef3d94108b741f14a

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