pip install "praisonaiagents[llm]"export HUGGINGFACE_API_KEY="your-key" # for CAJAL-4B via litellm# Optional fallback: export OPENAI_API_KEY="your-key"
2
Simple Scientific Writing
Create a specialized scientific writer agent:
from praisonaiagents import Agent, tool@tooldef format_latex_section(title: str, content: str) -> str: """Wrap prose in a LaTeX \\section{} block.""" return f"\\section{{{title}}}\n{content}\n"@tooldef format_citation(authors: str, year: int, title: str, venue: str) -> str: """Render an APA citation.""" return f"{authors} ({year}). {title}. *{venue}*."agent = Agent( name="Scientific Writer", instructions="You are a specialised scientific paper writer. Use LaTeX formatting and APA citations.", llm="huggingface/Agnuxo/CAJAL-4B-P2PCLAW", tools=[format_latex_section, format_citation],)agent.start( "Write a short paper (Abstract + Introduction + Conclusion) on " "'Climate change effects on coral reef biodiversity'.")
Swap llm="huggingface/Agnuxo/CAJAL-4B-P2PCLAW" for any other model (e.g. gpt-4o-mini) to use a general-purpose LLM if HuggingFace access is unavailable.
framework: praisonaitopic: "Climate change effects on coral reef biodiversity"roles: literature_reviewer: role: "Literature Reviewer" goal: "Survey recent academic work on {topic} and produce an APA review." backstory: "Expert in academic literature surveying and citation hygiene." llm: "gpt-4o-mini" tasks: review_literature: description: "Produce a concise literature review with 5-8 APA citations." expected_output: "APA-formatted literature review." methodology_designer: role: "Methodology Designer" goal: "Design a reproducible research methodology for {topic}." backstory: "Specialises in rigorous experimental design." llm: "gpt-4o-mini" tasks: design_methodology: description: "Write a reproducible methods section in LaTeX." expected_output: "LaTeX methods section." scientific_writer: role: "Scientific Writer" goal: "Assemble the final LaTeX paper on {topic}." backstory: >- Specialised in LaTeX-formatted academic papers, fine-tuned on scientific literature (CAJAL-4B checkpoint). llm: "huggingface/Agnuxo/CAJAL-4B-P2PCLAW" tasks: write_paper: description: >- Combine the literature review and methodology into a full scientific paper on {topic}. Use LaTeX formatting. expected_output: "Complete LaTeX paper."