Package: embedia
EmbediaMake LLM-powered webapps with easeDiscord·Docs·Blog·TwitterWhat is Embedia?Embedia is a framework for making LLM-powered webapps with ease.WithPython 3.8or higher set up, install Embedia using:pipinstallembediaWhich webapps can be created using Embedia?Embedia is built keeping in mind the common as well as advanced usecases of LLMs
in webapps.Some advanced usecases include:AI Agentsthat canrun predefined codewithcustom parametersbased onconversation contextNatural language searchover files, websites, or datasets powered byRetrieval Augmented GenerationCoding assistantsthat cantranslate, write, run, test, and debug codeAll thefunctionalities of OpenAI ChatGPT, but with anopensource LLMlike llama-2Some common usecases include:Chatbots with a personality (similar tocharacter.ai)A panel discussion between multiple personalities. These multiple
personalities can also be internal to a single complex chatbot.Language translators, improvers, and correctorsText summarizersKeyword extractorsSentiment analyzersSocial media content generatorsCreative writing assistantsSpecific planner for a complex taskText based adventure gamesWhy choose Embedia?Developer friendly: Easy to follow documentation, IntelliSense enabledPre-defined common AI Agents and ToolsLLM agnostic: Our universal APIs are LLM independent, it can be used
with any LLM - whether you're using a service provider like OpenAI, Anthropic,
Google or have deployed your own open-source model like Llama-2, Falcon, or
Vicuna.DB agnostic: Our APIs are also independent of what Vector database (or
Graph Database) you want to connect to your web application. Your vector
database might be managed by a cloud provider like Weaviate, Pinecone or
ElasticSearch. Or it might be hosted on a docker container besides your
webapp.Pub-sub based event systemto build highly customizable workflowsAsync: Built from ground up to be asynchronus. It works out of the box
with asynchronomous web frameworks like FastAPI, Starlette, Sanic, etc.Lightweight: Keeping production use-cases in mind, we have kept the
library's dependencies to a minimum. This makes it a very lightweight
component in your webstack.Small dev teamwith a clear focus on developer experience and
scalabilityHow to use it?Step 1: Connect your LLMimportopenaifromembediaimportChatLLMclassOpenAIChatLLM(ChatLLM):def__init__(self):super().__init__()openai.api_key="OPENAI_API_KEY"asyncdef_reply(self,prompt):completion=awaitopenai.ChatCompletion.acreate(model="gpt-3.5-turbo",temperature=0.1,messages=[{"role":msg.role,"content":msg.content}formsginself.chat_history],)returncompletion.choices[0].message.contentStep 2: Use your AI Agentimportasynciofromembedia.agentsimportToolUserAgentfromembedia.toolsimportPythonInterpreterTool,TerminalTool# Create an AI agent and give it Toolsai_agent=ToolUserAgent(chatllm=OpenAIChatLLM(),tools=[PythonInterpreterTool(),TerminalTool()])# Ask the AI agent to solve a problem for youquestion="Find the number of lines of code in main.py"asyncio.run(ai_agent(question))Quick glance over the library internalsThe core classes of Embedia are:Tokenizer: A class that converts text into tokensLLM: A class that interfaces with a next token generation type large language model (eg: text-davinci-003)ChatLLM: A class that interfaces with a chat type large language model (eg: gpt-3.5-turbo)Tool: A class that can convert any python function into a tool that can be used by the AgentEmbeddingModel: A class that interfaces with the Embedding Model (eg: text-embedding-ada-002)VectorDB: A class that interfaces with a vector database (eg: Weaviate)Pre-defined Tools include:PythonInterpreterTool: A tool that can run python code in the python interpreterTerminalTool: A tool that can run shell commands in the terminal10+ file operations tools: For reading, writing, copying, moving, deleting files / foldersPre-defined Agents include:ToolUserAgent: LLM powered System-1 thinker that can run tools in a loop by reading their docstringsHelpers include:Pub-sub based event system for building highly customizable workflowsPersona: An enum class containing pre-defined system promptsTextDoc: A class used for dealing with text documentsLearn about them more on ourdocumentation pageHow to contribute to the codebase?This library is under active and rapid development. We'd love your contributions to make it better. To get started, you can check outcontributing.mdBecome a sponsorRecurring revenue sponsors will get benefits like:Sponsored Screencasts with codeEarly access to Embedia's SAAS productsVisibility on our website and social mediaPartner with usWe'd love to partner with companies and libraries in the AI and web-dev ecosystem. If you'd like to get in touch, we're always active on ourDiscord server.LicenseCopyright - Sudhanshu Passi, 2023 under the the terms of theApache 2.0 license