Space Usage Guide

GitCode AI Space is a powerful online application deployment and sharing platform that allows you to easily transform AI models into interactive web applications. This guide will help you understand how to create and manage Spaces.

Space Creation

Create New Space

  1. Login to your GitCode AI account
  2. Go to “Space” > “Create Space”
  3. Fill in basic information:
    • Space name
    • Description
    • Tags
    • Visibility settings
  4. Select Space type:
    • Gradio application
    • Streamlit application
    • Docker container
    • Static website
  5. Configure hardware resources:
    • CPU
    • Memory
    • GPU (if needed)
  6. Click “Create” to complete

[Image: Space creation page screenshot]

Space Configuration File

Create a space-config.yaml file to define Space configuration:

space-name: my-awesome-app
version: 1.0.0
sdk: gradio
python_version: "3.9"
requirements:
  - gradio>=3.50.0
  - torch>=2.0.0
resources:
  cpu: 1
  memory: 2GB
  gpu: null
  1. Enter keywords in the search box
  2. Use filters:
    • Application type
    • Framework
    • Resource requirements
    • Access volume
    • Update time

Space Activation

Through Web Interface

  1. Go to Space details page
  2. Click “Activate” button
  3. Select deployment configuration:
    • Instance type
    • Auto-scaling settings
    • Environment variables

Space Usage

Development Mode

import gradio as gr

def greet(name):
    return f"Hello {name}!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")

# Local development
demo.launch()

# Deploy to Space
demo.deploy()

Docker Deployment

FROM python:3.9-slim

WORKDIR /app
COPY . .
RUN pip install -r requirements.txt

EXPOSE 7860
CMD ["python", "app.py"]

Environment Variable Configuration

# Set environment variables
export MODEL_PATH=/path/to/model
export API_KEY=your-api-key

# Use environment variables
import os
model_path = os.getenv("MODEL_PATH")

Best Practices

  1. Application Development

    • Use responsive design
    • Add error handling
    • Optimize loading performance
    • Provide user guides
  2. Resource Management

    • Reasonably configure resources
    • Use caching mechanisms
    • Monitor resource usage
    • Auto-scaling settings
  3. Security

    • Input validation
    • Access control
    • Data encryption
    • Logging
  4. Maintenance Updates

    • Version control
    • Automated testing
    • Monitoring alerts
    • Regular dependency updates

Common Questions

Q: What programming languages does Space support?

A: Mainly supports Python, while other languages can be supported through Docker.

Q: How to handle Space performance issues?

A: Performance can be improved by optimizing code, using caching, adjusting resource configuration, etc.

Q: How to implement automatic Space updates?

A: You can configure GitHub Actions or use GitCode CI/CD for automatic deployment.

Q: What are Space access limitations?

A: Free accounts have monthly access volume and computing resource limitations. Please check the pricing page for specific limits.