Skip to content

Commit

Permalink
Python: Fix Bing Connector Setting Usage (#6493)
Browse files Browse the repository at this point in the history
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

[PR 6278](#6278) added
support for Bing Custom Search, but had a bug introduced when merging a
change to how settings worked.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

This PR fixes the bug in how settings are referenced.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

Co-authored-by: Evan Mattson <[email protected]>
  • Loading branch information
bochris and moonbox3 authored Jun 3, 2024
1 parent eab0e67 commit e9b1407
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ async def search(self, query: str, num_results: int = 1, offset: int = 0) -> lis

_base_url = (
"https://api.bing.microsoft.com/v7.0/custom/search"
if self._custom_config
if self._settings.custom_config
else "https://api.bing.microsoft.com/v7.0/search"
)
_request_url = f"{_base_url}?q={urllib.parse.quote_plus(query)}&count={num_results}&offset={offset}" + (
f"&customConfig={self._custom_config}" if self._custom_config else ""
_request_url = (
f"{_base_url}?q={urllib.parse.quote_plus(query)}&count={num_results}&offset={offset}"
+ (
f"&customConfig={self._settings.custom_config}"
if self._settings.custom_config
else ""
)
)

logger.info(f"Sending GET request to {_request_url}")
Expand Down

0 comments on commit e9b1407

Please sign in to comment.