Skip to content

taka2noda/datadog-integration-openai-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

How to use

Docs

Example Application (Here)

Tested on

  • EC2(Ubuntu 22.04.3 LTS (GNU/Linux 6.2.0-1017-aws x86_64))

Commands

Install Datadog Agent.

$ DD_API_KEY="YOUR_DATADOGAPI_KEY" DD_SITE="datadoghq.com"  bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)"

Install python and openai library.

$ sudo apt update
$ sudo apt install python3
$ sudo apt install python3-pip
$ pip install openai

Enable StatsD in your Datadog Agent.

$ sed -i 's/# dogstatsd_stats_enable: false/dogstatsd_stats_enable: true/g' datadog.yaml
$ sudo service datadog-agent restart
$ sudo datadog-agent status

Install the Datadog APM Python library.

$ pip install ddtrace

Clone Sample Application Repo.

$ git clone https://github.com/taka2noda/openai-python.git

Define environment variables.

$ export OPENAI_API_KEY="YOUR_OPENAPI_KEY"
$ export DD_API_KEY="YOUR_DATADOGAPI_KEY"
$ cd openai-python/examples

Execute 1. Simple

$ DD_SERVICE="taka2-openai-demo" DD_ENV="dev" DD_OPENAI_LOGS_ENABLED="true" DD_OPENAI_LOG_PROMPT_COMPLETION_SAMPLE_RATE="1.0" ddtrace-run python3 demo-gpt-35.py

Execute 2. Error

$ DD_SERVICE="taka2-openai-demo" DD_ENV="dev" DD_OPENAI_LOGS_ENABLED="true" DD_OPENAI_LOG_PROMPT_COMPLETION_SAMPLE_RATE="1.0" ddtrace-run python3 demo-error.py

Execute 3. Call Dall-e model

$ DD_SERVICE="taka2-openai-picture" DD_ENV="dev" DD_OPENAI_LOGS_ENABLED="true" DD_OPENAI_LOG_PROMPT_COMPLETION_SAMPLE_RATE="1.0" ddtrace-run python3 picture.py

No use others because expensive

Outcome

Screenshot 2024-03-06 at 22 37 55 Screenshot 2024-03-06 at 22 10 30 Screenshot 2024-03-06 at 22 10 39 Screenshot 2024-03-06 at 22 10 58

About

OpenAI API integration with Datadog LLM Observability on EC2

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages