You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 11-integrating-with-function-calling/README.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
You've learned a fair bit so far in the previous lessons. However, we can improve further. Some things we can address are how we can get a more consistent response format to make it easier to work with the response downstream. Also, we might want to add data from other sources to further enrich our application.
6
6
7
-
The abovementioned problems are what this chapter is looking to address.
7
+
The above-mentioned problems are what this chapter is looking to address.
8
8
9
9
## Introduction
10
10
@@ -26,7 +26,7 @@ By the end of this lesson, you will be able to:
26
26
27
27
For this lesson, we want to build a feature for our education startup that allows users to use a chatbot to find technical courses. We will recommend courses that fit their skill level, current role and technology of interest.
28
28
29
-
To complete this scenario we will use a combination of:
29
+
To complete this scenario, we will use a combination of:
30
30
31
31
-`Azure OpenAI` to create a chat experience for the user.
32
32
-`Microsoft Learn Catalog API` to help users find courses based on the request of the user.
@@ -36,7 +36,7 @@ To get started, let's look at why we would want to use function calling in the f
36
36
37
37
## Why Function Calling
38
38
39
-
Before function calling, responses from an LLM were unstructured and inconsistent. Developers were required to write complex validation code to make sure they are able to handle each variation of a response. Users could not get answers like "What is the current weather in Stockholm?". This is because models were limited to the time the data was trained on.
39
+
Before function calling, responses from an LLM were unstructured and inconsistent. Developers were required to write complex validation code to make sure they were able to handle each variation of a response. Users could not get answers like "What is the current weather in Stockholm?". This is because models were limited to the time the data was trained on.
40
40
41
41
Function Calling is a feature of the Azure OpenAI Service to overcome the following limitations:
42
42
@@ -164,7 +164,7 @@ Now we can send both requests to the LLM and examine the response we receive by
164
164
}
165
165
```
166
166
167
-
Even though the prompts are the same and the descriptions are similar, we see values of the `Grades` property formatted differently as we can sometimes get the format `3.7` or `3.7 GPA` for example.
167
+
Even though the prompts are the same and the descriptions are similar, we see values of the `Grades` property formatted differently, as we can sometimes get the format `3.7` or `3.7 GPA` for example.
168
168
169
169
This result is because the LLM takes unstructured data in the form of the written prompt and returns also unstructured data. We need to have a structured format so that we know what to expect when storing or using this data
170
170
@@ -178,11 +178,11 @@ We can then take what is returned from the function and send this back to the LL
178
178
179
179
There are many different use cases where function calls can improve your app like:
180
180
181
-
-**Calling External Tools**. Chatbots are great at providing answers to questions from users. By using function calling, the chatbots can use messages from users to complete certain tasks. For example, a student can ask the chatbot to "Send email to my instructor saying I need more assistance with this subject". This can make a function call to `send_email(to: string, body: string)`
181
+
-**Calling External Tools**. Chatbots are great at providing answers to questions from users. By using function calling, the chatbots can use messages from users to complete certain tasks. For example, a student can ask the chatbot to "Send an email to my instructor saying I need more assistance with this subject". This can make a function call to `send_email(to: string, body: string)`
182
182
183
183
-**Create API or Database Queries**. Users can find information using natural language that gets converted into a formatted query or API request. An example of this could be a teacher who requests "Who are the students that completed the last assignment" which could call a function named `get_completed(student_name: string, assignment: int, current_status: string)`
184
184
185
-
-**Creating Structured Data**. Users can take a block of text or CSV and use the LLM to extract important information from it. For example, a student can convert a Wikipedia article about peace agreements to create AI flash cards. This can be done by using a function called `get_important_facts(agreement_name: string, date_signed: string, parties_involved: list)`
185
+
-**Creating Structured Data**. Users can take a block of text or CSV and use the LLM to extract important information from it. For example, a student can convert a Wikipedia article about peace agreements to create AI flashcards. This can be done by using a function called `get_important_facts(agreement_name: string, date_signed: string, parties_involved: list)`
186
186
187
187
## Creating Your First Function Call
188
188
@@ -299,7 +299,7 @@ Next, we need to see how we can use this in our app.
299
299
300
300
## Integrating Function Calls into an Application
301
301
302
-
After we have tested the formatted response from the LLM, now we can integrate this into an application.
302
+
After we have tested the formatted response from the LLM, we can now integrate this into an application.
303
303
304
304
### Managing the flow
305
305
@@ -337,7 +337,7 @@ To integrate this into our application, let's take the following steps:
337
337
338
338
Ok, so we created `functions` variables and a corresponding Python function, how do we tell the LLM how to map these two together so our Python function is called?
339
339
340
-
1. To see if we need to call a Python function, we need to look into the LLM response and see if `function_call` is part of it and call the pointedout function. Here's how you can make the mentioned check below:
340
+
1. To see if we need to call a Python function, we need to look into the LLM response and see if `function_call` is part of it and call the pointed-out function. Here's how you can make the mentioned check below:
Copy file name to clipboardExpand all lines: 12-designing-ux-for-ai-applications/README.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ Not every challenge can be solved with AI. AI comes in to augment your user expe
55
55
56
56
## Designing AI Applications for Trust and Transparency
57
57
58
-
Building trust is critical when designing AI applications. Trust ensures a user is confident that the application will get the work done, deliver results consistently and the results are what the user needs. A risk in this area is mistrust and over trust. Mistrust occurs when a user has little or no trust in an AI system, this leads to the user rejecting your application. Over trust occurs when a user overestimates the capability of an AI system, leading to users trusting the AI system too much. For example, an automated grading system in the case of over trust might lead the teacher not to proof through some of the papers to ensure the grading system works well. This could result in unfair or inaccurate grades for the students, or missed opportunities for feedback and improvement.
58
+
Building trust is critical when designing AI applications. Trust ensures a user is confident that the application will get the work done, deliver results consistently and the results are what the user needs. A risk in this area is mistrust and overtrust. Mistrust occurs when a user has little or no trust in an AI system, this leads to the user rejecting your application. Overtrust occurs when a user overestimates the capability of an AI system, leading to users trusting the AI system too much. For example, an automated grading system in the case of overtrust might lead the teacher not to proof through some of the papers to ensure the grading system works well. This could result in unfair or inaccurate grades for the students, or missed opportunities for feedback and improvement.
59
59
60
60
Two ways to ensure that trust is put right at the center of design are explainability and control.
61
61
@@ -83,27 +83,27 @@ Another feature in Bing that allows a user to have control over the application
83
83
84
84

85
85
86
-
> When designing AI applications, intentionality is key in ensuring users do not over trust setting unrealistic expectations of its capabilities. One way to do this is by creating friction between the prompts and the results. Reminding the user, that this is AI and not a fellow human being
86
+
> When designing AI applications, intentionality is key in ensuring users do not overtrust setting unrealistic expectations of its capabilities. One way to do this is by creating friction between the prompts and the results. Reminding the user, that this is AI and not a fellow human being
87
87
88
88
## Designing AI Applications for Collaboration and Feedback
89
89
90
-
As earlier mentioned generative AI creates a collaboration between the user and AI. Most engagements are with a user inputting a prompt and the AI generating an output. What if the output is incorrect? How does the application handle errors if they occur? Does the AI blame the user or take time to explain the error?
90
+
As earlier mentioned, generative AI creates a collaboration between the user and AI. Most engagements are with a user inputting a prompt and the AI generating an output. What if the output is incorrect? How does the application handle errors if they occur? Does the AI blame the user or take time to explain the error?
91
91
92
92
AI applications should be built in to receive and give feedback. This not only helps the AI system improve but also builds trust with the users. A feedback loop should be included in the design, an example can be a simple thumbs up or down on the output.
93
93
94
94
Another way to handle this is to clearly communicate the capabilities and limitations of the system. When a user makes an error requesting something beyond the AI capabilities, there should also be a way to handle this, as shown below.
95
95
96
96

97
97
98
-
System errors are common with applications where the user might need assistance with information outside the scope of the AI or the application may have a limit of how many questions/subjects a user can generate summaries. For example, an AI application trained with data on limited subjects for example, History and Math may not be able to handle questions around Geography. To mitigate this, the AI system can give a response like: "Sorry, our product has been trained with data in the following subjects....., I cannot be able to respond to the question you asked."
98
+
System errors are common with applications where the user might need assistance with information outside the scope of the AI or the application may have a limit on how many questions/subjects a user can generate summaries. For example, an AI application trained with data on limited subjects for example, History and Math may not be able to handle questions around Geography. To mitigate this, the AI system can give a response like: "Sorry, our product has been trained with data in the following subjects....., I cannot be able to respond to the question you asked."
99
99
100
100
AI applications are not perfect, therefore, they are bound to make mistakes. When designing your applications, you should ensure you create room for feedback from users and error handling in a way that is simple and easily explainable.
101
101
102
102
## Assignment
103
103
104
104
Take any AI apps you've built so far, consider implementing the below steps in your app:
105
105
106
-
-**Pleasant:** Consider how you can make your app more pleasant. Are you adding explanations everywhere, are you encouraging the user to explore? How are you wording your error messages?
106
+
-**Pleasant:** Consider how you can make your app more pleasant. Are you adding explanations everywhere? Are you encouraging the user to explore? How are you wording your error messages?
107
107
108
108
-**Usability:** Building a web app. Make sure your app is navigable by both mouse and keyboard.
109
109
@@ -117,4 +117,4 @@ Take any AI apps you've built so far, consider implementing the below steps in y
117
117
118
118
After completing this lesson, check out our [Generative AI Learning collection](https://aka.ms/genai-collection?WT.mc_id=academic-105485-koreyst) to continue leveling up your Generative AI knowledge!
119
119
120
-
Head over to Lesson 13 where we will look at how to [securing AI applications](../13-securing-ai-applications/README.md?WT.mc_id=academic-105485-koreyst)!
120
+
Head over to Lesson 13, where we will look at how to [securing AI applications](../13-securing-ai-applications/README.md?WT.mc_id=academic-105485-koreyst)!
0 commit comments