From 3431c5860e1f79cb748d8b6667ea6cb56ece813d Mon Sep 17 00:00:00 2001 From: om-khade-algobulls Date: Tue, 15 Aug 2023 19:43:11 +0530 Subject: [PATCH] Add GenAI chat feature --- pyalgotrading/algobulls/api.py | 46 +++++++++++++++++++++++++ pyalgotrading/algobulls/connection.py | 49 ++++++++++++++++++++++++--- 2 files changed, 90 insertions(+), 5 deletions(-) diff --git a/pyalgotrading/algobulls/api.py b/pyalgotrading/algobulls/api.py index 48575489..7979d387 100644 --- a/pyalgotrading/algobulls/api.py +++ b/pyalgotrading/algobulls/api.py @@ -30,6 +30,8 @@ def __init__(self, connection): self.__key_papertrading = {} # strategy-cstc_id mapping self.__key_realtrading = {} # strategy-cstc_id mapping self.pattern = re.compile(r'(? 20: + self.continue_from_previous_session(page_no=page_no + 1) + elif user_input.isdigit() and 1 <= int(user_input) <= len(customer_genai_sessions): + selected_session_index = page_no + int(user_input) - 1 + selected_session_id = customer_genai_sessions[selected_session_index]["id"] + self.api.genai_api_key = selected_session_id + + def initiate_chat(self, start_fresh=None, chat_gpt_model=None): + if start_fresh: + # reset session + self.api.genai_api_key = None + elif start_fresh is not None: + self.continue_from_previous_session(page_no=1) + + self.start_chat(chat_gpt_model) def save_latest_generated_strategy(self): pass