Commit graph

131 commits

Author SHA1 Message Date
eccca2a624
Handle max tokens exception in chat response generation
Introduced error handling for the 'max_tokens' exception during chat response generation. In cases where the maximum token count is exceeded, the bot now falls back to a no-tools response, avoiding the halt of conversation. This ensures a smoother chat experience and persistence in responding, even when a limit is reached. Any other exceptions will still be raised as before, maintaining error transparency.
2023-11-30 14:18:47 +01:00
670667567e
Handle key upload errors and refine tool flow responses
- Introduce error handling for the keys upload process, logging failures to assist with troubleshooting.
- Improve exception handling in the OpenAI class by returning a more informative response based on the exception arguments if available.
- Replace a return statement in the Newroom tool with an exception raise to standardize tool action termination and provide clearer flow control.

Resolves issue with silent key upload failures. Refines response and control flow for better clarity and debugging.
2023-11-29 20:31:07 +01:00
75360d040a
Introduce Async Enhancements and New Room Tool
Enabled asynchronous key upload in the roommember callback to improve efficiency. Fixed the chat response generation by properly referencing the event sender rather than the room ID, aligning user context with chat messages. Corrected the user parameter misuse in the OpenAI class to utilize the room ID. Extended the toolkit to include a 'newroom' feature for creating and setting up new Matrix rooms, thereby enhancing bot functionality.

This commit significantly improves bot response times and contextual accuracy while interacting within rooms and adds a valuable feature for users to create rooms seamlessly.
2023-11-29 15:48:56 +01:00
ad600faf4b
Refine logging and add image description feature
Enhanced the speech generation logging to display the word count of the input text instead of the full text. This change prioritizes user privacy and improves log readability. Implemented a new feature to generate descriptions for images within a conversation, expanding the bot's capabilities. Also, refactor `BaseTool` class to securely access arguments through `.get` method and to include `messages` by default, ensuring graceful handling of missing arguments.
2023-11-29 14:53:19 +01:00
03768b5b27
Improve speech-to-text audio handling
Enhanced the audio processing in speech-to-text conversion by converting the input audio to MP3 format before transcription. The logging now reflects the word count of the recognized text, providing clearer insight into the output. This should improve compatibility with the transcription service and result in more accurate transcriptions.
2023-11-29 12:30:26 +01:00
eba650188b
Add datetime tool to gptbot
Introduced a new 'datetime' tool to the gptbot, which provides the current date and time in UTC. This enhancement caters to the need for time-related queries within the bot's functionality, expanding its utility for users dealing with time-sensitive information.
2023-11-29 12:06:58 +01:00
e1782d1034
Disable test and encryption callbacks
Temporarily commented out callbacks for test responses, event handling, and encrypted messages to focus on core functionality stabilization. This change aims to simplify the debugging process and enhance the reliability of active features during the development phase. Encryption handling will be reintroduced after refining base features.
2023-11-29 11:43:09 +01:00
a6fca53b51
Improve Wikipedia error messages
Refined the exception details in the Wikipedia tool to include the search query when no results are found, enhancing the clarity of error outputs for end-users. This change helps in debugging by indicating the exact query that led to a no-results situation. Additionally, the existing failure-to-connect error message was left as-is, maintaining accurate API connectivity diagnostics.
2023-11-29 11:33:24 +01:00
c92828def1
Optimize message concatenation, add Wikipedia tool
Refactor the message concatenation logic within the chat response to ensure the original final message remains intact at the end of the sequence. Introduce a new 'Wikipedia' tool to the bot's capabilities, allowing users to query and retrieve information from Wikipedia directly through the bot's interface. This enhancement aligns with efforts to provide a more informative and interactive user experience.
2023-11-29 11:30:54 +01:00
3ee7505aa5
Remove debug URL print from weather tool
Eliminated a print statement that was outputting the API request URL in the weather fetching tool, ensuring sensitive key information is not displayed in logs. This increases security by preventing potential API key exposure.
2023-11-29 09:02:47 +01:00
36e34d5fcf
Removed traceback print from exception handling in bot's tool call
Eliminated the printing of traceback in the exception handling block when the GPTBot encounters an error calling a tool. This change cleans up the logs by removing a redundant error output since relevant information is already being logged. The update aims to enhance the clarity and readability of the logs in case of tool calling errors.
2023-11-29 08:33:41 +01:00
4d64593e89
Enhanced tool handling and image gen
Refactored `call_tool` to pass `room` and `user` for improved context during tool execution.
Introduced `Handover` and `StopProcessing` exceptions to better control the flow when calling tools involves managing exceptions and handovers between tools and text generation.
Enabled flexibility with `room` param in sending images and files, now accepting both `MatrixRoom` and `str` types.
Updated `generate_chat_response` in OpenAI class to incorporate tool usage flag and more pruned message handling for tool responses.
Introduced `orientation` option for image generation to specify landscape or portrait.
Implemented two new tool classes, `Imagine` and `Imagedescription`, to streamline image creation and description processes accordingly.

