cofactoryai / textbase Goto Github PK
View Code? Open in Web Editor NEW✨ Textbase is a simple framework for building AI chatbots. ✨
Home Page: https://textbase.ai
✨ Textbase is a simple framework for building AI chatbots. ✨
Home Page: https://textbase.ai
Description:
The current version of our chatbot heavily relies on the Open API for responding to user queries. However, there is an opportunity to optimize the Open API usage and enhance customer friendliness when users ask questions that are not directly related to the bot's core functionality. To address this, we propose a solution that utilizes a pre-trained chatbot dataset and employs techniques such as TF-IDF, cosine similarity search, and sentiment analysis. This approach aims to provide more accurate and contextually relevant responses to user queries, ultimately improving user satisfaction and reducing dependence on Open API calls.
Proposed Solution:
Dataset Utilization: We have obtained a pre-trained chatbot dataset from Kaggle, which contains a diverse range of user interactions. This dataset will be transformed into a CSV file format to facilitate easy access and retrieval of chatbot responses.
Response Handling:
Legal Check: The system will first evaluate whether the user query pertains to legal matters. If it does, the query will be directed to the GPT model to provide a relevant response.
Off-Topic Queries: If the query is not related to legal topics, the system will:
Utilize TF-IDF and cosine similarity to compare the user query with entries in the CSV file.
If a suitable match is found, the corresponding response will be retrieved from the CSV file and provided to the user.
In case of a mismatch, the system will perform sentiment analysis on the query.
Sentiment Analysis:
If the sentiment analysis indicates a positive or neutral sentiment, the system will prompt the user for further clarification with a response like "Please provide more context or details."
If the sentiment analysis identifies a negative sentiment, the system will respond with "I'm having trouble understanding your query. Could you please provide more information?"
Benefits:
Reduced reliance on Open API calls, leading to potential cost savings.
Enhanced customer experience by providing contextually relevant responses.
Improved user engagement through tailored responses to off-topic queries.
Decreased frustration for users encountering difficulties in communicating their queries.
Possibility of gathering more accurate user information through follow-up prompts.
I have installed the packages as given in the ReadMe document.
poetry run python textbase/textbase_cli.py test --path main.py
But I get "textbase" is not a package error. Can someone please help?
File "C:\Users\HEMA S\Python_Projects\textbase\textbase\textbase_cli.py", line 23, in test
server_path = importlib.resources.files('textbase').joinpath('utils', 'server.py')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HEMA S\AppData\Local\Programs\Python\Python311\Lib\importlib\resources_common.py", line 22, in files
return from_package(get_package(package))
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HEMA S\AppData\Local\Programs\Python\Python311\Lib\importlib\resources_common.py", line 55, in get_package
raise TypeError(f'{package!r} is not a package')
TypeError: 'textbase' is not a package
-[ ] changes > add link in title :
-[ ] changes > add YT video Installation:
-[ ] changes > add links coming soon:
-[ ] changes > main.py file
If you go to the example section in the docs website it contains basic starter code for various types of bots like a DALL-E bot
that can return images for the text input. To make it more visually intuitive of the final working we want to include a GIF for the final bot interface with a small conversation to show the responses.
For example if you go to the Installation section and scroll down you'll see some gifs to show how to locally setup the cli code. In the same way we want GIFs for all the example bots- OpenAI, Palm, Mimicking, DALL-E.
If you go to the textbase/models.py, there exists classes for various models like OpenAI (GPT3.5/4), Dalle-2, Huggingface inference API
etc that can be used for various tasks from text generation to chatbots and many more.
Claude 2.0 is another such promising LLM that we would very much like to integrate in textbase.
Just make another class in there like:
class Claude:
def generate():
pass
Python Client SDK
mentioned in the documentation. Keep in mind that you might have to restructure the response in the format that textbase
accepts. 👉🏻 ReferenceRefer to the code in models.py
, play around with it after setting things up locally.
main.py
, just like the one for OpenAI.docs.textbase.ai
claude-bot.md
and add relevant information there.Let us know if you face any issues!
Issue Overview:
When the user clicks on the "Send" button without providing any input, the application encounters an unexpected behavior. Instead of gracefully handling the empty input scenario, it currently proceeds with the interaction, which may lead to unintended outcomes. This issue aims to address this problem and improve the user experience.
Expected Behavior:
The application should handle the case of an empty input field when the user clicks the "Send" button. It should prompt the user to provide valid input and prevent any unintended actions based on empty inputs.
Proposed Solution:
To enhance the user experience and avoid issues arising from empty inputs, the application should implement client-side validation for the input field. When the user clicks the "Send" button, the application should check if the input field is empty. If it is, a user-friendly message or a tooltip should be displayed, prompting the user to enter valid input. This approach ensures that the user is aware of the requirement to provide meaningful input and helps prevent unnecessary interactions with the chatbot.
Steps to Reproduce:
Open the application.
Type nothing in the input field.
Click the "Send" button.
Current Outcome:
The application proceeds with the interaction despite an empty input, potentially leading to undesired behavior or empty responses from the chatbot.
Expected Outcome:
Upon clicking the "Send" button with an empty input field, the application should display a prompt or tooltip informing the user to enter valid input before proceeding with the interaction.
The Textbase AI page has three chatbot templates. Among them, ChatGPT 3.5 is the most popular one. However, it lacks other popular chatbot templates like Bard AI, CloudE AI 2 and many more.
I would like to add the a chatbot template for Bard AI in the codebase if this issue is relevant.
what is your license detail
image is not loaded on machine ....
The server is up and running on my local, but when I try to interact with the chatbot I am getting the following error.
"filepath_of_main.py/main.py that is expected to define function doesn't exist" on the command line.
When I inspected the frontend page . I am getting the following error.
POST http://localhost:8080/sendMessage net::ERR_CONNECTION_REFUSED.
I am also attaching the screenshot.
The link here leads to
https://github.com/cofactoryai/textbase/blob/main/docs/deployment/deploy-from-cli
which does not exist.
.toml
file also-[tool.poetry]
name = "textbase-client"
version = "0.1.7"
The textbase project lacked sentiment analysis, which is a critical feature for effective chatbot interactions. Without sentiment analysis, the chatbots were unable to respond appropriately to the emotional content of user input, leading to generic and often unsuitable responses for negative or neutral inputs.
in textbase_cli.py
there is only one flag called --path
for taking in the path to your main.py
file.
What we want is a way that by default the port for the command functions_framework --target=on_message --source={dir} --debug
in line number 29 be 8080 (which is already the default case), but it should be changeable to any other other lets say 8081.
So-
utils/server.py
we are using localhost:8080
directly here. the PORT 4000 is of frontend UI
and 8080 is for backend
and these two communicate together.Now in this file also, you'll have to get the port from the textbase_cli.py
file which should be 8080 by default and the new one if user changed it, so that the new URL with new port is displayed in the line 36.
Figure out a way to do this and create a PR with proper working screenshots in local setup 🚀
Just like the the Dalle Bot we also want to integrate Stable Diffusion for image generation techniques. Replicate provides an API through which we can do this.
Have a look at this demo here on how to use the API.
In the textbase/models.py
you'll see a class for DallE
which returns the URL of the generated image.
It appears on the UI something like this-
To make sure that this is rendered properly in the frontend, in the response inside main.py
we will use the Image
class as done in DallE
return {
"messages": [Image(url=bot_response)],
"state": state
}
Add a StableDiffusion
class in the models.py and add the logic there.
On the same line, I guess replicate
must give a URL for the image generated. We can use a similar approach in that as well.
Make sure to make another directory as textbase/examples/stable-diffusion
after testing that things are working fine and also add the respective docs.
Refer to docs.textbase.ai
for setting up the project locally
When I am deploying chatbot at my end It is showing network error.
I created a new chatbot at my end but results are same getting same message "Network Error".
I can helo develop palm ai chabot similar to that of openai
assign me under hacktoberfest
Adding the Story Telling ChatBot idea @silasalberti
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.