CoolFace
Apppublic

Akshay66777/agentscope-chat

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes
App README

AgentScope Chat on Hugging Face Spaces

A single-file Gradio app running an AgentScope Agent in-process — no FastAPI server, no React frontend, just Gradio + AgentScope. That makes it eligible for HF Spaces' free zero-a10g (ZeroGPU) hardware.

Features

  • —Streaming chat with an AgentScope ReActAgent
  • —Built-in tools: bash, read, write, edit, glob, grep — the agent can read and modify files in its workspace
  • —OpenAI-compatible: works with OpenAI or any OpenAI-compatible endpoint (set OPENAI_BASE_URL)
  • —MCP / custom skills / custom OpenAI-compatible API: all supported by AgentScope's framework — extend app.py to wire them in

Setup (Hugging Face Spaces)

  1. 1.Create a Space with SDK = Gradio and hardware = ZeroGPU (free)
  2. 2.Add these Secrets under Settings → Variables and secrets:
SecretRequiredDefaultPurpose
OPENAI_API_KEY✅—Your OpenAI (or compatible) API key
OPENAI_BASE_URL❌https://api.openai.com/v1Set to your OpenAI-compatible endpoint
MODEL_NAME❌gpt-4o-miniModel name to call
SYSTEM_PROMPT❌helpful assistantCustom system prompt
AGENT_NAME❌AgentScopeAgent display name
WORKDIR❌/tmp/agentscope-workdirWorkspace directory for file tools
  1. 1.Push these files to the Space:
  2. 2.app.py — the Gradio app
  3. 3.requirements.txt — Python deps
  4. 4.pyproject.toml — AgentScope package metadata
  5. 5.src/ — the AgentScope source (installed editable)
  6. 6.README.md — this file (Space frontmatter above)
  1. 1.The Space auto-builds and serves the app on port 7860.

Local run

bash
cd /home/z/my-project/agentscope
pip install -e ".[rag,tools]"
pip install -r requirements.txt
export OPENAI_API_KEY=sk-...
python app.py
# → http://localhost:7860

Extending

The app is a single app.py — edit freely:

  • —Add MCP servers → pass mcps=[MCPClient(...)] to Toolkit(...) (see agentscope.mcp.StdioMCPConfig / HttpMCPConfig)
  • —Add custom skills → pass skills_or_loaders=["/path/to/skill-dir"] to Toolkit(...) (skill dir must contain SKILL.md)
  • —Add custom tools → subclass agentscope.tool.ToolBase and add to the tools=[...] list
  • —Stream tokens → swap agent.reply() for agent.reply_stream() and yield chunks into the Gradio chatbot
  • —Add long-term memory → pass middlewares=[Mem0Middleware(...)] to Agent(...)

Source

Upstream: https://github.com/agentscope-ai/agentscope