Spaces:
Build error
Build error
Download agent.py from UnivAI/UnivAI-agents: direct link, hf CLI and curl.
- Browser
- Download file 896 Bytes
-
https://huggingface.co/spaces/UnivAI/UnivAI-agents/resolve/main/agent.py
- Command line
-
hf download hf://spaces/UnivAI/UnivAI-agents/agent.py
-
curl -L -o agent.py https://huggingface.co/spaces/UnivAI/UnivAI-agents/resolve/main/agent.py
896 Bytes
| 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 |