This improved error handling and additional granularity in tool invocation ensure that the bot behaves more predictably and transparently, particularly when interacting with generative AI and handling dialogue. The flexibility in both response and image generation caters to a wider range of user inputs and scenarios, ultimately enhancing the bot's user experience.
2023-11-29 08:33:20 +01:00
54dd80ed50
feat: Enable calling tools in chat completion
This commit adds functionality to call tools within the chat completion model. By introducing the `call_tool()` method in the `GPTBot` class, tools can now be invoked with the appropriate tool call. The commit also includes the necessary changes in the `OpenAI` class to handle tool calls during response generation. Additionally, new tool classes for geocoding and dice rolling have been implemented. This enhancement aims to expand the capabilities of the bot by allowing users to leverage various tools directly within the chat conversation.
2023-11-28 18:15:21 +01:00
155ea68e7a
feat: Add voice input and output support
This change adds support for voice input and output to the GPTbot. Users can enable this feature using the new `!gptbot roomsettings` command. Voice input and output are currently supported via OpenAI's TTS and Whisper models. However, note that voice input may be unreliable at the moment. This enhancement expands the capabilities of the bot, allowing users to interact with it using their voice. This addresses the need for a more user-friendly and natural way of communication.
2023-11-26 07:58:10 +01:00
554d3d8aa0
Refactor OpenAI class methods to retrieve assistant and thread IDs. 2023-11-19 17:02:40 +01:00
c3fe074b1e
Refactor OpenAI class to use asynchronous room check for generating response.
- Replaced synchronous room check with asynchronous room check using `await`.
- Updated the code to use the `await` keyword before calling `self.room_uses_assistant(room)`.
- This change enables the code to generate assistant response asynchronously.
2023-11-19 16:15:28 +01:00
65bf724a0b
feat: Add method to check if room uses assistant
This commit adds a new method `room_uses_assistant` to the OpenAI class. This method allows checking whether a given room uses an assistant. It uses the `room_settings` table in the database to determine if the specified room has the `openai_assistant` setting.
2023-11-19 16:06:59 +01:00
54f56c1b1a
Add launch configuration for Python module 2023-11-19 15:38:43 +01:00
fbbe82a1fc
Refactor image generation code with dynamic size and model
The commit modifies the image generation code in the OpenAI class. The size and model of the generated image can now be dynamically set based on the provided prompt. The code has been refactored to handle different image sizes and models correctly.
2023-11-19 15:38:34 +01:00
14da88de8b
feat: Improve image generation quality selection
The code change adds a conditional statement to select the image generation quality based on the selected image model.
2023-11-19 15:26:09 +01:00
474af54ae1
Start assistant implementation to support generating responses using an assistant if the room uses an assistant. Also, add methods to create and setup an assistant for a room. 2023-11-19 15:24:22 +01:00
2269018e92
Work towards encryption support 2023-11-11 17:22:43 +01:00
09393b4216
Remove debugging output that is no longer needed 2023-11-11 14:54:40 +01:00
48f13fcf7f
Fix truncation calculation 2023-11-11 13:32:31 +01:00
0317b2f5aa
Improve handling of event and other messages for chat response
Remove limitation of number of attached images for image-aware chat completions
2023-11-11 13:26:21 +01:00
4113a02232
Add image input on models that support it, fix some bugs, bump required OpenAI version 2023-11-11 12:27:19 +01:00
c238da9b99
openai: Fix image_model assignment, add method to check if the used chat model supports images messages 2023-11-11 09:51:28 +01:00
1b290c6b92
Revert last commit 2023-11-09 12:31:46 +01:00
37a1e6a85c
Fix handling of commands in GPTBot class 2023-11-09 12:30:12 +01:00
72340095f9
Fix bot command prefix recognition and handle ignore bot commands.
- Fixed bot command prefix recognition to include prefixes starting with an asterisk (= edited messages)
- Added handling of ignoring bot commands in the '_last_n_messages' method.
2023-11-09 12:29:04 +01:00
2e6c07eb22
Fix issue with OpenAI class to set the quality parameter based on the model type. 2023-11-07 15:55:25 +01:00
5a1a3733c5
Update OpenAI configuration with ImageModel and related changes
Previously, there was no option to specify the model for image generation in the OpenAI configuration. This commit adds a new option called "ImageModel" where you can specify the desired model. The default value for this option is "dall-e-2".

