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.0.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.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llama_index_llms_mymagic-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c7208ca94b588453f0f9e0e3f0149e400d25412cb4434514c8f5bface0dd0e15
MD5 ed861e652c98ef98fe0f8c41776f150f
BLAKE2b-256 ef9b35632839dfc11a0188de9a0d063e5b6a1e0cffd01efd5832f010810c4b79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_llms_mymagic-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f0a60ca13d30dcc6247a4075c06d72a5d494fc8fb17a272bad4d0f9ddcf587d
MD5 59e5693bda7e604e7b18662baa2af948
BLAKE2b-256 d8040774658b136c65b8f339724744dcaec010dcc59c8f8b19ddee4cb672ed38

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