Skip to main content

llama-index llms pipeshift integration

Project description

LlamaIndex Llms Integration: Pipeshift

Installation

  1. Install the required Python packages:

    %pip install llama-index-llms-pipeshift
    %pip install llama-index
    
  2. Set the PIPESHIFT_API_KEY as an environment variable or pass it directly to the class constructor.

Usage

Basic Completion

To generate a simple completion, use the complete method:

from llama_index.llms.pipeshift import Pipeshift

llm = Pipeshift(
    model="mistralai/Mistral-7B-Instruct-v0.3",
    # api_key="YOUR_API_KEY" # alternative way to pass api_key if not specified in environment variable
)
res = llm.complete("supercars are ")
print(res)

Example output:

Supercars are high-performance sports cars that are designed to deliver exceptional speed, power, and luxury. They are often characterized by their sleek and aerodynamic designs, powerful engines, and advanced technology.

Basic Chat

To simulate a chat with multiple messages:

from llama_index.core.llms import ChatMessage
from llama_index.llms.pipeshift import Pipeshift

messages = [
    ChatMessage(
        role="system", content="You are sales person at supercar showroom"
    ),
    ChatMessage(role="user", content="why should I pick porsche 911 gt3 rs"),
]
res = Pipeshift(
    model="mistralai/Mistral-7B-Instruct-v0.3", max_tokens=50
).chat(messages)
print(res)

Example output:

assistant: 1. Unmatched Performance: The Porsche 911 GT3 RS is a high-performance sports car that delivers an unparalleled driving experience. It boasts a powerful 4.0-liter flat

Streaming Completion

To stream a response in real-time using stream_complete:

from llama_index.llms.pipeshift import Pipeshift

llm = Pipeshift(model="mistralai/Mistral-7B-Instruct-v0.3")
resp = llm.stream_complete("porsche GT3 RS is ")

for r in resp:
    print(r.delta, end="")

Example output (partial):

 The Porsche 911 GT3 RS is a high-performance sports car produced by Porsche AG. It is part of the 911 (991 and 992 generations) series and is%

Streaming Chat

For a streamed conversation, use stream_chat:

from llama_index.llms.pipeshift import Pipeshift
from llama_index.core.llms import ChatMessage

llm = Pipeshift(model="mistralai/Mistral-7B-Instruct-v0.3")
messages = [
    ChatMessage(
        role="system", content="You are sales person at supercar showroom"
    ),
    ChatMessage(role="user", content="how fast can porsche gt3 rs it go?"),
]
resp = llm.stream_chat(messages)

for r in resp:
    print(r.delta, end="")

Example output (partial):

The Porsche 911 GT3 RS is an incredible piece of engineering. This high-performance sports car can reach a top speed of approximately 193 mph (310 km/h) according to P%

LLM Implementation example

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

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_pipeshift-0.1.0.tar.gz (3.3 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_pipeshift-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_pipeshift-0.1.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_pipeshift-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for llama_index_llms_pipeshift-0.1.0.tar.gz
Algorithm Hash digest
SHA256 14f748514a9a781144779afd4d4e9898ed324756b618173dc7fcbec6091785c7
MD5 b1ba27132681dcf06b37173e87db08a6
BLAKE2b-256 a9a214ba2995e58c8eacd0b6f01804719cd92fc04001690458d321b08e2e65a2

See more details on using hashes here.

File details

Details for the file llama_index_llms_pipeshift-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_llms_pipeshift-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc745e9e37e1e3bea733ed1a8bc49ef54e8a1ca7e0d63d16f1177dce5c963bb4
MD5 70bffd8d61c44fd9c9b562a7924dfa53
BLAKE2b-256 08e70fddded96d63f9638fb381997fccea165f9309ace65520898975aa02ecd8

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