Skip to main content

llama-index llms mymagic integration

Project description

LlamaIndex Llms Integration: Mymagic

Installation

To install the required package, run:

%pip install llama-index-llms-mymagic
!pip install llama-index

Setup

Before you begin, set up your cloud storage bucket and grant MyMagic API secure access. For detailed instructions, visit the MyMagic documentation.

Initialize MyMagicAI

Create an instance of MyMagicAI by providing your API key and storage configuration:

from llama_index.llms.mymagic import MyMagicAI

llm = MyMagicAI(
    api_key="your-api-key",
    storage_provider="s3",  # Options: 's3' or 'gcs'
    bucket_name="your-bucket-name",
    session="your-session-name",  # Directory for batch inference
    role_arn="your-role-arn",
    system_prompt="your-system-prompt",
    region="your-bucket-region",
    return_output=False,  # Set to True to return output JSON
    input_json_file=None,  # Input file stored on the bucket
    list_inputs=None,  # List of inputs for small batch
    structured_output=None,  # JSON schema of the output
)

Note: If return_output is set to True, max_tokens should be at least 100.

Generate Completions

To generate a text completion for a question, use the complete method:

resp = llm.complete(
    question="your-question",
    model="choose-model",  # Supported models: mistral7b, llama7b, mixtral8x7b, codellama70b, llama70b, etc.
    max_tokens=5,  # Number of tokens to generate (default is 10)
)
print(
    resp
)  # The response indicates if the final output is stored in your bucket or raises an exception if the job failed

Asynchronous Requests

For asynchronous operations, use the acomplete endpoint:

import asyncio


async def main():
    response = await llm.acomplete(
        question="your-question",
        model="choose-model",  # Supported models listed in the documentation
        max_tokens=5,  # Number of tokens to generate (default is 10)
    )
    print("Async completion response:", response)


await main()

LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/mymagic/

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_mymagic-0.4.1.tar.gz (5.9 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_mymagic-0.4.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_mymagic-0.4.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_llms_mymagic-0.4.1.tar.gz
Algorithm Hash digest
SHA256 31b0b7b25c03d68e05e6ccec77449b6396cf8ddafa27620a67749ea3c7a6e08d
MD5 b365d18559335a00c93d52a1c052986f
BLAKE2b-256 c1238262537699be8a8f17a8251905543ced147a04b4096d886e7c7ef7f8c123

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_llms_mymagic-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15d974418d8ca32585739a6633894f15167c0997a34b61b8eccada84ad3088bc
MD5 d57e177c0f1b1939a87cbcfaeb4b14e2
BLAKE2b-256 f0e4c9902dc96ebe21f0273b0ae22ddaebc40af57db04952230d9fc11bfa3c8c

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