Skip to content

Commit ff87caa

Browse files
Merge remote-tracking branch 'origin/update-modelid' into update-modelid
2 parents c1ccfe0 + 11369bf commit ff87caa

178 files changed

Lines changed: 1253 additions & 3155 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎python/pyproject.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ profile = "ruff"
8585
select = ["E", "F", "I"]
8686
line-length = 120
8787

88+
[tool.black]
89+
line-length = 120
90+
8891
[build-system]
8992
requires = ["poetry-core"]
9093
build-backend = "poetry.core.masonry.api"

‎python/samples/kernel-syntax-examples/action_planner.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ async def main():
1212
kernel = sk.Kernel()
1313
api_key, org_id = sk.openai_settings_from_dot_env()
1414

15-
kernel.add_chat_service(
16-
"chat-gpt", OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id)
17-
)
15+
kernel.add_chat_service("chat-gpt", OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id))
1816
kernel.import_skill(MathSkill(), "math")
1917
kernel.import_skill(FileIOSkill(), "fileIO")
2018
kernel.import_skill(TimeSkill(), "time")

‎python/samples/kernel-syntax-examples/azure_chat_gpt_api.py‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424

2525
kernel = sk.Kernel()
2626

27-
chat_service = sk_oai.AzureChatCompletion(
28-
**azure_openai_settings_from_dot_env_as_dict(include_api_version=True)
29-
)
27+
chat_service = sk_oai.AzureChatCompletion(**azure_openai_settings_from_dot_env_as_dict(include_api_version=True))
3028
kernel.add_chat_service("chat-gpt", chat_service)
3129

3230
## there are three ways to create the request settings in code: # noqa: E266
@@ -41,9 +39,7 @@
4139
## The second method is useful when you are using a single service, and you want to have type checking on the request settings or when you are using multiple instances of the same type of service, for instance gpt-35-turbo and gpt-4, both in openai and both for chat. # noqa: E501 E266
4240

4341
## 3. create the request settings from the kernel based on the registered service class: # noqa: E266
44-
req_settings = kernel.get_request_settings_from_service(
45-
ChatCompletionClientBase, "chat-gpt"
46-
)
42+
req_settings = kernel.get_request_settings_from_service(ChatCompletionClientBase, "chat-gpt")
4743
req_settings.max_tokens = 2000
4844
req_settings.temperature = 0.7
4945
req_settings.top_p = 0.8
@@ -52,15 +48,11 @@
5248

5349
prompt_config = sk.PromptTemplateConfig(completion=req_settings)
5450

55-
prompt_template = sk.ChatPromptTemplate(
56-
"{{$user_input}}", kernel.prompt_template_engine, prompt_config
57-
)
51+
prompt_template = sk.ChatPromptTemplate("{{$user_input}}", kernel.prompt_template_engine, prompt_config)
5852

5953
prompt_template.add_system_message(system_message)
6054
prompt_template.add_user_message("Hi there, who are you?")
61-
prompt_template.add_assistant_message(
62-
"I am Mosscap, a chat bot. I'm trying to figure out what people need."
63-
)
55+
prompt_template.add_assistant_message("I am Mosscap, a chat bot. I'm trying to figure out what people need.")
6456

6557
function_config = sk.SemanticFunctionConfig(prompt_config, prompt_template)
6658
chat_function = kernel.register_semantic_function("ChatBot", "Chat", function_config)

‎python/samples/kernel-syntax-examples/azure_chat_gpt_with_data_api.py‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@
3333
**azure_ai_search_settings
3434
)
3535
)
36-
azure_chat_with_data_settings = (
37-
sk_oai.OpenAIChatPromptTemplateWithDataConfig.AzureChatWithDataSettings(
38-
dataSources=[azure_aisearch_datasource]
39-
)
36+
azure_chat_with_data_settings = sk_oai.OpenAIChatPromptTemplateWithDataConfig.AzureChatWithDataSettings(
37+
dataSources=[azure_aisearch_datasource]
4038
)
4139

4240

@@ -50,23 +48,17 @@
5048
)
5149
kernel.add_chat_service("chat-gpt", chat_service)
5250

