Groq delivers fast inference through its custom-designed ASIC chip and optimized software that leverages parallel processing, model pruning, and quantization to reduce inference times and increase throughput. Its software also uses just-in-time compilation, low-level optimization, and memory optimization to minimize latency and maximize performance.

With HoneyHive, you can trace all your operations using a single line of code. Find a list of all supported integrations here.

HoneyHive Setup

Follow the HoneyHive Installation Guide to get your API key and initialize the tracer.

Groq Setup

Go to the Groq Cloud Console to get your Groq API key.

Example

Here is an example of how to trace your code in HoneyHive.

from groq import Groq
import json

from honeyhive import HoneyHiveTracer, trace

HoneyHiveTracer.init(
    api_key="MY_HONEYHIVE_API_KEY",
    project="MY_HONEYHIVE_PROJECT_NAME",
)

client = Groq(
    api_key="MY_GROQ_API_KEY",
)

def evaluate_post(post: str) -> dict:
    evaluation_prompt = f"""
    Evaluate the following blog post based on these criteria (rate each from 1-5):
    1. Engagement: How well does it capture and maintain reader interest?
    2. Clarity: How clear and well-structured is the content?
    3. Value: How informative and valuable is the content?
    
    Blog post:
    {post}
    
    Respond in this exact JSON format:
    {{
        "engagement": <score>,
        "clarity": <score>,
        "value": <score>,
        "total": <sum of scores>
    }}
    """
    
    response = client.chat.completions.create(
        messages=[{"role": "user", "content": evaluation_prompt}],
        model="llama3-8b-8192",
        response_format={"type": "json_object"}
    )
    
    # Parse the response as a dictionary
    return json.loads(response.choices[0].message.content)

@trace
def generate_blog_post(topic: str) -> dict:
    prompt = f"Write a compelling blog post about {topic}. Make it engaging and informative."
    
    response = client.chat.completions.create(
        messages=[{"role": "user", "content": prompt}],
        model="llama3-8b-8192",
    )
    # Evaluate the generated post right away
    post = response.choices[0].message.content
    evaluation = evaluate_post(post)
    return {
        "content": post,
        "evaluation": evaluation
    }

def main():
    # Topics for blog posts
    topics = [
        "The Future of AI in Healthcare",
        "Sustainable Living in 2024",
        "Digital Privacy in the Modern Age",
        "The Rise of Remote Work",
        "Mindfulness and Technology Balance"
    ]
    
    # Generate blog posts
    print("Generating blog posts...")
    posts = [generate_blog_post(topic) for topic in topics]
    
    # Find the highest-rated post
    best_post_index = max(range(len(posts)), key=lambda i: posts[i]['evaluation']['total'])
    
    print("\nEvaluation Results:")
    for i, post in enumerate(posts):
        print(f"\nPost {i+1}: {topics[i]}")
        print(f"Engagement: {post['evaluation']['engagement']}")
        print(f"Clarity: {post['evaluation']['clarity']}")
        print(f"Value: {post['evaluation']['value']}")
        print(f"Total Score: {post['evaluation']['total']}")
    
    print("\n=== Best Rated Blog Post ===")
    print(f"Topic: {topics[best_post_index]}")
    print(posts[best_post_index]['content'])
    print(posts[best_post_index]['evaluation'])

main()

View your Traces

Once you run your code, you can view your execution trace in the HoneyHive UI by clicking the Data Store tab on the left sidebar.