murphynetworks's picture
Simplify app.py to display CLI instructions instead of web interface
cf1596c
Raw History Blame Contribute Delete
3.24 kB
import os
import gradio as gr
from dotenv import load_dotenv
# Load environment variables (if available)
try:
load_dotenv()
except:
pass
# --- Build Gradio Interface using Blocks ---
with gr.Blocks() as demo:
gr.Markdown("# Enhanced Agent for API Question Evaluation")
gr.Markdown(
"""
## CLI-Based Enhanced Agent
This enhanced agent is designed to be run from the command line rather than through a web interface.
It features specialized tools for handling different types of data and performing various tasks
to effectively answer questions from the evaluation API.
### Key Features
- **Multiple Specialized Tools**: Web search, Excel analysis, audio transcription, code execution, and more
- **File Attachment Handling**: Automatically downloads and processes file attachments from the API
- **Minimal Answer Enforcement**: Ensures answers are concise and match the expected format
- **Robust Error Handling**: Prevents crashes with fallbacks for all tool operations
### Running the Agent
To run the agent, please use the command-line interface:
```bash
# Run the evaluation against the API
python run_enhanced_evaluation.py
# Use a different model
python run_enhanced_evaluation.py --model anthropic/claude-3-opus-20240229
# Run with parallel workers (experimental)
python run_enhanced_evaluation.py --workers 2
# Provide username and code link via command line
python run_enhanced_evaluation.py --username "YourName" --code-link "https://github.com/yourusername/your-repo"
```
### Testing the Agent
You can also test the agent with various question types:
```bash
# Run tests with basic questions
python test_enhanced_agent.py
# Test with a specific model
python test_enhanced_agent.py --model openai/gpt-4o
```
### Repository
For more details, please check the [GitHub repository](https://github.com/yourusername/your-repo).
"""
)
if __name__ == "__main__":
print("\n" + "-"*30 + " App Starting " + "-"*30)
# Check for SPACE_HOST and SPACE_ID at startup for information
space_host_startup = os.getenv("SPACE_HOST")
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
if space_host_startup:
print(f"✅ SPACE_HOST found: {space_host_startup}")
print(f" Runtime URL should be: https://{space_host_startup}.hf.space")
else:
print("ℹ️ SPACE_HOST environment variable not found (running locally?).")
if space_id_startup: # Print repo URLs if SPACE_ID is found
print(f"✅ SPACE_ID found: {space_id_startup}")
print(f" Repo URL: https://huggingface.co/spaces/{space_id_startup}")
print(f" Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main")
else:
print("ℹ️ SPACE_ID environment variable not found (running locally?). Repo URL cannot be determined.")
print("-"*(60 + len(" App Starting ")) + "\n")
print("Launching Gradio Interface...")
demo.launch(debug=True, share=False)