Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescalam committed Sep 5, 2024
1 parent 42fa288 commit be86fe0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
7 changes: 4 additions & 3 deletions semantic_router/index/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ def __len__(self):
return self.index.describe_index_stats()["total_vector_count"]



def parse_route_info(metadata: List[Dict[str, Any]]) -> List[Tuple]:
"""Parses metadata from Pinecone index to extract route, utterance, function
schema and additional metadata.
Expand All @@ -814,12 +813,14 @@ def parse_route_info(metadata: List[Dict[str, Any]]) -> List[Tuple]:
sr_function_schema = json.loads(record.get("sr_function_schema", "{}"))
if sr_function_schema == {}:
sr_function_schema = None

Check warning on line 815 in semantic_router/index/pinecone.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/index/pinecone.py#L809-L815

Added lines #L809 - L815 were not covered by tests

additional_metadata = {

Check warning on line 817 in semantic_router/index/pinecone.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/index/pinecone.py#L817

Added line #L817 was not covered by tests
key: value
for key, value in record.items()
if key not in ["sr_route", "sr_utterance", "sr_function_schema"]
}
# TODO: Not a fan of tuple packing here
route_info.append((sr_route, sr_utterance, sr_function_schema, additional_metadata))
route_info.append(

Check warning on line 823 in semantic_router/index/pinecone.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/index/pinecone.py#L823

Added line #L823 was not covered by tests
(sr_route, sr_utterance, sr_function_schema, additional_metadata)
)
return route_info

Check warning on line 826 in semantic_router/index/pinecone.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/index/pinecone.py#L826

Added line #L826 was not covered by tests
2 changes: 0 additions & 2 deletions semantic_router/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def __init__(
# if routes list has been passed, we initialize index now
if self.index.sync:
# initialize index now
logger.info(f"JB TEMP: {self.routes=}")
if len(self.routes) > 0:
self._add_and_sync_routes(routes=self.routes)
else:
Expand Down Expand Up @@ -545,7 +544,6 @@ def _add_and_sync_routes(self, routes: List[Route]):
)

# Update local route layer state
logger.info([data.get("function_schemas", None) for _, data in layer_routes_dict.items()])
self.routes = []
for route, data in layer_routes_dict.items():
function_schemas = data.get("function_schemas", None)
Expand Down
6 changes: 0 additions & 6 deletions semantic_router/llms/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ def __call__(
tools: Union[List[Dict[str, Any]], NotGiven] = (
function_schemas if function_schemas else NOT_GIVEN
)
logger.info(f"{function_schemas=}")
logger.info(f"{function_schemas is None=}")
logger.info(f"{tools=}")

completion = self.client.chat.completions.create(
model=self.name,
Expand Down Expand Up @@ -187,8 +184,6 @@ def extract_function_inputs(
raise Exception("No output generated for extract function input")
output = output.replace("'", '"')
function_inputs = json.loads(output)
logger.info(f"Function inputs: {function_inputs}")
logger.info(f"function_schemas: {function_schemas}")
if not self._is_valid_inputs(function_inputs, function_schemas):
raise ValueError("Invalid inputs")
return function_inputs
Expand All @@ -206,7 +201,6 @@ async def async_extract_function_inputs(
raise Exception("No output generated for extract function input")
output = output.replace("'", '"')
function_inputs = json.loads(output)
logger.info(f"OpenAI => Function Inputs: {function_inputs}")
if not self._is_valid_inputs(function_inputs, function_schemas):
raise ValueError("Invalid inputs")
return function_inputs
Expand Down

0 comments on commit be86fe0

Please sign in to comment.