OpenAI Assistants API v2
# 📖tutorials
q
@crooked-van-25152 🦸‍♀️ 🫡 as you have also mentioned, some of my posts have recently been right posts in a wrong place, since they've been non-tutorials, non-share-your-bots, and non-help-posts. So in addition to those channels, if there were a channel called something like 'Other Useful Stuff', I think I would be spending most of my time in there posting for example useful YouTube playlists related to tools or skills bot builders might need. Or like this one, which might start as a help request, turn into a tutorial, end as everyone is sharing their bots and projects, and in the middle, I hope there's again much talking like in developer or general channels. **OpenAI **has recently upgraded its Assistants API to version 2, marking a significant evolution in AI tools designed for business applications. These enhancements not only improve functionality and performance but also expand the practical applicability in various business contexts. So this topic also has all our favorite elements: speeding things up and cutting costs while improving the product and user experience. It includes RAG, fine-tuning, and a focus on why v2 is now much better for businesses, and after we have together built and shared useful Botpress templates 🛠️ , we then add that last missing favorite element: quick and easy to start using Assistants API v2 for your business and your clients 💎 💰 🚀 The transition to Assistants V2 represents a leap towards making AI tools more accessible, efficient, and adaptable to real-world applications. With an emphasis on fine-tuning and customization, businesses can now tailor AI functionalities to meet specific operational needs, potentially revolutionizing efficiency and customer interaction strategies.
Why we might need it: New Features -Vector Store in File Search: Now supports up to 10,000 files, a 500x increase from the previous limit, handling chunking, embedding, and quality knowledge retrieval more efficiently. -Tool Choice Forcing: Allows specific tool enforcement per thread to optimize task execution. -Assistant Roll Messages: Enables the inclusion of assistant-originated messages in message histories, enhancing thread management. Improvements Over Version 1 -Enhanced Context Management: Message history tracking now includes options for automatically truncating or setting specific thresholds for the number of messages in context, addressing issues related to token cost inefficiency. -Streamlined SDK Support: Improved support across diverse programming environments like TypeScript and Python, simplifying integration and usage. Search Optimization -File Search Enhancements: Includes improved query handling capabilities with enhanced reranking and user search (query) rewriting for optimized file search. -Chunking and Overlap Strategy: Implements a refined chunking strategy with significant overlap (400 tokens overlap on 800 token chunks) to ensure comprehensive data retrieval without missing context. Multi-Hop Document Reasoning -Complex Query Handling: Breaks down complex queries into simpler, multiple queries that can be handled more effectively to synthesize and return comprehensive responses.
Search Techniques -Hybrid Search Approaches: Utilizes both keyword and semantic search techniques to capture the intent and specifics of queries, not just the literal terms. Re-Ranking Mechanism -Query and Chunk Re-Scoring: After initial retrieval, queries and document chunks are re-ranked and re-scored based on relevance to the query, ensuring that the most pertinent information is prioritized. Chunking Strategy -Limited Chunk Context: Limits the number of chunks in context to 20, optimizing performance without overwhelming the system with too much data. Benefits for Companies -Cost-Effectiveness and Efficiency: By addressing issues related to token cost and response latency, Assistants V2 becomes a more viable option for business applications, reducing operational costs and improving user experience. -Enhanced Customization and Control: Offers businesses more control over the tool's behavior and output, aligning more closely with specific use-case requirements. Cost and Speed Efficiency -Optimized Performance: Reduced latency and cost through more efficient use of tokens and enhanced system responsiveness. Knowledge Base and Control Features -Expanded Document Handling: From a limit of 20 documents to up to 10,000, coupled with advanced control features like max token settings for threads, providing better management of resource consumption and cost. Fine-Tuning Strategy -Use-Case Specificity: You can start using Assistants API v2 with the full capabilities of GPT-4 and then collect the comprehensive data across various threads. This data (all those threads) is then used to fine-tune the smaller GPT-3.5 model, resulting in much cheaper, much faster, and much more targeted model that excludes unnecessary domains (like coding or medical information if your use case is travelling & hotel business), optimizing performance by focusing only to specific needs.
Future Developments -Text Extraction from Images: Planned capabilities for extracting text from images to further enhance the utility and applicability of the API in diverse business scenarios.
@best-army-74344 🦸🏽‍♂️ 💎 🫡 First we need to study, then we need to practice, and then we can start building Botpress templates and real projects for our companies and clients.
j
Devmik you are an actually robot..
You are not real.
How do you know all these things about AI
What school do you go to. Cuase enroll me in. I need this to get clients 🙂
Sorry if im annoying, but i gotta know.
q
Even though I wrote the text here (after studying the topic all morning by reading and watching useful videos), I needed to read the text again 2-3 times until I finally understood all the benefits which the new Assistants API v2 brings to us bot builders 🛠️ So I recommend everyone who's interested read that 2-3 times. Then you'll get all their ideas, and start creating your own ideas 💡
j
Im going back to school to increase my english skills
q
If I write some long posts or tutorials like this, I almost always ask ChatGPT to correct the spelling, but spelling only, not to change the text in any other way. I do the study first and write my own questions and instructions. And ChatGPT doesn't have any idea of the Assistants API's new updates from last week, so in texts like that, if it does anything else than spell-checking, it will only mess things up.
j
Got it.
Ill just build a GPT that increases my sentences
q
I've found that when I ask ChatGPT to correct the spelling in my long messages, I learn from that and don't make the same mistakes as often anymore.
j
I can see that now.
Last time we were working on the calcutor project, we were unfimiliar with Chatbots ( I think )
But now, we have increased our skills AND projects by a vast number
🤣 I love this GPT
q
lol
sry
j
Cute gif
I look like him
OMW, HES SO FLUFFY
Did you see that at a part of that gif he has 4 arms
Look closely
c
@quick-musician-29561 great write-up ! Going to delve into assistants this morning. Lets see what we can come up with
a
I read it only once, but it moved me enough 💪 I agree with the idea that it would be good to have a channel for topics like this. btw @quick-musician-29561 , could you suggest the videos that you found most relevant for the Assistant API v2?
q
@adamant-restaurant-32140 Building with python and Assistants API v2 (I'm doing the same with JavaScript)

https://www.youtube.com/watch?v=HEIdZHD6NHo&

Morningside AI (Liam Ottleys company) explaining the benefits and why we might need it

https://www.youtube.com/watch?v=AKD8cRzHjs4

j
Liam ottley
i know him lol
i am subbed
same with millions of others..
f
@quick-musician-29561 How do we use v2 with your original assistants template?
ps i tried dm'ing you but it would go through, what happened to your profile? Last message i got was the easter one!
b
Hey man, I can help you!!
Send me a DM
In those many messages, I shared all the instructions needed to use Assistants API v2.
Yes, I disabled DMs on this Discord account some time ago so I can concentrate more on work 🛠️ 🤖 🧑‍💻
f
Hey Guys! @quick-musician-29561 remember when we discussed this, that it will be better to create the the assistant in the openai account and then connect it through botpress so there is no need to create tools etc. Im basically sticking to that method. In that case its just a matter of changing the header (url) to v2 right? @User
man i thought you blocked me, i was heart broken for a second but then i thought he wouldn't do that to me, he love's me! haha!
here are the places v1 is mentioned in the original template @quick-musician-29561 made... without tool: const OPENAI_API_KEY = env.OPENAI_API_KEY; const assistantID = env.ASSISTANT_ID; const BASE_URL = 'https://api.openai.com/v1'; const headers = { 'Content-Type': 'application/json', 'Authorization':
Bearer ${OPENAI_API_KEY}
, 'OpenAI-Beta': 'assistants=v1', }; const retrieveRun = async () => { const statusResponse = await axios.request({ method: 'get', maxBodyLength: Infinity, url:
https://api.openai.com/v1/threads/${session.threadID}/runs/${runId}
, headers: { 'OpenAI-Beta': 'assistants=v1', Authorization:
Bearer ${OPENAI_API_KEY}
, 'Content-Type': 'application/json' } });
when simply changing all the mentions of v1 to v2 it gives this error: 23 May 2024, 11:03:18
Copy code
[e81fd351c5]    [bot-action]    [flow:Main] [node:Add_Stuff_Here] [card:OpenAI Assistant: Create Thread, Send Messages, Retrieve Responses]:     Error creating thread: { error: 
   { type: 'invalid_request_error',
     code: 'unknown_url',
     message: 'Unknown request URL: POST /v2/threads. Please check the URL for typos, or see the docs at https://platform.openai.com/docs/api-reference/.',
     param: null } }
23 May 2024, 11:03:18
[e81fd351c5]    [bot-action]    [flow:Main] [node:Add_Stuff_Here] [card:OpenAI Assistant: Create Thread, Send Messages, Retrieve Responses]:     Error executing action "inline-card:OpenAI Assistant: Create Thread, Send Messages, Retrieve Responses.js" in flow:Main:node:Add_Stuff_Here
  [Error, Request failed with status code 404
q
🦸🏻‍♂️ 💎 🫡
Sorry about that, and you're right! 💯 I have mentioned that I'm reading DMs in another account, and it's in my Discord bio. It's just easier this way; I can focus 100% on building stuff when needed, and also fully concentrate on DMs when I log into that other account. https://cdn.discordapp.com/attachments/1232193993836855347/1243201431331410002/Screenshot_from_2024-05-23_16-54-43.png?ex=66509d0e&is=664f4b8e&hm=f5c8a66b66d0ff8db7d663ead7f87e7292e84156341404f985a320b9c94011e1&
I think @best-army-74344 has fully functional Assistants API v2 code 🔥
f
Thanks man I have dm’d him!
f
V excited for this huge upgrade! Any luck with getting afunctional Assistants API v2 code?
f
Hello, I need help with the same
q
@few-beard-31210 @flaky-terabyte-57887 Did you try the instructions 🦸🏻‍♂️ jr_aulakh 🫡 gave, and also the ones mentioned here https://discord.com/channels/1108396290624213082/1121494527727902891/1232919125584642129 https://discord.com/channels/1108396290624213082/1231984738328379442/1231985583610396682
I'll update all my old chatbots and tutorials to use v2, for example this one which I already updated https://discord.com/channels/1108396290624213082/1180023587646746715/1244193401214210072
f
I feel flattered to recieve a direct response by devmik! I tried the instructions, i guess I updated too many v1's to v2? Downloaded your new update. It's referencing env variables but there's no spot to set them. should i create the variables or am i being daft? FWIW it does say "Sorry, an error occured, please try again later"
🦸‍♂️ 🛠️ 🫡
f
Yep, so i am daft. Thanks so much!!!
q
That was my mistake; I wrote better instructions only in that other thread which I linked here. Now they are here also. Thanks for pointing that out! @few-beard-31210
f
You're a hero, thank you so much!
b
Does this send the images generated by the GPT as well? @quick-musician-29561
I'd like to use it for images as well, but not sure about how to display them correctly
36 Views