Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .env-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

AGENT_NAME="crm_data_agent"
GOOGLE_GENAI_USE_VERTEXAI=1

GOOGLE_CLOUD_PROJECT="crm-data-agent"
GOOGLE_CLOUD_LOCATION="us-central1"
AI_STORAGE_BUCKET="my-crm-data-agent-bucket"

BQ_LOCATION="US"
SFDC_BQ_DATASET="sfdc_data"
FIRESTORE_SESSION_DATABASE="my-crm-data-agent-db"

SFDC_METADATA_FILE="sfdc_metadata.json"
FIRESTORE_EMULATOR_HOST=host.docker.internal:8080
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ data
.env
.vscode/
.DS_Store
google-cloud-sdk
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
crm-agent:
build:
context: ./src
dockerfile: Dockerfile
container_name: crm-agent
ports:
- "8000:8000"
env_file:
- .env
volumes:
- ./src:/app
depends_on:
- firebase-emulator
firebase-emulator:
image: node:18-slim
container_name: firebase-emulator
working_dir: /home/firebase
volumes:
- ./firebase:/home/firebase
command: >
sh -c "npm install -g firebase-tools &&
firebase emulators:start --only firestore --project fake-project --host 0.0.0.0"
ports:
- "4000:4000" # Emulator UI
- "8080:8080" # Firestore
12 changes: 12 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"emulators": {
"firestore": {
"port": 8080,
"host": "0.0.0.0"
},
"ui": {
"enabled": true,
"port": 4000
}
}
}
21 changes: 9 additions & 12 deletions src/.env-template
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
AGENT_NAME="crm_data_agent" # Agent Name. [REQUIRED]
GOOGLE_GENAI_USE_VERTEXAI=1 # Only tested with Gemini in Vertex AI. [REQUIRED]
AGENT_NAME="crm_data_agent"
GOOGLE_GENAI_USE_VERTEXAI=1

GOOGLE_CLOUD_PROJECT="" # Project Id for Vertex AI and Cloud Run. [REQUIRED]
GOOGLE_CLOUD_LOCATION="us-central1" # Cloud Region for Vertex AI and Cloud Run. [REQUIRED]
AI_STORAGE_BUCKET="" # Storage bucket for Artifacts Service and Vertex AI deployment operations. [REQUIRED]
GOOGLE_CLOUD_PROJECT="crm-data-agent"
GOOGLE_CLOUD_LOCATION="us-central1"
AI_STORAGE_BUCKET="my-crm-data-agent-bucket"

BQ_LOCATION="US" # BigQuery location [REQUIRED]
SFDC_BQ_DATASET="sfdc_data" # BigQuery Dataset with Salesforce data in SFDC_DATA_PROJECT_ID project. [REQUIRED]
# BQ_PROJECT_ID= # Project Id for executing BigQuery queries. (if empty, defaults to GOOGLE_CLOUD_PROJECT)
# SFDC_DATA_PROJECT_ID= # Project Id Salesforce Data in BigQuery. (if empty, defaults to BQ_PROJECT_ID/GOOGLE_CLOUD_PROJECT)
BQ_LOCATION="US"
SFDC_BQ_DATASET="sfdc_data"
FIRESTORE_SESSION_DATABASE="my-crm-data-agent-db"

FIRESTORE_SESSION_DATABASE="" # Firestore database name for storing session data [REQUIRED]

SFDC_METADATA_FILE="sfdc_metadata.json" # Salesforce Metadata file path. Do not change it if not using custom metadata.
SFDC_METADATA_FILE="sfdc_metadata.json"
13 changes: 10 additions & 3 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Copy source code into the container
COPY . /app

RUN pip install --no-cache-dir -r requirements.txt
# Install dependencies
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

EXPOSE 8080
# Expose app port
EXPOSE 8000

CMD uvicorn --app-dir web fast_api_runner:api_app --port 8000 --workers 16 & python3 web/main.py agents/data_agent local & wait
# Launch FastAPI + custom streamlit/app logic in parallel
CMD ["bash", "-c", "uvicorn --app-dir web fast_api_runner:api_app --port 8000 --workers 2 & python3 web/main.py agents/data_agent local & wait"]
16 changes: 13 additions & 3 deletions src/shared/firestore_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,23 @@

class FirestoreSessionService(BaseSessionService):
def __init__(self,
database: str,
sessions_collection: str = "/",
project_id: Optional[str] = None):
database: str,
sessions_collection: str = "/",
project_id: Optional[str] = None):

# Support Firestore Emulator if running locally
emulator_host = os.environ.get("FIRESTORE_EMULATOR_HOST")
if emulator_host:
os.environ["GOOGLE_CLOUD_PROJECT"] = os.environ.get("GOOGLE_CLOUD_PROJECT", "fake-project")
os.environ["FIRESTORE_EMULATOR_HOST"] = emulator_host
logger.info(f"Using Firestore Emulator at {emulator_host}")
else:
logger.info("Using Google Firestore in production mode")

self.client = Client(project_id, database=database)
self.sessions_collection = sessions_collection


@staticmethod
def _clean_app_name(name: str) -> str:
return name.rsplit("/", 1)[-1]
Expand Down