python-imagine-sdk 0.5.0
A simple Python library for quickly building your own custom AI use case using Qualcomm's inference-as-a-service platform
Requires Python: >=3.9
Keywords: ai, genai, imagine, llm, qualcomm, quic, sdk

# Qualcomm Imagine SDK for Python

Qualcomm has developed a Python package known as Imagine SDK. Its purpose is to simplify
the process of creating GenAI applications. It achieves this by merging our Imagine APIs
with sophisticated Python AI frameworks like LangChain. This amalgamation facilitates
the creation of applications such as chatbots, Generative Question-Answering (GQA),
summarization, and workflow automation.


## How to install

You can install the latest stable version of the Imagine SDK package from PyPI (
requires Python 3.9 or higher). The `python-imagine-sdk` package provides the basic functionality,
which is the Imagine Client that enables interacting with the Imagine GenAI platform in an object-oriented programming fashion.

```bash
pip install python-imagine-sdk
```

### LangChain support

If you have used other LLMs before, you might be familiar with the
[LangChain](https://www.langchain.com) syntax. If you want to use this approach to
[interact with Imagine using LangChain](/tutorials/3_0_langchain), you can install
the basic functionality plus LangChain support by installing the package as `python-imagine-sdk[langchain]`:

```bash
pip install python-imagine-sdk[langchain]
```

### CrewAI support

If you are planning to use [CrewAI](https://docs.crewai.com/), install the package as `python-imagine-sdk[crewai]` to automatically install the needed
dependencies:

```bash
pip install python-imagine-sdk[crewai]
```

### AutoGen support

If you are planning to use [AutoGen](https://github.com/microsoft/autogen/), install the package as `python-imagine-sdk[autogen]` to automatically install the needed
dependencies:

```bash
pip install python-imagine-sdk[autogen]
```

## How to use it

The following is the most basic example of using a Large Language Model (LLM) to
generate text. It instantiates the client `ImagineClient` and starts a
new conversation by asking a question.

```python
from imagine import ChatMessage, ImagineClient


client = ImagineClient()

chat_response = client.chat(
    messages=[ChatMessage(role="user", content="What is the best Spanish cheese?")],
    model="Llama-3.1-8B",
)

print(chat_response.first_content)
```

This will print something similar to:

```text
Spain is renowned for its rich variety of cheeses, each with its unique flavor profile
and texture. The "best" Spanish cheese is subjective and often depends on personal
taste preferences. However, here are some of the most popular and highly-regarded
Spanish cheeses:

1. Manchego: A firm, crumbly cheese made from sheep's milk, Manchego is a classic
   Spanish cheese with a nutty, slightly sweet flavor.
2. Mahon: A semi-soft cheese from the island of Minorca, Mahon has a mild,
   creamy flavor and a smooth texture.
3. Idiazabal: A smoked cheese from the Basque region, Idiazabal has a strong, savory
   flavor and a firm texture.
4. Garrotxa: A soft, creamy cheese from Catalonia, Garrotxa has a mild, buttery flavor
   and a delicate aroma.
...
```
The Imagine SDK exposes two clients, each with a different programming paradigm:
synchronous and asynchronous.

`imagine.ImagineClient` is the synchronous Imagine client. If you don't need
asynchronous programming on your Python code, or simply you are not familiar with
asynchronous programming, this is the client you want to use.

Otherwise, if you are leveraging `asyncio` on your codebase,
`imagine.ImagineAsyncClient` might be a better choice.

## Support

If you have any questions, concerns, or suggestions, please don't hesitate to reach us at `cloudai@qti.qualcomm.com`. We're here to help!

## License

Usage of Imagine SDK is subjected to the following license:

```
PLEASE READ THIS LICENSE AGREEMENT ("AGREEMENT") CAREFULLY. THIS AGREEMENT IS
A BINDING LEGAL AGREEMENT ENTERED INTO BY AND BETWEEN YOU (OR IF YOU ARE
ENTERING INTO THIS AGREEMENT ON BEHALF OF AN ENTITY, THEN THE ENTITY THAT YOU
REPRESENT) AND QUALCOMM TECHNOLOGIES, INC. ("QTI" "WE" "OUR" OR "US"). THIS IS
THE AGREEMENT THAT APPLIES TO YOUR USE OF THE DESIGNATED AND/OR LINKED
APPLICATIONS, THE ENCLOSED QUALCOMM TECHNOLOGIES' MATERIALS, INCLUDING RELATED
DOCUMENTATION AND ANY UPDATES OR IMPROVEMENTS THEREOF
(COLLECTIVELY, "MATERIALS"). BY USING OR COMPLETING THE INSTALLATION OF THE
MATERIALS, YOU ARE ACCEPTING THIS AGREEMENT AND YOU AGREE TO BE BOUND BY ITS
TERMS AND CONDITIONS. IF YOU DO NOT AGREE TO THESE TERMS, QTI IS UNWILLING TO
AND DOES NOT LICENSE THE MATERIALS TO YOU. IF YOU DO NOT AGREE TO THESE TERMS
YOU MUST DISCONTINUE THE INSTALLATION PROCESS AND YOU MAY NOT USE THE MATERIALS
OR RETAIN ANY COPIES OF THE MATERIALS. ANY USE OR POSSESSION OF THE MATERIALS
BY YOU IS SUBJECT TO THE TERMS AND CONDITIONS SET FORTH IN THIS AGREEMENT.

1. RIGHT TO USE DELIVERABLES; RESTRICTIONS.

1.1 License. Subject to the terms and conditions of this Agreement,
including, without limitation, the restrictions, conditions, limitations and
exclusions set forth in this Agreement, QTI hereby grants to you a
nonexclusive, limited license under QTI's copyrights to: (i) install and use
the Materials; and (ii) to reproduce and redistribute the binary code portions
of the Materials (the "Redistributable Binary Code"). You may make and use a
reasonable number of copies of any documentation.

1.2 Redistribution Restrictions. Distribution of the Redistributable Binary
Code is subject to the following restrictions: (i) Redistributable Binary Code
may only be distributed in binary format and may not be distributed in source
code format:; (ii) the Redistributable Binary Code may only operate in
conjunction with platforms incorporating Qualcomm Technologies, Inc. chipsets;
(iii) redistribution of the Redistributable Binary Code must include the .txt
file setting forth the terms and condition of this Agreement; (iv) you may not
use Qualcomm Technologies' or its affiliates or subsidiaries name, logo or
trademarks; and (v) copyright, trademark, patent and any other notices that
appear on the Materials may not be removed or obscured.

1.3 Additional Restrictions. Except as expressly permitted by this Agreement,
you shall have no right to sublicense, transfer or otherwise disclose the
Materials to any third party. You shall not reverse engineer, reverse
assemble, reverse translate, decompile or reduce to source code form any
portion of the Materials provided in object code form or executable form.
Except for the purposes expressly permitted in this Agreement, You shall not
use the Materials for any other purpose. QTI (or its licensors) shall retain
title and all ownership rights in and to the Materials and any alterations,
modifications (including all derivative works), translations or adaptations
made of the Materials, and all copies thereof, and nothing herein shall be
deemed to grant any right to You under any of QTI's or its affiliates'
patents. You shall not subject the Materials to any third party license
terms (e.g., open source license terms). You shall not use the Materials for
the purpose of identifying or providing evidence to support any potential
patent infringement claim against QTI, its affiliates, or any of QTI's or
QTI's affiliates' suppliers and/or direct or indirect customers. QTI hereby
reserves all rights not expressly granted herein.

1.4 Third Party Software and Materials. The Software may contain or link to
certain software and/or materials that are written or owned by third parties.
Such third party code and materials may be licensed under separate or
different terms and conditions and are not licensed to you under the terms of
this Agreement. You agree to comply with all terms and conditions imposed on
you in the applicable third party licenses. Such terms and conditions may
impose certain obligations on you as a condition to the permitted use of such
third party code and materials. QTI does not represent or warrant that such
third party licensors have or will continue to license or make available their
code and materials to you.

1.5 Feedback. QTI may from time to time receive suggestions, feedback or
other information from You regarding the Materials. Any suggestions, feedback
or other disclosures received from You are and shall be entirely voluntary on
the part of You. Notwithstanding any other term in this Agreement, QTI shall
be free to use suggestions, feedback or other information received from You,
without obligation of any kind to You. The Parties agree that all inventions,
product improvements, and modifications conceived of or made by QTI that are
based, either in whole or in part, on ideas, feedback, suggestions, or
recommended improvements received from You are the exclusive property of QTI,
and all right, title and interest in and to any such inventions, product
improvements, and modifications will vest solely in QTI.

1.6 No Technical Support. QTI is under no obligation to provide any form of
technical support for the Materials, and if QTI, in its sole discretion,
chooses to provide any form of support or information relating to the
Materials, such support and information shall be deemed confidential and
proprietary to QTI.

2. WARRANTY DISCLAIMER. YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT THE USE OF
THE MATERIALS IS AT YOUR SOLE RISK. THE MATERIALS AND TECHNICAL SUPPORT, IF
ANY, ARE PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR
IMPLIED. QTI ITS LICENSORS AND AFFILIATES MAKE NO WARRANTIES, EXPRESS OR
IMPLIED, WITH RESPECT TO THE MATERIALS OR ANY OTHER INFORMATION OR DOCUMENTATION
PROVIDED UNDER THIS AGREEMENT, INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR AGAINST INFRINGEMENT, OR
ANY EXPRESS OR IMPLIED WARRANTY ARISING OUT OF TRADE USAGE OR OUT OF A COURSE OF
DEALING OR COURSE OF PERFORMANCE. NOTHING CONTAINED IN THIS AGREEMENT SHALL BE
CONSTRUED AS (I) A WARRANTY OR REPRESENTATION BY QTI, ITS LICENSORS OR
AFFILIATES AS TO THE VALIDITY OR SCOPE OF ANY PATENT, COPYRIGHT OR OTHER
INTELLECTUAL PROPERTY RIGHT OR (II) A WARRANTY OR REPRESENTATION BY QTI THAT ANY
MANUFACTURE OR USE WILL BE FREE FROM INFRINGEMENT OF PATENTS, COPYRIGHTS OR
OTHER INTELLECTUAL PROPERTY RIGHTS OF OTHERS, AND IT SHALL BE THE SOLE
RESPONSIBILITY OF YOU TO MAKE SUCH DETERMINATION AS IS NECESSARY WITH RESPECT TO
THE ACQUISITION OF LICENSES UNDER PATENTS AND OTHER INTELLECTUAL PROPERTY OF
THIRD PARTIES.

3. NO OTHER LICENSES OR INTELLECTUAL PROPERTY RIGHTS. Neither this Agreement,
nor any act by QTI or any of its affiliates pursuant to this Agreement or
relating to the Materials (including, without limitation, the provision by QTI
or its affiliates of the Materials), shall provide to You any license or any
other rights whatsoever under any patents, trademarks, trade secrets, copyrights
or any other intellectual property of QTI or any of its affiliates, except for
the copyright rights expressly licensed under this Agreement. You understand and
agree that:

(i) Neither this Agreement, nor delivery of the Materials, grants any right to
practice, or any other right at all with respect to, any patent of QTI or any
of its affiliates; and

(ii) A separate license agreement from QUALCOMM Incorporated is needed to use
or practice any patent of QUALCOMM Incorporated. You agree not to contend in
any context that, as a result of the provision or use of the Materials, either
QTI or any of its affiliates has any obligation to extend, or You or any other
party has obtained any right to, any license, whether express or implied, with
respect to any patent of QTI or any of its affiliates for any purpose.

4. TERMINATION. This Agreement shall be effective upon acceptance, or access or
use of the Materials (whichever occurs first) by You and shall continue until
terminated. You may terminate the Agreement at any time by deleting and
destroying all copies of the Materials and all related information in Your
possession or control. This Agreement terminates immediately and automatically,
with or without notice, if You fail to comply with any provision hereof.
Additionally, QTI may at any time terminate this Agreement, without cause, upon
notice to You. Upon termination You must, to the extent possible, delete or
destroy all copies of the Materials in Your possession and the license granted
to You in this Agreement shall terminate. Sections 1.2 through 10 shall survive
the termination of this Agreement. In the event that any restrictions,
conditions, limitations are found to be either invalid or unenforceable, the
rights granted to You in Section 1 (License) shall be null, void and ineffective
from the Effective Date, and QTI shall also have the right to terminate this
Agreement immediately, and with retroactive effect to the effective date.

5. LIMITATION OF LIABILITY. IN NO EVENT SHALL QTI, QTI's AFFILIATES OR ITS
LICENSORS BE LIABLE TO YOU FOR ANY INCIDENTAL, CONSEQUENTIAL OR SPECIAL DAMAGES,
INCLUDING BUT NOT LIMITED TO ANY LOST PROFITS, LOST SAVINGS, OR OTHER INCIDENTAL
DAMAGES, ARISING OUT OF THE USE OR INABILITY TO USE, OR THE DELIVERY OR FAILURE
TO DELIVER, ANY OF THE DELIVERABLES, OR ANY BREACH OF ANY OBLIGATION UNDER THIS
AGREEMENT, EVEN IF QTI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
THE FOREGOING LIMITATION OF LIABILITY SHALL REMAIN IN FULL FORCE AND EFFECT
REGARDLESS OF WHETHER YOUR REMEDIES HEREUNDER ARE DETERMINED TO HAVE FAILED OF
THEIR ESSENTIAL PURPOSE. THE ENTIRE LIABILITY OF QTI, QTI's AFFILIATES AND ITS
LICENSORS, AND THE SOLE AND EXCLUSIVE REMEDY OF YOU, FOR ANY CLAIM OR CAUSE OF
ACTION ARISING HEREUNDER (WHETHER IN CONTRACT, TORT, OR OTHERWISE) SHALL NOT
EXCEED US$50.

6. INDEMNIFICATION. You agree to indemnify and hold harmless QTI and its
officers, directors, employees and successors and assigns against any and all
third party claims, demands, causes of action, losses, liabilities, damages,
costs and expenses, incurred by QTI (including but not limited to costs of
defense, investigation and reasonable attorney's fees) arising out of, resulting
from or related to: (i) any breach of this Agreement by You; and (ii) your acts,
omissions, products and services. If requested by QTI, You agree to defend QTI
in connection with any third party claims, demands, or causes of action
resulting from, arising out of or in connection with any of the foregoing.

7. ASSIGNMENT. You shall not assign this Agreement or any right or interest
under this Agreement, nor delegate any obligation to be performed under this
Agreement, without QTI's prior written consent. For purposes of this Section 7,
an "assignment" by You under this Section shall be deemed to include, without
limitation, any merger, consolidation, sale of all or substantially all of its
assets, or any substantial change in the management or control of You.
Any attempted assignment in contravention of this Section 9 shall be void.
QTI may freely assign this Agreement or delegate any or all of its rights and
obligations hereunder to any third party.

8. COMPLIANCE WITH LAWS; APPLICABLE LAW. You agree to comply with all
applicable local, international and national laws and regulations and with U.S.
Export Administration Regulations, as they apply to the subject matter of this
Agreement. You will not engage in any activity in connection with this Agreement that
would reasonably be expected to cause QTI to violate any local, national, or international
laws or regulations applicable to QTI, including the U.S. Export Administration Regulations,
and you acknowledge that nothing in this Agreement shall cause QTI to take any action that
would cause QTI to violate any local, national, or international laws or regulations applicable
to QTI. This Agreement is governed by the laws of the State of California,
excluding California's choice of law rules.

9. CONTRACTING PARTIES. If the Materials are downloaded on any computer owned
by a corporation or other legal entity, then this Agreement is formed by and
between QTI and such entity. The individual accepting the terms of this
Agreement represents and warrants to QTI that they have the authority to bind
such entity to the terms and conditions of this Agreement.

10. MISCELLANEOUS PROVISIONS. This Agreement, together with all exhibits
attached hereto, which are incorporated herein by this reference, constitutes
the entire agreement between QTI and You and supersedes all prior negotiations,
representations and agreements between the parties with respect to the subject
matter hereof. No addition or modification of this Agreement shall be effective
unless made in writing and signed by the respective representatives of QTI and
You. The restrictions, limitations, exclusions and conditions set forth in this
Agreement shall apply even if QTI or any of its affiliates becomes aware of or
fails to act in a manner to address any violation or failure to comply
therewith. You hereby acknowledge and agree that the restrictions, limitations,
conditions and exclusions imposed in this Agreement on the rights granted in
this Agreement are not a derogation of the benefits of such rights. You further
acknowledges that, in the absence of such restrictions, limitations, conditions
and exclusions, QTI would not have entered into this Agreement with You. Each
party shall be responsible for and shall bear its own expenses in connection
with this Agreement. If any of the provisions of this Agreement are determined
to be invalid, illegal, or otherwise unenforceable, the remaining provisions
shall remain in full force and effect. This Agreement is entered into solely
in the English language, and if for any reason any other language version is
prepared by any party, it shall be solely for convenience and the English
version shall govern and control all aspects. If You are located in the
province of Quebec, Canada, the following applies: The Parties hereby confirm
they have requested this Agreement and all related documents be prepared
in English.
```