CoolFace
Apppublic

polojuan/agentic-workflows

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
writer_agent.py30 linesDownload Raw Back to agents
1import streamlit as st2from openai import OpenAI3from dotenv import find_dotenv, load_dotenv4 5# Load environment variables6load_dotenv(find_dotenv())7 8def writer_agent(task: str, model: str = "gpt-5-mini") -> str:9    """10    Executes writing tasks, such as drafting, expanding, or summarizing text.11    """12    # Get client from session state13    client = st.session_state.get("client") or OpenAI()14 15    print("==================================")16    print("✍️ Writer Agent")17    print("==================================")18    messages = [19        {"role": "system", "content": "You are a writing agent specialized in generating well-structured academic or technical content.  Report contents are recommended to be in paragraph form except for reference section. Reference shall have APA format citation with full links. DO NOT provide recommendations for the next steps at the end. DO NOT ask any questions on the next steps at the end."},20        {"role": "user", "content": task}21    ]22 23    response = client.chat.completions.create(24        model=model,25        messages=messages26    )27    used_tokens = response.usage.total_tokens28    print("Used Tokens:\n", used_tokens)29    return response.choices[0].message.content, used_tokens30