Skip to content

Commit

Permalink
Merge pull request #17 from 8090-inc/develop
Browse files Browse the repository at this point in the history
2024-09-24 Release
  • Loading branch information
chrislott authored Sep 24, 2024
2 parents fd43b95 + b7379a2 commit 6715c96
Show file tree
Hide file tree
Showing 157 changed files with 17,615 additions and 452 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build Docker Compose Projects

on:
push:
branches: [ main, test-workflow ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
get-project-list:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.dir-list.outputs.directories }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: 'recursive' # Add this line to checkout submodules

- name: Get list of directories
id: dir-list
run: echo "directories=$(ls -d */ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT

build-project:
needs: get-project-list
runs-on: ubuntu-latest
strategy:
matrix:
project: ${{fromJson(needs.get-project-list.outputs.projects)}}

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: 'recursive' # Add this line to checkout submodules

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Build and test ${{ matrix.project }}
run: |
echo "Building ${{ matrix.project }}"
cd ${{ matrix.project }}
cp env-example.txt .env
echo "Contents of ${{ matrix.project }}:"
ls -la
echo "Running docker-compose build"
docker-compose build --no-cache
cd ..
env:
ACTIONS_STEP_DEBUG: true
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
path = wolfram-assistant-app/xrx-core
url = https://github.com/8090-inc/xrx-core.git
branch = feature/refactor
[submodule "pizza-store/xrx-core"]
path = pizza-store/xrx-core
url = https://github.com/8090-inc/xrx-core.git
116 changes: 106 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,115 @@
# Reasoning
# Welcome to xRx
**Any modality input (x), reasoning (R), any modality output (x).**

This directory contains the reasoning applications for the xRx repository.
xRx is a framework for building AI-powered applications that interact with users across multiple modalities.

This repository contains the reasoning applications built on top of the xRx framework.

The reasoning systems process input, generate responses and manage the overall conversation flow within the xRx framework. Each subdirectory in this folder represents a different application, including a specific reasoning agent and an UI.

