Package: intelli
IntelliCreate chatbots and AI agent work flows. It allows to connect your data with multiple AI models like OpenAI, Gemini, and Mistral through a unified access layer.InstallpipinstallintelliFor detailed usage instructions, refer tointelli documentation.Code ExamplesCreate ChatbotSwitch between multiple chatbot providers without changing your code.fromintelli.function.chatbotimportChatbotfromintelli.model.input.chatbot_inputimportChatModelInputdefcall_chatbot(provider,model=None):# prepare common inputinput=ChatModelInput("You are a helpful assistant.",model)input.add_user_message("What is the capital of France?")# creating chatbot instanceopenai_bot=Chatbot(YOUR_API_KEY,provider)response=openai_bot.chat(input)returnresponse# call openaicall_chatbot("openai","gpt-4")# call mistralaicall_chatbot("mistral","mistral-medium")# call google geminicall_chatbot("gemini")Connect Your Docs With ChatbotIntelliPy allows you to chat with your docs using multiple LLMs. To connect your data, visit theIntelliNode App, start a project using the Document option, upload your documents or images, and copy the generated One Key. This key will be used to connect the chatbot to your uploaded data.# creating chatbot with the intellinode one keybot=Chatbot(YOUR_OPENAI_API_KEY,"openai",{"one_key":YOUR_ONE_KEY})input=ChatModelInput("You are a helpful assistant.","gpt-3.5-turbo")input.add_user_message("What is the procedure for requesting a refund according to the user manual?")response=bot.chat(input)Generate ImagesUse the image controller to generate arts from multiple models with minimum code change:fromintelli.controller.remote_image_modelimportRemoteImageModelfromintelli.model.input.image_inputimportImageModelInput# model details - change only two words to switchprovider="openai"model_name="dall-e-3"# prepare the input detailsprompts="cartoonishly-styled solitary snake logo, looping elegantly to form both the body of the python and an abstract play on data nodes."image_input=ImageModelInput(prompt=prompt,width=1024,height=1024,model=model_name)# call the model openai/stabilitywrapper=RemoteImageModel(your_api_key,provider)results=wrapper.generate_images(image_input)Create AI FlowsYou can create a flow of tasks executed by different AI models. Here's an example of creating a blog post flow:ChatGPT agent to write a post.Google gemini agent to write image description.Stable diffusion to generate images.fromintelli.flow.agents.agentimportAgentfromintelli.flow.tasks.taskimportTaskfromintelli.flow.sequence_flowimportSequenceFlowfromintelli.flow.input.task_inputimportTextTaskInputfromintelli.flow.processors.basic_processorimportTextProcessor# define agentsblog_agent=Agent(agent_type='text',provider='openai',mission='write blog posts',model_params={'key':YOUR_OPENAI_API_KEY,'model':'gpt-4'})copy_agent=Agent(agent_type='text',provider='gemini',mission='generate description',model_params={'key':YOUR_GEMINI_API_KEY,'model':'gemini'})artist_agent=Agent(agent_type='image',provider='stability',mission='generate image',model_params={'key':YOUR_STABILITY_API_KEY})# define taskstask1=Task(TextTaskInput('blog post about electric cars'),blog_agent,log=True)task2=Task(TextTaskInput('Generate short image description for image model'),copy_agent,pre_process=TextProcessor.text_head,log=True)task3=Task(TextTaskInput('Generate cartoon style image'),artist_agent,log=True)# start sequence flowflow=SequenceFlow([task1,task2,task3],log=True)final_result=flow.start()To build async AI flows with multiple paths, refer to theflow tutorial.PillarsThe wrapper layerprovides low-level access to the latest AI models.The controller layeroffers a unified input to any AI model by handling the differences.The function layerprovides abstract functionality that extends based on the app's use cases.Flows: create a flow of ai agents working toward user tasks.