A prototype of a chatbot built using OpenAi Threads & Function calling mechanism for financial service providers.
A conversational-ai bot designed to handle and understand users' queries related to services provided by the financial institutions. Appropriate runner is invoked that takes necessary parameters from user's query which then runs and returns appropriate results in response to their query.
Ex: if a query related to stock availability is asked, then stock_available function()
is called.
- Initialize the OpenAI Client: Initialise the openai client using
OpenAi API Key
and create the Beta assisstant. - Context Setting: Set the context for the assisstant and declaring all the necessary functions appropriately.
- Create a Communication Thread: Create a thread that acts as a bridge between user and assisstant, facilitating exchange of messages between them.
- Define Functions: Implement the functions that were previously declared in the assisstant's context.
- Non-Streaming Threads: Threads run without streaming.
- Function Invocation: Appropriate function is invoked based on user's query and the response returned by the runner/function is returned to user over the same thread.
Python, OpenAi Services