Spaces:
Runtime error
A newer version of the Gradio SDK is available:
5.42.0
title: IFX-sandbox
emoji: π
colorFrom: red
colorTo: gray
sdk: gradio
app_file: gradio_app.py
pinned: false
49ers FanAI Hub - Gradio Version
This is a Gradio-based chatbot application that provides information about the San Francisco 49ers, players, games, and fans. The application uses LangChain, Neo4j, and Zep for memory management.
Features
- Chat interface for asking questions about the 49ers
- Integration with Neo4j graph database for structured data queries
- Vector search for finding game summaries
- Memory management with Zep for conversation history
- Game Recap component that displays visual information for game-related queries
Prerequisites
- Python 3.9+
- Neo4j database (local or Aura)
- OpenAI API key
- Zep API key
Installation
- Clone the repository
- Install the required packages:
pip install -r gradio_requirements.txt
- Set up your environment variables:
- Copy
.env.example
to.env
in the root directory - Fill in your API keys and credentials
- Copy
Example .env
file:
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4o
AURA_CONNECTION_URI=your_neo4j_uri
AURA_USERNAME=your_neo4j_username
AURA_PASSWORD=your_neo4j_password
ZEP_API_KEY=your_zep_api_key
IMPORTANT: Never commit your actual API keys or credentials to the repository. The
.env
files are included in.gitignore
to prevent accidental exposure of sensitive information.
Running the Application
To run the Gradio application:
python gradio_app.py
This will start the Gradio server and open the application in your default web browser.
Project Structure
gradio_app.py
: Main Gradio applicationgradio_agent.py
: Agent implementation using LangChain for Gradiogradio_graph.py
: Neo4j graph connection for Gradiogradio_llm.py
: Language model configuration for Gradiogradio_utils.py
: Utility functions for Gradioprompts.py
: System prompts for the agenttools/
: Specialized tools for the agentcypher.py
: Tool for Cypher queries to Neo4jvector.py
: Tool for vector search of game summariesgame_recap.py
: Tool for game recaps with visual component
components/
: UI componentsgame_recap_component.py
: Game recap visual component
data/
: Data files and scripts- Various scripts and CSV files with 49ers data
docs/
: Documentationrequirements.md
: Detailed product and technical requirementsgame_recap_implementation_instructions.md
: Implementation details for the game recap feature
Game Recap Component
The Game Recap feature provides visual information about games in addition to text-based summaries. When a user asks about a specific game, the application:
- Identifies the game being referenced
- Retrieves game data from the Neo4j database
- Displays a visual component with team logos, scores, and other game information
- Generates a text summary in the chat
Note: As mentioned in docs/game_recap_implementation_instructions.md
, this component is still a work in progress. Currently, it displays above the chat window rather than embedded within chat messages.
Security Considerations
This repository includes:
.gitignore
file to prevent committing sensitive information.env.example
files showing required environment variables without actual values- No hardcoded API keys or credentials in the code
Before pushing to a public repository:
- Ensure all sensitive information is in
.env
files (which are ignored by git) - Verify no API keys or credentials are hardcoded in any files
- Check that large data files or binary files are properly ignored if needed
Usage
- Start the application
- Ask questions about the 49ers, such as:
- "Who are the current players on the 49ers roster?"
- "Tell me about the 49ers game against the Chiefs"
- "Which fan communities have the most members?"
- "Show me the recap of the 49ers vs. Vikings game"
The application will use the appropriate tools to answer your questions based on the data in the Neo4j database.
Deployment
This application has been deployed to HuggingFace Spaces and is publicly available at: https://huggingface.co/spaces/aliss77777/ifx-sandbox
Deployment Steps
- Used Gradio's built-in deployment feature:
gradio deploy --app-file gradio_app.py --title "49ers FanAI Hub"
- Uploaded environment variables securely as Secrets in the HuggingFace Space
- Verified all API connections and data access on the deployed version
The deployment process automatically handles:
- Code upload to HuggingFace Spaces
- Installing dependencies from requirements.txt
- Building and serving the Gradio application
Final Checks
- Verified UI rendering and responsiveness
- Confirmed data accuracy and Neo4j connection
- Tested all features: chat, graph queries, and game recap functionality
- Documented any deployment-specific issues or limitations