{"id":3604,"date":"2023-11-18T10:55:46","date_gmt":"2023-11-18T18:55:46","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/surface-duo\/?p=3604"},"modified":"2024-01-03T16:05:05","modified_gmt":"2024-01-04T00:05:05","slug":"openai-assistants","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/surface-duo\/openai-assistants\/","title":{"rendered":"OpenAI Assistants"},"content":{"rendered":"<p>\n  Hello prompt engineers,\n<\/p>\n<p>\n  OpenAI held their first Dev Day on November 6<sup>th<\/sup>, which included a number of new <a href=\"https:\/\/openai.com\/blog\/new-models-and-developer-products-announced-at-devday\">product announcements<\/a>, including GPT-4 Turbo with 128K context, function calling updates, JSON mode, improvements to GPT-3.5 Turbo, the Assistant API, DALL*E 3, text-to-speech, and more. This post will focus just on the Assistant API because it greatly simplifies a lot of the challenges we\u2019ve been addressing in the <em>JetchatAI<\/em> Android sample app.\n<\/p>\n<h2>Assistants<\/h2>\n<p>\n  The <a href=\"https:\/\/platform.openai.com\/docs\/assistants\/overview\">Assistants overview<\/a> explains the key features of the new API and how to implement an example in Python. In today&#8217;s blog post we&#8217;ll compare the new API to the Chat API we&#8217;ve been using in our Android <i>JetchatAI<\/i> sample, and specifically to the <b>#document-chat<\/b> demo that we built over the past few weeks.\n<\/p>\n<p>\n  Big differences between the Assistants API and the Chat API:\n<\/p>\n<ul>\n<li>\n    <b>Stateful<\/b> \u2013 the history is stored on the server, and the client app just needs to track the thread identifier and send new messages.\n  <\/li>\n<li>\n    <b>Sliding window<\/b> \u2013 automatic management of the model\u2019s context window.\n  <\/li>\n<li>\n    <b>Doc upload and embedding<\/b> \u2013 can be easily seeded with a knowledgebase which will be automatically chunked and embeddings created.\n  <\/li>\n<li>\n    <b>Code interpreter<\/b> \u2013 Python code can be generated and run to answer questions.\n  <\/li>\n<li>\n    <b>Functions<\/b> \u2013 supported just like the Chat API.\n  <\/li>\n<\/ul>\n<h2>Revisiting the #document-chat&#8230;<\/h2>\n<p>\n  The last two posts have been about building a basic document chat similar to this <a href=\"https:\/\/github.com\/azure-samples\/azure-search-openai-demo\">Azure OpenAI sample<\/a>, using a lot of custom Kotlin code. OpenAI Assistants now make this trivial to build, as shown in Figure 1 below. This example shows how to prototype an Assistant in the <a href=\"https:\/\/platform.openai.com\/playground\">Playground<\/a> that can answer questions based on documentation sources.\n<\/p>\n<p>\n  You can see the result is very similar to the responses from the <a href=\"https:\/\/devblogs.microsoft.com\/surface-duo\/android-openai-chatgpt-25\/\">previous blog post<\/a>:\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"2003\" height=\"1492\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/11\/a-screenshot-of-a-chat-description-automatically-3.png\" class=\"wp-image-3605\" alt=\"Screenshot of the OpenAI Assistants playground with an example query with some screen elements highlighted and numbered.\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/11\/a-screenshot-of-a-chat-description-automatically-3.png 2003w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/11\/a-screenshot-of-a-chat-description-automatically-3-300x223.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/11\/a-screenshot-of-a-chat-description-automatically-3-1024x763.png 1024w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/11\/a-screenshot-of-a-chat-description-automatically-3-768x572.png 768w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/11\/a-screenshot-of-a-chat-description-automatically-3-1536x1144.png 1536w\" sizes=\"(max-width: 2003px) 100vw, 2003px\" \/><br\/><em>Figure 1: OpenAI Assistant playground, with the sample PDFs uploaded and supporting typical user queries<\/em>\n<\/p>\n<p>\n  Each element in the playground in Figure 1 is explained below:\n<\/p>\n<ol>\n<li>\n  The Assistant <strong>Instructions<\/strong> are like the system prompt.\n<\/li>\n<li>\n  Enable <strong>Retrieval<\/strong> on the assistant and upload the source documents (in our case, the fictitious Contoso PDFs).\n<\/li>\n<li>\n  Add personalization information to augment the query, eg \u201cmy plan is the Northwind Health Standard plan\u201d. App application implementation would add this automatically, not require the user to enter it every time.\n<\/li>\n<li>\n  The <strong>User<\/strong> query \u201cdoes my plan cover contact lenses and immunizations\u201d\n<\/li>\n<li>\n  <strong>doc chat<\/strong> shows the result from the model is grounded in the uploaded documents, and includes citations to the relevant information source. \n<\/li>\n<\/ol>\n<p>\n  Comparing this example to the Chat Playground prototype <a href=\"https:\/\/devblogs.microsoft.com\/surface-duo\/android-openai-chatgpt-25\/\">last week<\/a> you can see the Assistants API is much simpler.\n<\/p>\n<h2>Coming to Kotlin<\/h2>\n<p>\n  The Assistant API is still in beta, so expect changes before it\u2019s ready for production use, however it\u2019s certain that the Kotlin code to implement the Assistant will be much simpler than the Chat API. Rather than keeping track of the entire conversation, managing the context window, chunking the source data, and prompt-tweaking for RAG, in future the code will only keep track of the thread identifier and exchange new queries and responses with the server. The citations can also be programmatically resolved when you implement the API (even though they appear as illegible model-generated strings in the playground).\n<\/p>\n<p>\n  The <a href=\"https:\/\/github.com\/aallam\/openai-kotlin\">OpenAI Kotlin<\/a> open-source client library is currently implementing the Assistant API \u2013 see the progress in this <a href=\"https:\/\/github.com\/aallam\/openai-kotlin\/pull\/259\/files\">pull request<\/a>. \n<\/p>\n<h2>Resources and feedback<\/h2>\n<p>\n  Refer to the <a href=\"https:\/\/openai.com\/blog\/new-models-and-developer-products-announced-at-devday\">OpenAI blog<\/a> for more details on the Dev Day announcements, and the <a href=\"https:\/\/platform.openai.com\/docs\/assistants\/overview\">Assistants docs<\/a> for more technical detail.\n<\/p>\n<p>\n  We\u2019d love your feedback on this post, including any tips or tricks you\u2019ve learned from playing around with ChatGPT prompts.\n<\/p>\n<p>\n  If you have any thoughts or questions, use the <a href=\"http:\/\/aka.ms\/SurfaceDuoSDK-Feedback\">feedback forum<\/a> or message us on <a href=\"https:\/\/twitter.com\/surfaceduodev\">Twitter @surfaceduodev<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello prompt engineers, OpenAI held their first Dev Day on November 6th, which included a number of new product announcements, including GPT-4 Turbo with 128K context, function calling updates, JSON mode, improvements to GPT-3.5 Turbo, the Assistant API, DALL*E 3, text-to-speech, and more. This post will focus just on the Assistant API because it greatly [&hellip;]<\/p>\n","protected":false},"author":570,"featured_media":3605,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[741],"tags":[734,733],"class_list":["post-3604","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","tag-chatgpt","tag-openai"],"acf":[],"blog_post_summary":"<p>Hello prompt engineers, OpenAI held their first Dev Day on November 6th, which included a number of new product announcements, including GPT-4 Turbo with 128K context, function calling updates, JSON mode, improvements to GPT-3.5 Turbo, the Assistant API, DALL*E 3, text-to-speech, and more. This post will focus just on the Assistant API because it greatly [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/3604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/users\/570"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/comments?post=3604"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/3604\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media\/3605"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media?parent=3604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/categories?post=3604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/tags?post=3604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}