Groq OpenTelemetry Integration
Overview
This integration provides support for using OpenTelemetry with the Groq framework. It enables tracing and monitoring of applications built with Groq.
Installation
- Install traceAI Groq
pip install traceAI-groq
Set Environment Variables
Set up your environment variables to authenticate with FutureAGI.
import os
os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY
os.environ["GROQ_API_KEY"] = GROQ_API_KEY
Quickstart
Register Tracer Provider
Set up the trace provider to establish the observability pipeline. The trace provider:
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="groq_app"
)
Configure Groq Instrumentation
Instrument the Groq client to enable telemetry collection. This step ensures that all interactions with the Groq SDK are tracked and monitored.
from groq import Groq
def test():
client = Groq(
api_key=os.environ.get("GROQ_API_KEY"),
)
weather_function = {
"type": "function",
"function": {
"name": "get_weather",
"description": "finds the weather for a given city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city to find the weather for, e.g. 'London'",
}
},
"required": ["city"],
},
},
}
sys_prompt = "Respond to the user's query using the correct tool."
user_msg = "What's the weather like in San Francisco?"
messages = [
{"role": "system", "content": sys_prompt},
{"role": "user", "content": user_msg},
]
response = client.chat.completions.create(
model="mixtral-8x7b-32768",
messages=messages,
temperature=0.0,
tools=[weather_function],
tool_choice="required",
)
message = response.choices[0].message
assert (tool_calls := message.tool_calls)
tool_call_id = tool_calls[0].id
messages.append(message)
messages.append(
ChatCompletionToolMessageParam(
content="sunny", role="tool", tool_call_id=tool_call_id
),
)
final_response = client.chat.completions.create(
model="mixtral-8x7b-32768",
messages=messages,
)
return final_response
if __name__ == "__main__":
response = test()
print("Response\n")
print(response)
Metadata
Release files for traceAI-groq 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| traceai_groq-0.1.9.tar.gz | 9.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| traceai_groq-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.1 kB
Release files / traceai_groq-0.1.9.tar.gz
| Download URL | traceai_groq-0.1.9.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3028048000b38f28b24c38ac228f69aa50ed90c24875941fb6ccbfa4f2c61dd2
|
|
BLAKE2b-256 checksum How to use checksums |
8e3e598c3f339f116fd48f092e88bcdcd0eb17a7f5ce46c19ba6d8071209bcff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / traceai_groq-0.1.9-py3-none-any.whl
| Download URL | traceai_groq-0.1.9-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd777e4b0403ad496f1830b10af4c38496e0a358c709be9d23acd0374dd9945f
|
|
BLAKE2b-256 checksum How to use checksums |
4f5e4a9836d82bc9ddacf47cf293361848336c8516fcffe908a62ce764b6aa6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|