Skip to content

Commit

Permalink
Merge pull request #10 from OpenBB-finance/feature/push-to-pypi
Browse files Browse the repository at this point in the history
[Feature] Publish to PyPI
  • Loading branch information
mnicstruwig authored Dec 13, 2023
2 parents 8f64e8d + a04ceab commit f936795
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 52 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish

on:
release:
types: [published]

jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Build
run: |
poetry build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
44 changes: 44 additions & 0 deletions openbb_agents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
import logging
import logging.config

from openbb_agents.utils import get_verbosity

VERBOSE = get_verbosity()

logging_config = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"json": {
"()": "pythonjsonlogger.jsonlogger.JsonFormatter",
"format": "%(asctime)s %(levelname)s %(name)s %(message)s",
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout", # Default is stderr
"formatter": "json",
},
},
"loggers": { # define loggers for specific modules
"openbb_agents.agent": {
"handlers": ["console"],
"level": "INFO",
"propagate": False,
},
"openbb_agents.utils": {
"handlers": ["console"],
"level": "ERROR",
"propagate": False,
},
"openbb_agents.chains": {
"handlers": ["console"],
"level": "INFO",
"propagate": False,
},
},
"root": { # root logger
"handlers": ["console"],
"level": "WARNING",
},
}

logging.config.dictConfig(logging_config)
6 changes: 2 additions & 4 deletions openbb_agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def openbb_agent(
answered_subquestions = []
for subquestion in subquestion_list.subquestions: # TODO: Do in parallel
# Fetch tool for subquestion
print(f"Attempting to select tools for: {subquestion.question}")
logger.info("Attempting to select tools for: %s", {subquestion.question})
selected_tools = select_tools(
vector_index=vector_index,
tools=tools,
Expand All @@ -70,10 +70,9 @@ def openbb_agent(
# TODO: Improve filtering of tools (probably by storing them in a dict)
tool_names = [tool.name for tool in selected_tools.tools]
subquestion_tools = [tool for tool in tools if tool.name in tool_names]
print(f"Retrieved tool(s): {tool_names}")
logger.info("Retrieved tool(s): %s", tool_names)

# Then attempt to answer subquestion
print(f"Attempting to answer question: {subquestion.question}")
answered_subquestion = generate_subquestion_answer(
SubQuestionAgentConfig(
query=query,
Expand All @@ -86,7 +85,6 @@ def openbb_agent(
verbose=verbose,
)
answered_subquestions.append(answered_subquestion)
print(answered_subquestion)

# Answer final question
return generate_final_response(
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.poetry]
name = "openbb-agents"
version = "0.1.0"
version = "0.0.2a"
description = "LLMs X OpenBB"
authors = ["Your Name <[email protected]>"]
authors = ["Michael Struwig <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
Expand All @@ -26,9 +26,6 @@ pre-commit = "^3.5.0"
ruff = "^0.1.7"
pytest = "^7.4.3"

[tool.isort]
profile = "black"

[tool.ruff.lint]
select = [
"E", # pycodestyle
Expand Down
43 changes: 0 additions & 43 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,7 @@
import argparse
import logging
import logging.config

from openbb_agents import agent

logging_config = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"json": {
"()": "pythonjsonlogger.jsonlogger.JsonFormatter",
"format": "%(asctime)s %(levelname)s %(name)s %(message)s",
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout", # Default is stderr
"formatter": "json",
},
},
"loggers": { # define loggers for specific modules
"openbb_agents.agent": {
"handlers": ["console"],
"level": "INFO",
"propagate": False,
},
"openbb_agents.utils": {
"handlers": ["console"],
"level": "ERROR",
"propagate": False,
},
"openbb_agents.chains": {
"handlers": ["console"],
"level": "INFO",
"propagate": False,
},
},
"root": { # root logger
"handlers": ["console"],
"level": "WARNING",
},
}

logging.config.dictConfig(logging_config)

parser = argparse.ArgumentParser(description="Query the OpenBB agent.")
parser.add_argument(
"query", metavar="query", type=str, help="The query to send to the agent."
Expand Down

0 comments on commit f936795

Please sign in to comment.