Python: Proper separation of unit and integration tests (#732)

### Motivation and Context
This PR introduces the ability to run formal integration tests for
python using pytest - separated from unit tests for easier automation.

### Description
- moved `python/tests/end-to-end` directory to
`python/tests/integration`
- renamed integration tests to test_* pattern so pytest will detect them
- import `GenerationConfig` for hugging face completions - according to
logs, this is the recommended practice
This commit is contained in:
Abby Harrison
2023-05-01 16:16:36 -07:00
committed by GitHub
parent 309840beb1
commit 4e2d886eff
29 changed files with 355 additions and 208 deletions
@@ -4,7 +4,7 @@ from logging import Logger
from typing import Optional
import torch
from transformers import pipeline
from transformers import GenerationConfig, pipeline
from semantic_kernel.connectors.ai.ai_exception import AIException
from semantic_kernel.connectors.ai.complete_request_settings import (
@@ -69,14 +69,15 @@ class HuggingFaceTextCompletion(TextCompletionClientBase):
str -- Completion result.
"""
try:
result = self.generator(
prompt,
num_return_sequences=1,
generation_config = GenerationConfig(
temperature=request_settings.temperature,
top_p=request_settings.top_p,
max_length=request_settings.max_tokens,
max_new_tokens=request_settings.max_tokens,
pad_token_id=50256, # EOS token
)
result = self.generator(
prompt, num_return_sequences=1, generation_config=generation_config
)
if self._task == "text-generation" or self._task == "text2text-generation":
return result[0]["generated_text"]
@@ -48,6 +48,9 @@ class OpenAITextEmbedding(EmbeddingGeneratorBase):
import openai
openai.api_key = self._api_key
openai.api_base = "https://api.openai.com/v1"
openai.api_type = "openai"
openai.api_version = None
if self._org_id is not None:
openai.organization = self._org_id