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

Uploaded Python 3

File details

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

File metadata

  • Download URL: llama_index_llms_mymagic-0.5.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_mymagic-0.5.0.tar.gz
Algorithm Hash digest
SHA256 27218452f39383b9d95e11668c17987bdfb6b5f356bff3dc2f10ede602cc772c
MD5 824cb62c31436a8b5a1874593a5b4322
BLAKE2b-256 786ba881ae883efffb1c3c320c51e34feacda95a08c2d08fc19770b4e3ea9679

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llama_index_llms_mymagic-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_mymagic-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d24531d6543455a1a18b0e4e526c89f9edffcbd7b8c588ccc4721e4a2c8e7457
MD5 9daa8b1a38c885b2799739dae8f05f43
BLAKE2b-256 0c0791edcc4459d513d45ddf545d2a616aaf4ead64160a7f36cdaf93102fcdb4

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