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.7.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.7.0
File Size Uploaded Provenance Actions
llama_index_llms_friendli-0.7.0.tar.gz 5.4 kB Without provenance Details for llama_index_llms_friendli-0.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 10.8 kB

Release files / llama_index_llms_friendli-0.7.0.tar.gz

Download URL llama_index_llms_friendli-0.7.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0f602f36f0b31f363e82e2553bcb09efda0303803d2c2c8c4dcc7126402f1287
BLAKE2b-256 checksum
How to use checksums
1b37825a3825522812a75a90747814dba090129b6d82c86157f8e119e201c25f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","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.7.0-py3-none-any.whl

Download URL llama_index_llms_friendli-0.7.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
000845a2d4cc5ca971eab92abdbd5ce929a70050a39331a02846588e52ecae09
BLAKE2b-256 checksum
How to use checksums
3764959e5ef4af014cb7624c9319aa31a32e663c8a8b553f197ebe6fc1f001ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","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.7.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