File size: 3,242 Bytes
10e9b7d
 
8e01d85
 
cf1596c
 
 
 
 
10e9b7d
cf1596c
 
 
8e01d85
cf1596c
 
 
4021bf3
cf1596c
 
 
3c4371f
cf1596c
3c4371f
cf1596c
 
 
 
e80aab9
cf1596c
3c4371f
cf1596c
e80aab9
cf1596c
 
 
31243f4
cf1596c
 
31243f4
cf1596c
 
e80aab9
cf1596c
 
 
e80aab9
cf1596c
e80aab9
cf1596c
e514fd7
cf1596c
 
 
e80aab9
cf1596c
 
 
e80aab9
cf1596c
e80aab9
cf1596c
 
e80aab9
cf1596c
e80aab9
3c4371f
7d65c66
3c4371f
7d65c66
 
3c4371f
 
7d65c66
3c4371f
7d65c66
 
 
 
 
 
 
 
 
3c4371f
 
cf1596c
3c4371f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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)