OpenTelemetry instrumentation for Groq
Project description
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)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traceai_groq-0.1.8.tar.gz.
File metadata
- Download URL: traceai_groq-0.1.8.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ab3726062f87ffe77e3ad0c06a81c86701690b0380fcf257da1273f2ce27570
|
|
| MD5 |
d8f5a439b22ab89a32847a4989084973
|
|
| BLAKE2b-256 |
3e3884a1f8573dd7224591c5f271d1ad57d897aa61fee0aa52ce3749653697e7
|
File details
Details for the file traceai_groq-0.1.8-py3-none-any.whl.
File metadata
- Download URL: traceai_groq-0.1.8-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ad50c8b377c71cd3569361e02000b6aa40f368928afab735940c615004a67fe
|
|
| MD5 |
fbfa7f1f6f7c490e9e80be8a198c2b4a
|
|
| BLAKE2b-256 |
8e27bf196e876159dc507d7e3fb9edd1452458cf8b9e8ce396b839a5d31431e5
|