Skip to main content

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

To get started, create a service by registering greptimeai, and get:

  • host
  • database
  • username
  • password

Set it as the GREPTIMEAI_xxx environment variable before using the library:

export GREPTIMEAI_HOST=''
export GREPTIMEAI_DATABASE=''
export GREPTIMEAI_USERNAME=''
export GREPTIMEAI_PASSWORD=''

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greptimeai-0.1.2.tar.gz (10.5 kB view hashes)

Uploaded Source

Built Distribution

greptimeai-0.1.2-py3-none-any.whl (10.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page