Skip to content

Latest commit

 

History

History
123 lines (100 loc) · 2.72 KB

README.md

File metadata and controls

123 lines (100 loc) · 2.72 KB

Backend

Backend part contains basic infastructure for POC your ideas.

You can find there two main features

  1. Process from frontend to backend text to text content
  2. Process from frontend to backend image to text content

Tools used

  • FastAPI: Modern, fast (high-performance) Python web framework
  • Anthropic: AI integration for advanced natural language processing

Structure

backend/
├── app/
│   ├── api/
│   │   └── chat.py
│   ├── core/
│   │   ├── config.py 
│   │   └── logging.py
│   ├── models/
│   │   └── request_models.py
│   ├── services/
│   │   └── anthropic_service.py
│   ├── utils/
│   │   └── prompt.py
│   └── main.py
├── .env.example
├── docker-compose.yml
├── Dockerfile
├── README.md
├── Requirements.txt
└── setup.sh

Getting Started

Run the development server:

fastapi dev ./app/main.py

Serving at: http://localhost:8000

API docs: http://localhost:8000/docs

Development on a Cloud Server

For remote development, you will need:

  • Server Access (ssh user@ip & password || SSH key)
  • Visual Studio Code

Pre-installed software on the server:

  • vim
  • build-essential
  • python3
  • python3-venv
  • docker-ce
  • docker-ce-cli
  • docker-buildx-plugin
  • docker-compose-plugin

Running Docker Container

To deploy a container to a cloud server, you will need:

  1. In the Makefile, add USERNAME and REPO to the existing tokens:
USERNAME=UserNameDockerHub
REPO=RepositoryNameDockerHub
TAG=v1
TELEGRAM_BOT_TOKEN=1235
OPENAI_API_KEY=1234
  1. Make sure your ANTHROPIC_API_KEY in .env
  2. Build the image for Linux
make build_docker
  1. Run the container with the application
make run_docker
  1. Also, you can publish the image on DockerHub
make push_docker

Downloading and Running the Published Image

  1. Log into the server
ssh -i PATH_TO_YOUR_KEY.pem ubuntu@SERVER_IP_ADDRESS
  1. Find the published image on DockerHub:
docker search username/projectname
  1. Download the image:
docker pull username/projectname:v1
  1. Run the container with Telegram bot and OpenAI API tokens:
sudo docker run -d -p 8000:8000 -e ANTHROPIC_API_KEY=YOUR_API_KEY ContainerID

DONE