## Available Reasoning Applications
> **Documentation.** Check out the full documentation [here](https://8090-inc.github.io/xrx-core/).
1. [Simple Agent](./simple-agent): A basic template for creating custom reasoning agents.
2. [Shopify Agent](./shopify-agent): An agent designed to handle app-based interactions with a Shopify store.
3. [Wolfram Agent](./wolfram-assistant-agent): An agent designed to handle math and physics-based interactions.
4. [Template Agent](./template-agent): A starting point for developing new reasoning agents.
5. [Patient Information Agent](./patient-information-agent): An agent designed to collect and manage patient information before a doctor's visit.
## Available Reasoning Applications
1. [Simple App](./simple-app): A simple template for creating custom reasoning apps.
2. [Pizza Store](./pizza-store): An app designed to handle app-based interactions with a Pizza Store.
3. [Shopify App](./shopify-app): An app designed to handle app-based interactions with a Shopify store.
4. [Wolfram Assistant App](./wolfram-assistant-app): An app designed to handle math and physics-based interactions.
5. [Patient Information App](./patient-information-app): An app designed to collect and manage patient information before a doctor's visit.

## Usage
To get started with xRx, follow these steps:

1. Clone the repository with its submodules using the following command:

```
git clone --recursive https://github.com/8090-inc/xrx-sample-apps.git
```
It's crucial to include the `--recursive` flag when cloning, as each application is built on top of a git submodule called `xrx-core`. This submodule contains the fundamental building blocks for the xRx framework.

2. Navigate to the cloned repository:

```
cd xrx-sample-apps
```

3. To use a specific reasoning application:
- Navigate to the specific folder
- Set the `.env` variables
- Run the `docker compose` command
- Each application has its own set of environment variables. Refer to the `.env.example` file in each application's directory for the required variables.

> **Note:** We suggest opening only that specific folder in your IDE for a cleaner workspace.
4. Continue following the instructions in the README file of the specific application you are interested in.

For more detailed information on how to implement and use these reasoning systems, please refer to the README files within each application's subdirectory.

## Contributing
We welcome contributions to the xRx framework and its sample applications. If you have any suggestions or improvements, please follow these steps:

1. Open a new issue on GitHub describing the proposed change or improvement
2. Fork the repository
3. Create a new branch for your feature
4. Commit your changes
5. Push to your branch
6. Create a pull request, referencing the issue you created

> **Note:** Pull requests not backed by published issues will not be considered. This process ensures that all contributions are discussed and aligned with the project's goals before implementation.
## GitHub Actions Workflow

This project uses a GitHub Actions workflow to automatically build and test Docker Compose projects in each subdirectory of the repository.

### Workflow Details

The workflow is defined in `.github/workflows/build-docker-compose.yml` and does the following:

1. Triggers on:
- Push to `main` or `test-workflow` branches
- Pull requests to `main` branch
- Manual dispatch

2. For each subdirectory in the repository root:
- Builds the Docker Compose project
- Starts the containers
- Stops and removes the containers

### Testing the Workflow

To test the GitHub Actions workflow:

1. **Push to test-workflow branch**: Make changes and push to the `test-workflow` branch to trigger the workflow.

2. **Create a Pull Request**: Open a PR to the `main` branch to trigger the workflow.

3. **Manual Trigger**:
- Go to the Actions tab in the GitHub repository
- Select "Build Docker Compose Projects" workflow
- Click "Run workflow" and select the branch to run on

4. **Local Testing with Act**:
If you have [Act](https://github.com/nektos/act) installed, you can test locally:
```
act push
```

### Workflow Configuration

The workflow uses the following Docker Compose flags:
- `--build`: Build images before starting containers
- `--no-cache`: Do not use cache when building images
- `--force-recreate`: Recreate containers even if their configuration hasn't changed
- `--renew-anon-volumes`: Recreate anonymous volumes
- `--remove-orphans`: Remove containers for services not defined in the Compose file

### Debugging

The workflow has debug logging enabled. Check the workflow run logs in the GitHub Actions tab for detailed output.

## Project Structure

Ensure each subdirectory that should be built has a valid `docker-compose.yml` file.

To use a specific reasoning application, you need to go into the specific folder, set the `.env` variables and run the `docker compose`.
## Updates

For more detailed information on how to implement and use these reasoning systems, please refer to the README files within each application's subdirectory.
- 2024-09-23: We are temporarily removing the guardrails proxy and reasoning service from the docker compose setup, due to breaking changes from guardrailsai.
71 changes: 44 additions & 27 deletions patient-information-app/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# Patient Information Agent
# Patient Information App

## Overview

This project features a reasoning agent designed to gather patient information before a doctor's visit. The agent interacts with patients through a conversational interface, collecting essential details such as name, date of birth, allergies, current medications, and reason for visit. This agent is integrated into the xRx framework, providing a seamless experience for patient intake.
This project features a reasoning agent designed to gather patient information before a doctor's visit. The agent interacts with patients through a conversational interface, collecting essential details such as name, date of birth, allergies, current medications, and reason for visit. This agent is built on top of the xRx framework, providing a seamless experience for patient intake.

## Getting Started

### Prerequisites
* We assume you have already cloned the repository, as explained in the general README. For the sake of clarity, here's the command again:
```
git clone --recursive https://github.com/8090-inc/xrx-sample-apps.git
```

Install Docker, Python3, and Pip3 with homebrew on macOS or apt-get update on Debian/Ubuntu based Linux systems:
* If the submodule was not installed, or you want to update it, use the following command:
```
git submodule update --init --recursive
```

```bash
brew cask install docker
brew install [email protected]
```
* Install `Docker`, `Python3`, and `Pip3` with [homebrew](https://formulae.brew.sh/) on macOS or `apt-get update` on Debian/Ubuntu based Linux systems:
```bash
brew cask install docker
brew install [email protected]
```

## How To Run

Expand All @@ -26,10 +34,10 @@ brew install [email protected]

2. Run the container:
```bash
docker run -p 8093:8093 --env-file .env patient-information-agent:latest
docker run -p 8003:8003 --env-file .env patient-information-agent:latest
```

The agent will be accessible at http://localhost:8093.
The agent will be accessible at http://localhost:8003.

### Locally without Docker

Expand All @@ -50,22 +58,28 @@ The agent will be accessible at http://localhost:8093.
4. Run the application:
```bash
cd app
uvicorn main:app --host 127.0.0.1 --port 8093 --reload
uvicorn main:app --host 127.0.0.1 --port 8003 --reload
```

The agent will now be running at http://localhost:8093
The agent will now be running at http://localhost:8003

## Project Structure

- `app/`: Contains the main application code
- `main.py`: FastAPI application setup and endpoint definition
- `agent/`: Core agent logic
- `executor.py`: Main agent execution logic
- `utils/`: Utility functions and LLM integration
- `context_manager.py`: Manages session context
- `requirements.txt`: Python dependencies
- `Dockerfile`: Docker configuration for containerization
- `reasoning/`: Contains the main application code
- `app/`: backend application folder
- `agent/`: agent logic
- `context_manager.py`: Manages session context
- `executor.py`: Main agent execution logic
- `__init__.py`: Initializes the app module
- `main.py`: FastAPI application setup and endpoint definition
- `Dockerfile`: Docker configuration for containerization
- `requirements.txt`: Python dependencies
- `nextjs-client/`: Next.js frontend for the patient intake application
- `test/`: Contains test files
- `xrx-core/`: Core xRx framework (submodule)
- `docker-compose.yaml`: Docker Compose configuration file
- `env-example.txt`: Example environment variables file
- `README.md`: Project documentation

## API Usage

Expand All @@ -76,7 +90,7 @@ The agent exposes a single endpoint using FastAPI:
### Example request using curl

```bash
curl -X POST http://localhost:8093/run-reasoning-agent \
curl -X POST http://localhost:8003/run-reasoning-agent \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{
Expand All @@ -86,7 +100,7 @@ curl -X POST http://localhost:8093/run-reasoning-agent \
"messages": [
{"role": "user", "content": "Hi, I'm here for my appointment."}
]
}'
}
```
### Example request using Python's requests library with streaming
Expand All @@ -95,7 +109,7 @@ curl -X POST http://localhost:8093/run-reasoning-agent \
import requests
import json
url = "http://localhost:8093/run-reasoning-agent"
url = "http://localhost:8003/run-reasoning-agent"
headers = {
"Content-Type": "application/json",
"Accept": "text/event-stream",
Expand Down Expand Up @@ -159,8 +173,11 @@ The frontend will be available at http://localhost:3000.
Contributions to improve the Patient Information Agent are welcome. Please follow these steps:
1. Fork the repository
2. Create a new branch for your feature
3. Commit your changes
4. Push to your branch
5. Create a pull request
1. Open a new issue on GitHub describing the proposed change or improvement
2. Fork the repository
3. Create a new branch for your feature
4. Commit your changes
5. Push to your branch
6. Create a pull request, referencing the issue you created
> **Note:** pull requests not backed by published issues will not be considered. This process ensures that all contributions are discussed and aligned with the project's goals before implementation.
22 changes: 11 additions & 11 deletions patient-information-app/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ services:
networks:
- xrx_network

xrx-guardrails:
container_name: xrx-guardrails
build:
context: ./xrx-core/guardrails-proxy
dockerfile: Dockerfile
ports:
- 8004:8004
env_file:
- .env
networks:
- xrx_network
# xrx-guardrails:
# container_name: xrx-guardrails
# build:
# context: ./xrx-core/guardrails-proxy
# dockerfile: Dockerfile
# ports:
# - 8004:8004
# env_file:
# - .env
# networks:
# - xrx_network

xrx-redis:
image: "redis:alpine"
Expand Down
Loading

0 comments on commit 6715c96

Please sign in to comment.