mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### 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. --> Implementation of Google PaLM connector with text completion and an example file to demonstrate its functionality. Closes #1979 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Implemented Google Palm connector with text completion 2. Added example file to ```python/samples/kernel-syntax-examples``` 3. Added integration tests with different inputs to kernel.run_async 4. Added unit tests to ensure successful initialization of the class and successful API calls 5. 3 optional arguments (top_k, safety_settings, client) for google.generativeai.generate_text were not included. See more information about the function and its arguments: https://developers.generativeai.google/api/python/google/generativeai/generate_text I also opened a PR for text embedding and chat completion #2258 ### 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#dev-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 Currently no warnings, there was 1 warning when first installing genai with `poetry add google.generativeai==v0.1.0rc2` from within poetry shell: "The locked version 0.1.0rc2 for google-generativeai is a yanked version. Reason for being yanked: Release is marked as supporting Py3.8, but in practice it requires 3.9". We would need to require later versions of python to fix it. --------- Co-authored-by: Abby Harrison <[email protected]> Co-authored-by: Abby Harrison <[email protected]>
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
import semantic_kernel as sk
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def create_kernel():
|
|
kernel = sk.Kernel()
|
|
return kernel
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def get_aoai_config():
|
|
if "Python_Integration_Tests" in os.environ:
|
|
deployment_name = os.environ["AzureOpenAIEmbeddings__DeploymentName"]
|
|
api_key = os.environ["AzureOpenAI__ApiKey"]
|
|
endpoint = os.environ["AzureOpenAI__Endpoint"]
|
|
else:
|
|
# Load credentials from .env file
|
|
deployment_name, api_key, endpoint = sk.azure_openai_settings_from_dot_env()
|
|
deployment_name = "text-embedding-ada-002"
|
|
|
|
return deployment_name, api_key, endpoint
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def get_oai_config():
|
|
if "Python_Integration_Tests" in os.environ:
|
|
api_key = os.environ["OpenAI__ApiKey"]
|
|
org_id = None
|
|
else:
|
|
# Load credentials from .env file
|
|
api_key, org_id = sk.openai_settings_from_dot_env()
|
|
|
|
return api_key, org_id
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def get_gp_config():
|
|
if "Python_Integration_Tests" in os.environ:
|
|
api_key = os.environ["GOOGLE_PALM_API_KEY"]
|
|
else:
|
|
# Load credentials from .env file
|
|
api_key = sk.google_palm_settings_from_dot_env()
|
|
|
|
return api_key
|