CoolFace
Apppublic

polojuan/agentic-workflows

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
editor_agent.py31 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 editor_agent(task: str, model: str = "gpt-5-mini") -> str:9    """10    Executes editorial tasks such as reflection, critique, or revision.11    """12    # Get client from session state13    client = st.session_state.get("client") or OpenAI()14 15    print("==================================")16    print("🧠 Editor Agent")17    print("==================================")18    messages = [19        {"role": "system", "content": "You are an editor agent. Your job is to reflect on, critique, or improve existing drafts. DO NOT provde 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 31