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.6.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.6.0
File Size Uploaded Provenance Actions
llama_index_llms_friendli-0.6.0.tar.gz 5.5 kB Without provenance Details for llama_index_llms_friendli-0.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 10.8 kB

Release files / llama_index_llms_friendli-0.6.0.tar.gz

Download URL llama_index_llms_friendli-0.6.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5941fb60fbf4022b0f39218e7de4a7ac498c352ec8981102e09e45dc766b6f06
BLAKE2b-256 checksum
How to use checksums
bdc5feba947f8d3c9e3915c9fb67096fe9eea06fe981ea805e5f09d729b04dae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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}

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

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

Security for llama-index-llms-friendli 0.6.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