Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codespell support (config, workflow to detect/not fix) and make it fix few typos #296

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = .git*,*.pdf,*.svg,.codespellrc
check-hidden = true
# ignore-regex =
# ignore-words-list =
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within .codespellrc
---
name: Codespell

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ repos:
entry: black
args: ["knowledge_storm/"]
language: python
pass_filenames: true
pass_filenames: true
- repo: https://github.com/codespell-project/codespell
# Configuration for codespell is in .codespellrc
rev: v2.3.0
hooks:
- id: codespell
2 changes: 1 addition & 1 deletion examples/storm_examples/run_storm_wiki_serper.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def main(args):
# Important to note that tbs(date range is hardcoded values).
# num is results per pages and is recommended to use in increments of 10(10, 20, etc).
# page is how many pages will be searched.
# h1 is where the google search will orginate from.
# h1 is where the google search will originate from.
topic = input("topic: ")
data = {"autocorrect": True, "num": 10, "page": 1}
rm = SerperRM(serper_search_api_key=os.getenv("SERPER_API_KEY"), query_params=data)
Expand Down
2 changes: 1 addition & 1 deletion frontend/demo_light/pages_util/CreateNewArticle.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def handle_final_writing():

# update status bar
st.session_state["page3_write_article_state"] = "prepare_to_show_result"
status.update(label="information snythesis complete!", state="complete")
status.update(label="information synthesis complete!", state="complete")

def handle_prepare_to_show_result():
if st.session_state["page3_write_article_state"] == "prepare_to_show_result":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GenExpertActionPlanning(dspy.Signature):
last_utterance = dspy.InputField(
prefix="Last utterance in the conversation: \n", format=str
)
resposne = dspy.OutputField(
response = dspy.OutputField(
prefix="Now give your note. Start with one of [Original Question, Further Details, Information Request, Potential Answer] with one sentence description\n",
format=str,
)
Expand Down Expand Up @@ -126,7 +126,7 @@ def forward(
expert=current_expert,
summary=conversation_summary,
last_utterance=last_utterance,
).resposne
).response
action_type, action_content = self.parse_action(action)

if self.callback_handler is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _get_navigation_choice(
if child_names:
structure += f"Child Nodes: {child_names}"
navigated_path = " -> ".join(knowledge_node.get_path_from_root())
structure += f"Path you have nagivated: {navigated_path}"
structure += f"Path you have navigated: {navigated_path}"

# get predicted action
with dspy.settings.context(lm=self.engine):
Expand Down
2 changes: 1 addition & 1 deletion knowledge_storm/lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def __call__(self, prompt, only_completed=True, return_sorted=False, **kwargs):
assert return_sorted is False, "for now"
# per eg here: https://docs.anthropic.com/claude/reference/messages-examples
# max tokens can be used as a proxy to return smaller responses
# so this cannot be a proper indicator for incomplete response unless it isnt the user-intent.
# so this cannot be a proper indicator for incomplete response unless it isn't the user-intent.
n = kwargs.pop("n", 1)
completions = []
for _ in range(n):
Expand Down
2 changes: 1 addition & 1 deletion knowledge_storm/storm_wiki/modules/storm_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def pre_order_find_index(node):
pre_order_find_index(child)

pre_order_find_index(self.root)
# constrcut index mapping
# construct index mapping
ref_index_mapping = {}
for ref_index in ref_indices:
if ref_index not in ref_index_mapping:
Expand Down