Skip to content

Commit

Permalink
Merge pull request #288 from oshoma/run-make
Browse files Browse the repository at this point in the history
Run make to fix code style
  • Loading branch information
20001LastOrder authored Feb 7, 2024
2 parents 975d5d4 + e079b0f commit 2ae9578
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 38 deletions.
3 changes: 1 addition & 2 deletions src/apps/slackapp/slackapp/bolt_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
from sherpa_ai.scrape.prompt_reconstructor import PromptReconstructor
from sherpa_ai.task_agent import TaskAgent
from sherpa_ai.tools import get_tools
from sherpa_ai.utils import (count_string_tokens, log_formatter,
show_commands_only)
from sherpa_ai.utils import count_string_tokens, log_formatter, show_commands_only
from sherpa_ai.verbose_loggers import DummyVerboseLogger, SlackVerboseLogger
from sherpa_ai.verbose_loggers.base import BaseVerboseLogger

Expand Down
3 changes: 1 addition & 2 deletions src/sherpa_ai/database/user_usage_tracker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time

from sqlalchemy import (TIMESTAMP, Boolean, Column, Integer, String,
create_engine)
from sqlalchemy import TIMESTAMP, Boolean, Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

Expand Down
8 changes: 5 additions & 3 deletions src/sherpa_ai/memory/belief.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,18 @@ def get_internal_history(
return context

def get_histories_excluding_types(
self, token_counter: Callable[[str], int], exclude_type: [EventType] , max_tokens=4000
self,
token_counter: Callable[[str], int],
exclude_type: [EventType],
max_tokens=4000,
):
"""
Get the internal history of the agent with out events in the excluded_type
Args:
token_counter: Token counter
max_tokens: Maximum number of tokens
exclude_type: List of events to be excluded
exclude_type: List of events to be excluded
Returns:
str: Internal history of the agent
Expand All @@ -118,7 +121,6 @@ def get_histories_excluding_types(
break
context = "\n".join(set(reversed(results))) + "\n".join(set(feedback))
return context


def set_actions(self, actions: List[BaseAction]):
self.actions = actions
Expand Down
6 changes: 4 additions & 2 deletions src/sherpa_ai/models/chat_model_with_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import typing
from typing import Any, Coroutine, List, Optional

from langchain.callbacks.manager import (AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun)
from langchain.callbacks.manager import (
AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun,
)
from langchain.chat_models.base import BaseChatModel
from langchain.schema import BaseMessage, ChatResult
from loguru import logger
Expand Down
6 changes: 4 additions & 2 deletions src/sherpa_ai/models/sherpa_base_chat_model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import typing
from typing import Any, List, Optional

from langchain.callbacks.manager import (AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun)
from langchain.callbacks.manager import (
AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun,
)
from langchain.chat_models import ChatOpenAI
from langchain.chat_models.base import BaseChatModel
from langchain.schema import BaseMessage, ChatResult
Expand Down
6 changes: 4 additions & 2 deletions src/sherpa_ai/models/sherpa_base_model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import typing
from typing import Any, List, Optional

from langchain.callbacks.manager import (AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun)
from langchain.callbacks.manager import (
AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun,
)
from langchain.chat_models.base import BaseChatModel
from langchain.llms.openai import OpenAI
from langchain.schema import BaseMessage, ChatResult
Expand Down
2 changes: 1 addition & 1 deletion src/sherpa_ai/output_parsers/citation_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def split_paragraph_into_sentences(self, paragraph):

# add citation to the generated text
def parse_output(self, generated: str, resources: list[dict]) -> ValidationResult:
"""
"""
Add citation to each sentence in the generated text from resources based on fact checking model.
Args:
generated (str): The generated content where we need to add citation/reference
Expand Down
3 changes: 1 addition & 2 deletions src/sherpa_ai/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from typing import Any, Callable, List

from langchain.prompts.chat import BaseChatPromptTemplate
from langchain.schema import (AIMessage, BaseMessage, HumanMessage,
SystemMessage)
from langchain.schema import AIMessage, BaseMessage, HumanMessage, SystemMessage
from langchain.vectorstores.base import VectorStoreRetriever
from loguru import logger
from pydantic import BaseModel
Expand Down
2 changes: 1 addition & 1 deletion src/sherpa_ai/scrape/extract_github_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def extract_github_readme(repo_url):
response = requests.get(github_api_url, headers=headers)

files = response.json()
if(type(files) is dict and files.message == 'Bad Credentials'):
if type(files) is dict and files.message == "Bad Credentials":
return None
matching_files = [
file["name"]
Expand Down
9 changes: 6 additions & 3 deletions src/sherpa_ai/scrape/file_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import requests

import sherpa_ai.config as cfg
from sherpa_ai.utils import (chunk_and_summarize_file, count_string_tokens,
extract_text_from_pdf,
question_with_file_reconstructor)
from sherpa_ai.utils import (
chunk_and_summarize_file,
count_string_tokens,
extract_text_from_pdf,
question_with_file_reconstructor,
)


class QuestionWithFileHandler:
Expand Down
10 changes: 7 additions & 3 deletions src/sherpa_ai/scrape/prompt_reconstructor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import sherpa_ai.config as cfg
from sherpa_ai.scrape.extract_github_readme import extract_github_readme
from sherpa_ai.utils import (chunk_and_summarize, count_string_tokens,
get_link_from_slack_client_conversation,
rewrite_link_references, scrape_with_url)
from sherpa_ai.utils import (
chunk_and_summarize,
count_string_tokens,
get_link_from_slack_client_conversation,
rewrite_link_references,
scrape_with_url,
)


class PromptReconstructor:
Expand Down
9 changes: 7 additions & 2 deletions src/sherpa_ai/task_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
from langchain.chains.llm import LLMChain
from langchain.chat_models.base import BaseChatModel
from langchain.llms.base import BaseLLM
from langchain.schema import (AIMessage, BaseMessage, Document, HumanMessage,
SystemMessage)
from langchain.schema import (
AIMessage,
BaseMessage,
Document,
HumanMessage,
SystemMessage,
)
from langchain.tools.base import BaseTool
from langchain.tools.human.tool import HumanInputRun
from langchain.vectorstores.base import VectorStoreRetriever
Expand Down
4 changes: 2 additions & 2 deletions src/sherpa_ai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,5 @@ def check_if_number_exist(result: str, source: str):
for numbers in error_numbers:
message += numbers + ", "
message = f"Don't use the numbers {message} to answer the question instead stick to the numbers mentioned in the context."
return {"number_exists": False , "messages":message}
return {"number_exists": True , "messages":message}
return {"number_exists": False, "messages": message}
return {"number_exists": True, "messages": message}
8 changes: 5 additions & 3 deletions src/sherpa_ai/verbose_loggers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from sherpa_ai.verbose_loggers.verbose_loggers import (DummyVerboseLogger,
SlackVerboseLogger,
StorageVerboseLogger)
from sherpa_ai.verbose_loggers.verbose_loggers import (
DummyVerboseLogger,
SlackVerboseLogger,
StorageVerboseLogger,
)

__all__ = [
"DummyVerboseLogger",
Expand Down
10 changes: 8 additions & 2 deletions src/tests/integration_tests/test_plan_critics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
import pytest
from loguru import logger

from sherpa_ai.agents import (AgentPool, Critic, MLEngineer, Physicist,
Planner, UserAgent)
from sherpa_ai.agents import (
AgentPool,
Critic,
MLEngineer,
Physicist,
Planner,
UserAgent,
)
from sherpa_ai.memory import SharedMemory
from sherpa_ai.orchestrator import Orchestrator, OrchestratorConfig
from sherpa_ai.test_utils.llms import get_llm
Expand Down
1 change: 1 addition & 0 deletions src/tests/unit_tests/agents/test_planner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from sherpa_ai.agents.agent_pool import AgentPool
from sherpa_ai.agents.physicist import Physicist
from sherpa_ai.agents.planner import Planner

# from sherpa_ai.agents.programmer import Programmer
from sherpa_ai.memory.shared_memory import SharedMemory
from sherpa_ai.test_utils.llms import get_llm
Expand Down
3 changes: 1 addition & 2 deletions src/tests/unit_tests/output_parsers/test_output_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

from sherpa_ai.output_parser import (TaskAction, TaskOutputParser,
preprocess_json_input)
from sherpa_ai.output_parser import TaskAction, TaskOutputParser, preprocess_json_input


@pytest.mark.parametrize(
Expand Down
14 changes: 10 additions & 4 deletions src/tests/unit_tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

import pytest

from sherpa_ai.utils import (check_if_number_exist, extract_numbers_from_text,
get_base_url, get_links_from_string,
log_formatter, rewrite_link_references,
scrape_with_url, show_commands_only)
from sherpa_ai.utils import (
check_if_number_exist,
extract_numbers_from_text,
get_base_url,
get_links_from_string,
log_formatter,
rewrite_link_references,
scrape_with_url,
show_commands_only,
)


def test_get_links_from_string_succeeds():
Expand Down

0 comments on commit 2ae9578

Please sign in to comment.