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.
Here is an example of how to trace your code in HoneyHive.
from groq import Groqimport jsonfrom honeyhive import HoneyHiveTracer, traceHoneyHiveTracer.init( api_key="MY_HONEYHIVE_API_KEY", project="MY_HONEYHIVE_PROJECT_NAME",)client = Groq( api_key="MY_GROQ_API_KEY",)defevaluate_post(post:str)->dict: evaluation_prompt =f""" Evaluate the following blog post based on these criteria (rate each from1-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 dictionaryreturn json.loads(response.choices[0].message.content)@tracedefgenerate_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}defmain():# 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 postsprint("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 inenumerate(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()