|
37 | 37 | "source": [
|
38 | 38 | "from services import Service\n",
|
39 | 39 | "\n",
|
| 40 | + "from samples.service_settings import ServiceSettings\n", |
| 41 | + "\n", |
| 42 | + "service_settings = ServiceSettings()\n", |
| 43 | + "\n", |
40 | 44 | "# Select a service to use for this notebook (available services: OpenAI, AzureOpenAI, HuggingFace)\n",
|
41 |
| - "selectedService = Service.OpenAI" |
| 45 | + "selectedService = (\n", |
| 46 | + " Service.AzureOpenAI\n", |
| 47 | + " if service_settings.global_llm_service is None\n", |
| 48 | + " else Service(service_settings.global_llm_service.lower())\n", |
| 49 | + ")\n", |
| 50 | + "print(f\"Using service type: {selectedService}\")" |
42 | 51 | ]
|
43 | 52 | },
|
44 | 53 | {
|
|
47 | 56 | "id": "508ad44f",
|
48 | 57 | "metadata": {},
|
49 | 58 | "outputs": [],
|
50 |
| - "source": [ |
51 |
| - "from semantic_kernel.contents import ChatHistory\n", |
52 |
| - "\n", |
53 |
| - "if selectedService == Service.OpenAI or selectedService == Service.AzureOpenAI:\n", |
54 |
| - " from semantic_kernel.connectors.ai.open_ai import (\n", |
55 |
| - " AzureChatCompletion,\n", |
56 |
| - " AzureChatPromptExecutionSettings,\n", |
57 |
| - " AzureTextCompletion,\n", |
58 |
| - " OpenAIChatCompletion,\n", |
59 |
| - " OpenAIChatPromptExecutionSettings,\n", |
60 |
| - " OpenAITextCompletion,\n", |
61 |
| - " OpenAITextPromptExecutionSettings,\n", |
62 |
| - " )\n", |
63 |
| - "if selectedService == Service.HuggingFace:\n", |
64 |
| - " from semantic_kernel.connectors.ai.hugging_face import HuggingFaceTextCompletion" |
65 |
| - ] |
| 59 | + "source": [] |
66 | 60 | },
|
67 | 61 | {
|
68 | 62 | "attachments": {},
|
|
81 | 75 | "outputs": [],
|
82 | 76 | "source": [
|
83 | 77 | "from semantic_kernel import Kernel\n",
|
| 78 | + "from semantic_kernel.connectors.ai.hugging_face import ( # noqa: F401\n", |
| 79 | + " HuggingFacePromptExecutionSettings,\n", |
| 80 | + " HuggingFaceTextCompletion,\n", |
| 81 | + ")\n", |
| 82 | + "from semantic_kernel.connectors.ai.open_ai import AzureChatPromptExecutionSettings # noqa: F401\n", |
| 83 | + "from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings # noqa: F401\n", |
| 84 | + "from semantic_kernel.connectors.ai.open_ai import OpenAITextPromptExecutionSettings # noqa: F401\n", |
| 85 | + "from semantic_kernel.connectors.ai.open_ai import (\n", |
| 86 | + " AzureChatCompletion,\n", |
| 87 | + " AzureTextCompletion,\n", |
| 88 | + " OpenAIChatCompletion,\n", |
| 89 | + " OpenAITextCompletion,\n", |
| 90 | + ")\n", |
84 | 91 | "\n",
|
85 | 92 | "kernel = Kernel()\n",
|
86 | 93 | "\n",
|
|
201 | 208 | "outputs": [],
|
202 | 209 | "source": [
|
203 | 210 | "if selectedService == Service.HuggingFace:\n",
|
204 |
| - " from semantic_kernel.connectors.ai.hugging_face.hf_prompt_execution_settings import (\n", |
205 |
| - " HuggingFacePromptExecutionSettings,\n", |
206 |
| - " )\n", |
207 |
| - "\n", |
208 | 211 | " hf_prompt_execution_settings = HuggingFacePromptExecutionSettings(\n",
|
209 | 212 | " service_id=\"hf_text\", extension_data={\"max_new_tokens\": 80, \"temperature\": 0.7, \"top_p\": 1}\n",
|
210 | 213 | " )"
|
|
269 | 272 | "metadata": {},
|
270 | 273 | "outputs": [],
|
271 | 274 | "source": [
|
| 275 | + "from semantic_kernel.contents import ChatHistory\n", |
| 276 | + "\n", |
272 | 277 | "if selectedService == Service.OpenAI:\n",
|
273 | 278 | " chat = ChatHistory()\n",
|
274 | 279 | " chat.add_user_message(\n",
|
|
0 commit comments