Spaces:
Build error
Build error
File size: 896 Bytes
6798e8f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import os
from groq import Groq
from dotenv import load_dotenv
from root_tools import gather_research
load_dotenv()
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
def generate_report(topic):
raw_content, sources = gather_research(topic) # unpack both now
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[
{
"role": "system",
"content": "You are an expert research analyst. Write clear structured reports."
},
{
"role": "user",
"content": f"Using this research data, write a detailed structured report on: {topic}\n\nData:\n{raw_content}"
}
]
)
report = response.choices[0].message.content
sources_section = "\n\n---\n## Sources\n" + "\n".join(sources)
return report + sources_section |