|
24 | 24 |
|
25 | 25 | kernel = sk.Kernel() |
26 | 26 |
|
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)) |
30 | 28 | kernel.add_chat_service("chat-gpt", chat_service) |
31 | 29 |
|
32 | 30 | ## there are three ways to create the request settings in code: # noqa: E266 |
|
41 | 39 | ## 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 |
42 | 40 |
|
43 | 41 | ## 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") |
47 | 43 | req_settings.max_tokens = 2000 |
48 | 44 | req_settings.temperature = 0.7 |
49 | 45 | req_settings.top_p = 0.8 |
|
52 | 48 |
|
53 | 49 | prompt_config = sk.PromptTemplateConfig(completion=req_settings) |
54 | 50 |
|
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) |
58 | 52 |
|
59 | 53 | prompt_template.add_system_message(system_message) |
60 | 54 | 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.") |
64 | 56 |
|
65 | 57 | function_config = sk.SemanticFunctionConfig(prompt_config, prompt_template) |
66 | 58 | chat_function = kernel.register_semantic_function("ChatBot", "Chat", function_config) |
|
0 commit comments