Skip to content

Commit

Permalink
add poetry and update project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lynxrv21 committed Nov 2, 2023
1 parent ad02e19 commit f8d89eb
Show file tree
Hide file tree
Showing 33 changed files with 1,857 additions and 67 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install poetry
poetry install
- name: Analysing the code with pylint
run: |
black --check --diff .
isort --check --diff .
make style
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.PHONY: fmt check style verify tests
fmt: ## Format code with isort and blace
@echo "🚀 Formatting code: Running isort"
@poetry run isort .
@echo "🚀 Formatting code: Running black"
@poetry run black .

check: ## Run code quality tools.
@echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
@poetry check --lock
# @echo "🚀 Static type checking: Running mypy -p dream_team_gpt"
# @poetry run mypy -p dream_team_gpt

style: ## Run code style checks.
@echo "🚀 Checking code formatting with isort: Running isort --check --diff ."
@poetry run isort --check --diff .
@echo "🚀 Checking code formatting with black: Running black --check --diff ."
@poetry run black --check --diff .
# @echo "🚀 Static type checking: Running mypy -p dream_team_gpt"
# @poetry run mypy -p dream_team_gpt


test: ## Test the code with pytest
@echo "🚀 Testing code: Running pytest"
@poetry run pytest

verify: ## Run style and tests
check
style
tests

.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# DreamTeamGPT
# DreamTeamGPT 🤖🤖🤖

pick your dream executive team and watch them brainstorm your idea....
Pick your dream executive team and watch them brainstorm your idea....

## Installation

Create new virtual environment with python3.11
```bash
pip install poetry # install poetry
poetry install # install project dependencies

cp .env.template .env # .env is used for local environment variables
```

