Skip to content

Instantly share code, notes, and snippets.

@rajivmehtaflex
Last active July 27, 2024 11:44
Show Gist options
  • Save rajivmehtaflex/d30b2769e55b0df73f5a5fe6a42ea99a to your computer and use it in GitHub Desktop.
Save rajivmehtaflex/d30b2769e55b0df73f5a5fe6a42ea99a to your computer and use it in GitHub Desktop.
About LangTrace

url::Langtrace

pip install langtrace-python-sdk

Must precede any llm module imports

from langtrace_python_sdk import langtrace langtrace.init(api_key = 'd14167f87f6d8eefc3fcdd1acd9ef3eda021bcb95f83f2b4448556cc324507e4')

from langtrace_python_sdk import langtrace from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span

Paste this code after your langtrace init function

from openai import OpenAI

langtrace.init( api_key="d14167f87f6d8eefc3fcdd1acd9ef3eda021bcb95f83f2b4448556cc324507e4" )

@with_langtrace_root_span() def example(): client = OpenAI() response = client.chat.completions.create( model="gpt-3.5-turbo", messages=[ { "role": "system", "content": "How many states of matter are there?" } ], ) print(response.choices[0].message.content)

example()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment