Metadata-Version: 2.1
Name: textbase-framework
Version: 0.1.2
Summary: Framework for the textbase package.
Author: sammyCofactory
Author-email: samarthar@cofactory.ai
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: functions-framework (>=3.4.0,<4.0.0)
Requires-Dist: openai (>=0.27.9,<0.28.0)
Requires-Dist: pydantic (==1.9.*)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Description-Content-Type: text/markdown

# textbase-framework
An add-on for the textbase repository which enables you to deploy your bots to the internet for everyone to use!

To use it, you just have to import the library and use a decorator function called `bot`.

You can also use different models by importing the `models` module. Currently we support:
- OpenAI
- HuggingFace
- BotLibre

Example:
```
from textbase_framework import bot, Message
from textbase_framework.models import OpenAI

OpenAI.api_key = os.getenv("OPENAI_API_KEY")

# System prompt; this will set the tone of the bot for the rest of the conversation.

SYSTEM_PROMPT = """You are chatting with an AI. There are no specific prefixes for responses, so you can ask or talk about anything you like.
The AI will respond in a natural, conversational manner. Feel free to start the conversation with any question or topic, and let's have a
pleasant chat!
"""

@bot() #The decorator function
def on_message(message_history: List[Message], state: dict = None):

    # Your logic for the bot. A very basic request to OpenAI is provided below. You can choose to handle it however you want.
    bot_response = OpenAI.generate(
        model="gpt-3.5-turbo",
        system_prompt=SYSTEM_PROMPT,
        message_history=message_history
    )

    '''
    The response HAS to be in the format given below so that our backend framework has no issues communicating with the frontend.
    '''

    response = {
        "data": {
            "messages": [
                {
                    "type": "string",
                    "value": bot_response
                },
                {
                    "type": "audio",
                    "value": ""
                }
            ],
            "state": state
        },
        "errors": [
            {
                "message": ""
            }
        ]
    }

    return {
        "status_code": 200,
        "response": response
    }
```