53-
prompt_config = (
54-
sk_oai.OpenAIChatPromptTemplateWithDataConfig.from_completion_parameters(
55-
max_tokens=2000,
56-
temperature=0.7,
57-
top_p=0.8,
58-
data_source_settings=azure_chat_with_data_settings,
59-
)
51+
prompt_config = sk_oai.OpenAIChatPromptTemplateWithDataConfig.from_completion_parameters(
52+
max_tokens=2000,
53+
temperature=0.7,
54+
top_p=0.8,
55+
data_source_settings=azure_chat_with_data_settings,
6056
)
6157

62-
prompt_template = sk.ChatPromptTemplate(
63-
"{{$user_input}}", kernel.prompt_template_engine, prompt_config
64-
)
58+
prompt_template = sk.ChatPromptTemplate("{{$user_input}}", kernel.prompt_template_engine, prompt_config)
6559

6660
prompt_template.add_user_message("Hi there, who are you?")
67-
prompt_template.add_assistant_message(
68-
"I am an AI assistant here to answer your questions."
69-
)
61+
prompt_template.add_assistant_message("I am an AI assistant here to answer your questions.")
7062

7163
function_config = sk.SemanticFunctionConfig(prompt_config, prompt_template)
7264
chat_function = kernel.register_semantic_function("ChatBot", "Chat", function_config)

‎python/samples/kernel-syntax-examples/azure_chat_gpt_with_data_api_cross_lingual.py‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
# Set index language
2020
azure_aisearch_datasource.parameters.indexLanguage = "en"
2121

22-
azure_chat_with_data_settings = (
23-
sk_oai.OpenAIChatPromptTemplateWithDataConfig.AzureChatWithDataSettings(
24-
dataSources=[azure_aisearch_datasource]
25-
)
22+
azure_chat_with_data_settings = sk_oai.OpenAIChatPromptTemplateWithDataConfig.AzureChatWithDataSettings(
23+
dataSources=[azure_aisearch_datasource]
2624
)
2725

2826
# For example, AI Search index may contain the following document:
@@ -44,20 +42,16 @@
4442
chat_service,
4543
)
4644

47-
prompt_config = (
48-
sk_oai.OpenAIChatPromptTemplateWithDataConfig.from_completion_parameters(
49-
max_tokens=2000,
50-
temperature=0.7,
51-
top_p=0.8,
52-
inputLanguage="fr",
53-
outputLanguage="de",
54-
data_source_settings=azure_chat_with_data_settings,
55-
)
45+
prompt_config = sk_oai.OpenAIChatPromptTemplateWithDataConfig.from_completion_parameters(
46+
max_tokens=2000,
47+
temperature=0.7,
48+
top_p=0.8,
49+
inputLanguage="fr",
50+
outputLanguage="de",
51+
data_source_settings=azure_chat_with_data_settings,
5652
)
5753

58-
prompt_template = sk.ChatPromptTemplate(
59-
"{{$user_input}}", kernel.prompt_template_engine, prompt_config
60-
)
54+
prompt_template = sk.ChatPromptTemplate("{{$user_input}}", kernel.prompt_template_engine, prompt_config)
6155

6256
prompt_template.add_user_message("Bonjour!")
6357
prompt_template.add_assistant_message(

‎python/samples/kernel-syntax-examples/azure_chat_gpt_with_data_api_function_calling.py‎

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
)
2828
)
2929

30-
azure_chat_with_data_settings = (
31-
sk_oai.OpenAIChatPromptTemplateWithDataConfig.AzureChatWithDataSettings(
32-
dataSources=[azure_aisearch_datasource]
33-
)
30+
azure_chat_with_data_settings = sk_oai.OpenAIChatPromptTemplateWithDataConfig.AzureChatWithDataSettings(
31+
dataSources=[azure_aisearch_datasource]
3432
)
3533

3634
# For example, AI Search index may contain the following document:
@@ -63,22 +61,16 @@
6361
# if you only want to use a specific function, set the name of that function in this parameter,
6462
# the format for that is 'SkillName-FunctionName', (i.e. 'math-Add').
6563
# if the model or api version do not support this you will get an error.
66-
prompt_config = (
67-
sk_oai.OpenAIChatPromptTemplateWithDataConfig.from_completion_parameters(
68-
max_tokens=2000,
69-
temperature=0.7,
70-
top_p=0.8,
71-
function_call="auto",
72-
data_source_settings=azure_chat_with_data_settings,
73-
)
74-
)
75-
prompt_template = OpenAIChatPromptTemplate(
76-
"{{$user_input}}", kernel.prompt_template_engine, prompt_config
64+
prompt_config = sk_oai.OpenAIChatPromptTemplateWithDataConfig.from_completion_parameters(
65+
max_tokens=2000,
66+
temperature=0.7,
67+
top_p=0.8,
68+
function_call="auto",
69+
data_source_settings=azure_chat_with_data_settings,
7770
)
71+
prompt_template = OpenAIChatPromptTemplate("{{$user_input}}", kernel.prompt_template_engine, prompt_config)
7872
prompt_template.add_user_message("Hi there, who are you?")
79-
prompt_template.add_assistant_message(
80-
"I am an AI assistant here to answer your questions."
81-
)
73+
prompt_template.add_assistant_message("I am an AI assistant here to answer your questions.")
8274

8375
function_config = sk.SemanticFunctionConfig(prompt_config, prompt_template)
8476
chat_function = kernel.register_semantic_function("ChatBot", "Chat", function_config)

‎python/samples/kernel-syntax-examples/azure_chat_gpt_with_data_api_vector_search.py‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@
3535
**azure_ai_search_settings
3636
)
3737
)
38-
azure_chat_with_data_settings = (
39-
sk_oai.OpenAIChatPromptTemplateWithDataConfig.AzureChatWithDataSettings(
40-
dataSources=[azure_aisearch_datasource]
41-
)
38+
azure_chat_with_data_settings = sk_oai.OpenAIChatPromptTemplateWithDataConfig.AzureChatWithDataSettings(
39+
dataSources=[azure_aisearch_datasource]
4240
)
4341

4442

@@ -52,23 +50,17 @@
5250
)
5351
kernel.add_chat_service("chat-gpt", chat_service)
5452

55-
prompt_config = (
56-
sk_oai.OpenAIChatPromptTemplateWithDataConfig.from_completion_parameters(
57-
max_tokens=2000,
58-
temperature=0.7,
59-
top_p=0.8,
60-
data_source_settings=azure_chat_with_data_settings,
61-
)
53+
prompt_config = sk_oai.OpenAIChatPromptTemplateWithDataConfig.from_completion_parameters(
54+
max_tokens=2000,
55+
temperature=0.7,
56+
top_p=0.8,
57+
data_source_settings=azure_chat_with_data_settings,
6258
)
6359

64-
prompt_template = sk.ChatPromptTemplate(
65-
"{{$user_input}}", kernel.prompt_template_engine, prompt_config
66-
)
60+
prompt_template = sk.ChatPromptTemplate("{{$user_input}}", kernel.prompt_template_engine, prompt_config)
6761

6862
prompt_template.add_user_message("Hi there, who are you?")
69-
prompt_template.add_assistant_message(
70-
"I am an AI assistant here to answer your questions."
71-
)
63+
prompt_template.add_assistant_message("I am an AI assistant here to answer your questions.")
7264

7365
function_config = sk.SemanticFunctionConfig(prompt_config, prompt_template)
7466
chat_function = kernel.register_semantic_function("ChatBot", "Chat", function_config)

‎python/samples/kernel-syntax-examples/azure_cognitive_search_memory.py‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@
1818

1919
async def populate_memory(kernel: sk.Kernel) -> None:
2020
# Add some documents to the ACS semantic memory
21-
await kernel.memory.save_information_async(
22-
COLLECTION_NAME, id="info1", text="My name is Andrea"
23-
)
24-
await kernel.memory.save_information_async(
25-
COLLECTION_NAME, id="info2", text="I currently work as a tour guide"
26-
)
21+
await kernel.memory.save_information_async(COLLECTION_NAME, id="info1", text="My name is Andrea")
22+
await kernel.memory.save_information_async(COLLECTION_NAME, id="info2", text="I currently work as a tour guide")
2723
await kernel.memory.save_information_async(
2824
COLLECTION_NAME, id="info3", text="I've been living in Seattle since 2005"
2925
)
@@ -32,9 +28,7 @@ async def populate_memory(kernel: sk.Kernel) -> None:
3228
id="info4",
3329
text="I visited France and Italy five times since 2015",
3430
)
35-
await kernel.memory.save_information_async(
36-
COLLECTION_NAME, id="info5", text="My family is from New York"
37-
)
31+
await kernel.memory.save_information_async(COLLECTION_NAME, id="info5", text="My family is from New York")
3832

3933

4034
async def search_acs_memory_questions(kernel: sk.Kernel) -> None:

‎python/samples/kernel-syntax-examples/bing_search_skill.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212

1313
async def main():
1414
kernel = sk.Kernel()
15-
deployment, key, endpoint, api_version = sk.azure_openai_settings_from_dot_env(
16-
include_api_version=True
17-
)
15+
deployment, key, endpoint, api_version = sk.azure_openai_settings_from_dot_env(include_api_version=True)
1816
kernel.add_chat_service(
1917
"chat-gpt",
2018
AzureChatCompletion(

‎python/samples/kernel-syntax-examples/chat.py‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@
1818
kernel = sk.Kernel()
1919

2020
api_key, org_id = sk.openai_settings_from_dot_env()
21-
kernel.add_chat_service(
22-
"chat-gpt", sk_oai.OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id)
23-
)
21+
kernel.add_chat_service("chat-gpt", sk_oai.OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id))
2422

25-
prompt_config = sk.PromptTemplateConfig.from_completion_parameters(
26-
max_tokens=2000, temperature=0.7, top_p=0.4
27-
)
23+
prompt_config = sk.PromptTemplateConfig.from_completion_parameters(max_tokens=2000, temperature=0.7, top_p=0.4)
2824

29-
prompt_template = sk.PromptTemplate(
30-
sk_prompt, kernel.prompt_template_engine, prompt_config
31-
)
25+
prompt_template = sk.PromptTemplate(sk_prompt, kernel.prompt_template_engine, prompt_config)
3226

3327
function_config = sk.SemanticFunctionConfig(prompt_config, prompt_template)
3428
chat_function = kernel.register_semantic_function("ChatBot", "Chat", function_config)

0 commit comments

Comments
 (0)