In the `GPTBot` class, the OpenAI object is now initialized with the `ImageModel` option if it is provided in the configuration. This allows the bot to use the specified image generation model in addition to the chat model.

Furthermore, in the `OpenAI` class, the `image_api` attribute has been renamed to `image_model` to reflect its purpose more accurately. The default value has also been updated to "dall-e-2" to align with the new configuration option.

This commit ensures that the OpenAI configuration is up-to-date and allows users to specify the desired image generation model.
2023-11-07 14:02:10 +01:00
d2c6682faa
Version bump to 0.1.1 2023-06-01 06:34:09 +00:00
8147a89f69
Merge branch 'thebalaa-main' 2023-06-01 06:28:22 +00:00
136f56f208
Merge branch 'main' of https://github.com/thebalaa/matrix-gptbot into thebalaa-main 2023-06-01 06:27:58 +00:00
27078243a8
Merge branch 'thebalaa-main' 2023-06-01 06:24:45 +00:00
f419206a9a
Fix type hints in migrations 2023-06-01 06:23:48 +00:00
Mo Balaa
0b0bf8a673 Fixes to get working out of the box 2023-05-31 23:29:51 -05:00
b1b274be57
Allow setting BaseURL for OpenAI API 2023-05-31 18:21:07 +00:00
2b6969dfe8
Fix pip install command in development docs 2023-05-25 15:46:38 +00:00
cce082ef67
Bump version to 0.1.0
Improve logging
Black formatting
2023-05-25 12:41:32 +00:00
c188223cea
Whelp. 2023-05-25 12:05:07 +00:00
45c336e609
Fix message sending in newroom command 2023-05-25 10:50:37 +00:00
154e234943
Fix README 2023-05-25 10:17:20 +00:00
55809a9a39
Make it an importable module
Abandon DuckDB in favor of sqlite3
2023-05-25 07:28:28 +00:00
3a1d1ea86a
Merge branch 'justin-russell-bugfixes' 2023-05-20 19:11:54 +00:00
Justin
861b82061f Use suggested migration fix 2023-05-20 11:20:54 -05:00
Justin
b41a9ecd14 Adds retry logic for failed openai requests 2023-05-19 15:37:04 -05:00
Justin
6c97c0f61d Cleanup unused imports 2023-05-19 14:54:51 -05:00
Justin
cdca5fb124 using openai async methods 2023-05-19 14:52:20 -05:00