Skip to content

Commit cbcca58

Browse files
committed
Fix linting
1 parent df3df91 commit cbcca58

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

python/rubin/rag/chatbot.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,13 @@ def handle_user_input(
170170
},
171171
{"callbacks": [stream_handler]},
172172
)
173-
msgs.add_ai_message(result["answer"]) # type: ignore[index]
173+
msgs.add_ai_message(result["answer"]) # type: ignore[index]
174174

175175
# Display source documents in an expander
176176
with st.expander("See sources"):
177177
scores = [
178-
chunk.metadata["score"] for chunk in result["context"] # type: ignore[index]
178+
chunk.metadata["score"]
179+
for chunk in result["context"] # type: ignore[index]
179180
]
180181

181182
if scores:
@@ -184,10 +185,10 @@ def handle_user_input(
184185
max_score * 0.9
185186
) # Set threshold to 90% of the highest score
186187

187-
for chunk in result["context"]: # type: ignore[index]
188+
for chunk in result["context"]: # type: ignore[index]
188189
score = chunk.metadata["score"]
189190

190191
# Only show sources with scores
191192
# significantly higher (above the threshold)
192193
if score >= threshold:
193-
st.info(f"Source: {chunk.metadata['source']}")
194+
st.info(f"Source: {chunk.metadata['source']}")
-8 KB
Binary file not shown.

python/rubin/rag/extra_scripts/parse_jira_tickets.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import json
44
import time
5-
from pathlib import Path
65
from functools import reduce
7-
from typing import Any, Dict, Optional
6+
from pathlib import Path
7+
from typing import Any
88

99
import requests
10-
from typing import Optional
1110

1211

1312
def get_jira_issue(issue_name: str, email: str, api_token: str) -> tuple:
@@ -108,11 +107,14 @@ def extract_parent_issue(jira_data: dict) -> dict:
108107
return {}
109108

110109

111-
def safe_get(dictionary: Dict[str, Any], keys: list, default: Optional[Any] = None) -> Any:
110+
def safe_get(
111+
dictionary: dict[str, Any], keys: list, default: Any | None = None
112+
) -> Any:
113+
"""Safely extract information from nested dictionaries."""
112114
return reduce(
113-
lambda d, key: d.get(key, default) if isinstance(d, dict) else default,
114-
keys,
115-
dictionary
115+
lambda d, key: d.get(key, default) if isinstance(d, dict) else default,
116+
keys,
117+
dictionary,
116118
)
117119

118120

python/rubin/rag/extra_scripts/universal_weaviate_uploader.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def push_docs_to_weaviate(
2424
openai_api_key = os.getenv("OPENAI_API_KEY")
2525
if openai_api_key is None:
2626
raise ValueError("OPENAI_API_KEY environment variable is not set")
27-
2827

2928
client = weaviate.connect_to_custom(
3029
http_host="localhost",
@@ -33,9 +32,7 @@ def push_docs_to_weaviate(
3332
grpc_host="localhost",
3433
grpc_port=50051,
3534
grpc_secure=False,
36-
headers={
37-
"X-OpenAI-Api-Key": openai_api_key # Or any other inference API keys
38-
},
35+
headers={"X-OpenAI-Api-Key": openai_api_key},
3936
)
4037

4138
if do_chunk:

0 commit comments

Comments
 (0)