Skip to content

Commit

Permalink
Switch to ruff in pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcarroll committed Jan 25, 2024
1 parent 4052ae7 commit 3385dee
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.11
args: ["--line-length", "105"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: ruff
- id: ruff-format
1 change: 1 addition & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
line-length = 105
2 changes: 1 addition & 1 deletion pages/1_File_Q&A.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
response = client.completions.create(
prompt=prompt,
stop_sequences=[anthropic.HUMAN_PROMPT],
model="claude-v1", #"claude-2" for Claude 2 model
model="claude-v1", # "claude-2" for Claude 2 model
max_tokens_to_sample=100,
)
st.write("### Answer")
Expand Down
8 changes: 6 additions & 2 deletions pages/2_Chat_with_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from langchain.tools import DuckDuckGoSearchRun

with st.sidebar:
openai_api_key = st.text_input("OpenAI API Key", key="langchain_search_api_key_openai", type="password")
openai_api_key = st.text_input(
"OpenAI API Key", key="langchain_search_api_key_openai", type="password"
)
"[Get an OpenAI API key](https://platform.openai.com/account/api-keys)"
"[View the source code](https://github.com/streamlit/llm-examples/blob/main/pages/2_Chat_with_search.py)"
"[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/streamlit/llm-examples?quickstart=1)"
Expand Down Expand Up @@ -36,7 +38,9 @@

llm = ChatOpenAI(model_name="gpt-3.5-turbo", openai_api_key=openai_api_key, streaming=True)
search = DuckDuckGoSearchRun(name="Search")
search_agent = initialize_agent([search], llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, handle_parsing_errors=True)
search_agent = initialize_agent(
[search], llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, handle_parsing_errors=True
)
with st.chat_message("assistant"):
st_cb = StreamlitCallbackHandler(st.container(), expand_new_thoughts=False)
response = search_agent.run(st.session_state.messages, callbacks=[st_cb])
Expand Down

0 comments on commit 3385dee

Please sign in to comment.