Update `.env` with your OpenAI API [key](https://platform.openai.com/)

After installation run
```bash
make verify
```

Before committing your updates don't forget to apply formatting
```bash
make fmt
```
## Usage

Use `run.sh` to make AI work on your idea:
```bash
./run.sh -i "profitable children's toy for Christmas"
```

<details> <summary>Output example</summary>

['profitable children's toy for Christmas.']

Expand Down Expand Up @@ -48,3 +78,11 @@ disruptions. Implement predictive analytics to anticipate demand, streamlining i
reliable, fast delivery options to enhance customer experience.
Ensure web platform can handle increased traffic and purchases. Prioritize customer feedback to quickly address issues
and maintain reputation.

</details>


Check `help` for more options:
```bash
./run.sh --help
```
1 change: 0 additions & 1 deletion constants.py

This file was deleted.

File renamed without changes.
2 changes: 2 additions & 0 deletions dream_team_gpt/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .chairman import Chairman
from .sme import SME
14 changes: 7 additions & 7 deletions agents/agent.py → dream_team_gpt/agents/agent.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from textwrap import dedent

from clients.base import AIClient
from constants import NO_COMMENT
from dream_team_gpt.clients.base import AIClient
from dream_team_gpt.constants import NO_COMMENT

DEFAULT_SYSTEM_PROMPT = dedent(
f"""\
Provide succinct, fact-based answers. Eliminate filler words and politeness.
Concentrate on delivering actionable insights and concrete solutions.
Avoid vague or generic statements. Stick to the topic at hand.
If your response doesn't meet these standards, reply with the exact words '{NO_COMMENT}'
"""
Provide succinct, fact-based answers. Eliminate filler words and politeness.
Concentrate on delivering actionable insights and concrete solutions.
Avoid vague or generic statements. Stick to the topic at hand.
If your response doesn't meet these standards, reply with the exact words '{NO_COMMENT}'
"""
)


Expand Down
6 changes: 3 additions & 3 deletions agents/chairman.py → dream_team_gpt/agents/chairman.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from loguru import logger

from agents.agent import Agent
from agents.sme import SME
from clients.base import AIClient
from dream_team_gpt.agents.agent import Agent
from dream_team_gpt.agents.sme import SME
from dream_team_gpt.clients.base import AIClient


class Chairman(Agent):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from textwrap import dedent

from agents.agent import Agent
from clients import AIClient
from dream_team_gpt.agents.agent import Agent
from dream_team_gpt.clients import AIClient

REFINER_PROMPT = dedent(
"""\
Expand Down
2 changes: 1 addition & 1 deletion agents/secretary.py → dream_team_gpt/agents/secretary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from agents.agent import Agent
from dream_team_gpt.agents.agent import Agent


class Secretary(Agent):
Expand Down
8 changes: 3 additions & 5 deletions agents/sme.py → dream_team_gpt/agents/sme.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from textwrap import dedent

from agents.agent import Agent
from clients.base import AIClient
from dream_team_gpt.agents.agent import Agent
from dream_team_gpt.clients.base import AIClient

USER_PROMPT_TEMPLATE = dedent(
"""\
Expand All @@ -18,9 +18,7 @@


class SME(Agent):
def __init__(
self, client: AIClient, name: str, expertise: str, concerns: list[str]
):
def __init__(self, client: AIClient, name: str, expertise: str, concerns: list[str]):
# Construct the user_prompt string
user_prompt = USER_PROMPT_TEMPLATE.format(
name=name, expertise=expertise, concerns=", ".join(concerns)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enum import Enum

from clients.base import AIClient
from clients.config import AIClientConfig
from clients.gpt_client import GPTClient
from dream_team_gpt.clients.base import AIClient
from dream_team_gpt.clients.config import AIClientConfig
from dream_team_gpt.clients.gpt_client import GPTClient


class AIClientType(str, Enum):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
import json
import time
from enum import Enum

import openai
from loguru import logger
import openai

from .base import AIClient

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions main.py → dream_team_gpt/main.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import os
from pathlib import Path
import os

import click
from dotenv import load_dotenv
import click

from agents.chairman import Chairman
from agents.idea_refiner import IdeaRefiner
from agents.sme import SME
from clients import AIClientConfig, AIClientType, get_ai_client
from constants import DEFAULT_SME_DICT, NO_COMMENT
from utils.logging import configure_logging
from utils.parse_config import parse_yaml_config
from utils.print_with_wrap import print_with_wrap
from dream_team_gpt.agents import SME, Chairman
from dream_team_gpt.agents.idea_refiner import IdeaRefiner
from dream_team_gpt.clients import AIClientConfig, AIClientType, get_ai_client
from dream_team_gpt.constants import DEFAULT_SME_DICT, NO_COMMENT
from dream_team_gpt.utils import configure_logging, parse_yaml_config, print_with_wrap


@click.command()
Expand All @@ -31,10 +28,13 @@
)
@click.option("-v", "--verbose", default=1, count=True)
def main(idea: str, config: Path = None, verbose: int = 1):

print(idea)
configure_logging(verbose)
load_dotenv()
client = get_ai_client(
AIClientType.ChatGPT, AIClientConfig(model="gpt-3.5-turbo", api_key=os.getenv("openai.api_key"))
AIClientType.ChatGPT,
AIClientConfig(model="gpt-3.5-turbo", api_key=os.getenv("openai.api_key")),
)
if config:
sme_dict = parse_yaml_config(config)
Expand Down
4 changes: 4 additions & 0 deletions dream_team_gpt/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .logging import configure_logging
from .parse_config import parse_yaml_config
from .print_with_wrap import print_with_wrap
from .token_counter import num_tokens_from_messages
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path

import yaml
from loguru import logger
import yaml


def parse_yaml_config(file_path: Path) -> list[dict]:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@ def num_tokens_from_messages(messages, model="gpt-3.5-turbo-0613"):
tokens_per_message = 3
tokens_per_name = 1
elif model == "gpt-3.5-turbo-0301":
tokens_per_message = (
4 # every message follows <|start|>{role/name}\n{content}<|end|>\n
)
tokens_per_message = 4 # every message follows <|start|>{role/name}\n{content}<|end|>\n
tokens_per_name = -1 # if there's a name, the role is omitted
elif "gpt-3.5-turbo" in model:
print(
"Warning: gpt-3.5-turbo may update over time. Returning num tokens assuming gpt-3.5-turbo-0613."
)
return num_tokens_from_messages(messages, model="gpt-3.5-turbo-0613")
elif "gpt-4" in model:
print(
"Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613."
)
print("Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613.")
return num_tokens_from_messages(messages, model="gpt-4-0613")
else:
raise NotImplementedError(
Expand Down
7 changes: 0 additions & 7 deletions logger_config.py

This file was deleted.

Loading

0 comments on commit f8d89eb

Please sign in to comment.