Back to Llama Index

EverlyAI

docs/examples/llm/everlyai.ipynb

0.14.211.3 KB
Original Source

<a href="https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/llm/everlyai.ipynb" target="_parent"></a>

EverlyAI

If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.

python
%pip install llama-index-llms-everlyai
python
!pip install llama-index
python
from llama_index.llms.everlyai import EverlyAI
from llama_index.core.llms import ChatMessage

Call chat with ChatMessage List

You need to either set env var EVERLYAI_API_KEY or set api_key in the class constructor

python
# import os
# os.environ['EVERLYAI_API_KEY'] = '<your-api-key>'

llm = EverlyAI(api_key="your-api-key")
python
message = ChatMessage(role="user", content="Tell me a joke")
resp = llm.chat([message])
print(resp)

Streaming

python
message = ChatMessage(role="user", content="Tell me a story in 250 words")
resp = llm.stream_chat([message])
for r in resp:
    print(r.delta, end="")

Call complete with Prompt

python
resp = llm.complete("Tell me a joke")
print(resp)
python
resp = llm.stream_complete("Tell me a story in 250 words")
for r in resp:
    print(r.delta, end="")