HydroGen-APP / groq_analysis.py
mjolnir1122's picture
Update groq_analysis.py
d045339 verified
raw
history blame contribute delete
730 Bytes
import requests
from config import GROQ_API_KEY
# Function to send hydrogen data to Groq's Llama 3 for analysis
def analyze_hydrogen_data(data):
prompt = f"Analyze the following hydrogen production dataset and provide insights: {data.to_string()}"
headers = {"Authorization": f"Bearer {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}", "Content-Type": "application/json"}
payload = {"messages": [{"role": "user", "content": prompt}], "model": "llama3-70b-8192"}
response = requests.post("https://api.groq.com/chat/completions", json=payload, headers=headers)
if response.status_code == 200:
return response.json()["choices"][0]["message"]["content"]
return "AI analysis failed."