Skip to main content

LlamaIndex Llms Integration: Friendli

Installation

  1. Install the required Python packages:

    %pip install llama-index-llms-friendli
    !pip install llama-index
    
  2. Set the Friendli token as an environment variable:

    %env FRIENDLI_TOKEN=your_token_here
    

Usage

Basic Chat

To generate a chat response, use the following code:

from llama_index.llms.friendli import Friendli
from llama_index.core.llms import ChatMessage, MessageRole

llm = Friendli()

message = ChatMessage(role=MessageRole.USER, content="Tell me a joke.")
resp = llm.chat([message])
print(resp)

Streaming Responses

To stream chat responses in real-time:

resp = llm.stream_chat([message])
for r in resp:
    print(r.delta, end="")

Asynchronous Chat

For asynchronous chat interactions, use the following:

resp = await llm.achat([message])
print(resp)

Async Streaming

To handle async streaming of chat responses:

resp = await llm.astream_chat([message])
async for r in resp:
    print(r.delta, end="")

Complete with a Prompt

To generate a completion based on a prompt:

prompt = "Draft a cover letter for a role in software engineering."
resp = llm.complete(prompt)
print(resp)

Streaming Completion

To stream completions in real-time:

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

Async Completion

To handle async completions:

resp = await llm.acomplete(prompt)
print(resp)

Async Streaming Completion

For async streaming of completions:

resp = await llm.astream_complete(prompt)
async for r in resp:
    print(r.delta, end="")

Model Configuration

To configure a specific model:

llm = Friendli(model="llama-2-70b-chat")
resp = llm.chat([message])
print(resp)

LLM Implementation example

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

Metadata

Release files for llama-index-llms-friendli 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-llms-friendli 0.8.0
File Size Uploaded Provenance Actions
llama_index_llms_friendli-0.8.0.tar.gz 5.8 kB Without provenance Details for llama_index_llms_friendli-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-llms-friendli 0.8.0
File Interpreter ABI Platform Actions
llama_index_llms_friendli-0.8.0-py3-none-any.whl Python 3 none any Details for llama_index_llms_friendli-0.8.0-py3-none-any.whl

Total release size: 11.6 kB

Release files / llama_index_llms_friendli-0.8.0.tar.gz

Download URL llama_index_llms_friendli-0.8.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
738367e221bfdb45983efcf99323f66345060812726e4d6b2f2cd16df814ec05
BLAKE2b-256 checksum
How to use checksums
ad8e172be01f581794b8af8151e237edd2c8b7ca212f6204301c8b8a336a2202
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_llms_friendli-0.8.0-py3-none-any.whl

Download URL llama_index_llms_friendli-0.8.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb7f14594e8bc8c01783148aa10ce85a46477db19dd1df1f1ddcca7fa918bc37
BLAKE2b-256 checksum
How to use checksums
ec02de5b6f9e29c34d76c751647cb51616c7f960aae911147d2aadbbfb8bd122
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for llama-index-llms-friendli 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page