Observability tool for LLM application
Project description
greptimeai
Observability and analytics tool for LLM framework, service, etc. You can find more examples and guides on greptimeai-cookbook
Installation
To start, ensure you have Python 3.8 or newer. If you just want to use the package, run:
pip install --upgrade greptimeai
Usage
TODO(yuanbohan): make sure this link is correct!!
To get started, create a service by registering greptimeai, and get:
- host
- database
- token
Set it as the GREPTIMEAI_xxx
environment variable before using the library:
export GREPTIMEAI_HOST=''
export GREPTIMEAI_DATABASE=''
export GREPTIMEAI_TOKEN=''
LangChain
LangChain provides a callback system that allows you to hook into the various stages of your LLM application. Import GreptimeCallbackHandler, which helps to collect metrics and traces to GreptimeCloud.
from greptimeai.langchain.callback import GreptimeCallbackHandler
from langchain.chains import LLMChain
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
callbacks = [GreptimeCallbackHandler()]
llm = OpenAI()
prompt = PromptTemplate.from_template("1 + {number} = ")
# Constructor callback: First, let's explicitly set the GreptimeCallbackHandler
# when initializing our chain
chain = LLMChain(llm=llm, prompt=prompt, callbacks=callbacks)
chain.run(number=2)
# Request callbacks: Finally, let's use the request `callbacks` to achieve the same result
chain = LLMChain(llm=llm, prompt=prompt)
chain.run(number=2, callbacks=callbacks)
This example needs to be configured with your OpenAI account's private API key which is available on
our developer platform. Set it as the OPENAI_API_KEY
environment variable:
export OPENAI_API_KEY='sk-...'
OpenAI
TODO
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for greptimeai-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6020519311b8f6c9392ff47d738269237eb16ec0f0076e11d5bb1bec55bd929a |
|
MD5 | 576055a953510af8c37c4b9bdd8a21d9 |
|
BLAKE2b-256 | b1292ccd79dbe852b3fe161babb3469039bea9a0dbf2257b386c8af36994a58a |