Skip to content

Commit

Permalink
issue #56 Refactor and enhance provider selection strategies
Browse files Browse the repository at this point in the history
Refactored `ChatGPTIPAProvider.cpp` for better readability by reformatting the addition of the "Content-Type: application/json" header. Updated `main.cpp` to include new header files `LanguageMatchingProviderSelectionStrategy.h` and `ProviderSelectionStrategyList.h`. Modified the `main` function to use a `ProviderSelectionStrategyList` for more flexible provider selection, incorporating both `LanguageMatchingProviderSelectionStrategy` and `ModalityMatchingProviderSelectionStrategy`.
  • Loading branch information
schnelle committed Oct 1, 2024
1 parent d9d706a commit 1459df0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ const std::shared_ptr<ExternalClientResponse> ChatGPTIPAProvider::processInput(
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers,
"Authorization: Bearer OPENAI-DEVELOPER-KEY");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(
headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

// TODO Remove this disabling of SSL verification
Expand Down
13 changes: 12 additions & 1 deletion source/w3cipa/w3cipademo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include <log4cplus/loggingmacros.h>

#include <w3c/voiceinteraction/ipa/client/ModalityManager.h>
#include <w3c/voiceinteraction/ipa/external/ipa/LanguageMatchingProviderSelectionStrategy.h>
#include <w3c/voiceinteraction/ipa/external/ipa/ModalityMatchingProviderSelectionStrategy.h>
#include <w3c/voiceinteraction/ipa/external/ipa/ProviderSelectionStrategyList.h>
#include <w3c/voiceinteraction/ipa/external/ipa/ProviderRegistry.h>
#include <w3c/voiceinteraction/ipa/external/ProviderSelectionService.h>
#include <w3c/voiceinteraction/ipa/reference/client/ConsoleTextModalityComponent.h>
Expand Down Expand Up @@ -59,8 +61,17 @@ int main() {
std::make_shared<::reference::dialog::ReferenceIPADialogManager>();

// External IPA / Services Layer
std::shared_ptr<::external::ipa::ModalityMatchingProviderSelectionStrategy> providerSelectionStrategy =
std::shared_ptr<::external::ipa::ProviderSelectionStrategyList>
providerSelectionStrategy =
std::make_shared<::external::ipa::ProviderSelectionStrategyList>();
std::shared_ptr<::external::ipa::LanguageMatchingProviderSelectionStrategy>
languageProviderSelectionStrategy = std::make_shared<
::external::ipa::LanguageMatchingProviderSelectionStrategy>();
providerSelectionStrategy->addStrategy(languageProviderSelectionStrategy);
std::shared_ptr<::external::ipa::ModalityMatchingProviderSelectionStrategy>
modalityProviderSelectionStrategy =
std::make_shared<::external::ipa::ModalityMatchingProviderSelectionStrategy>();
providerSelectionStrategy->addStrategy(modalityProviderSelectionStrategy);
std::shared_ptr<ProviderRegistry> registry =
std::make_shared<ProviderRegistry>(providerSelectionStrategy);
std::shared_ptr<IPAProvider> chatGPT =
Expand Down

0 comments on commit 1459df0

Please sign in to comment.