diff --git a/py/ai.py b/py/ai.py index f78b3b7..5879e9d 100644 --- a/py/ai.py +++ b/py/ai.py @@ -93,11 +93,14 @@ class AI: msg['role'] = 'model' genai.configure(api_key=api_key) - model = genai.GenerativeModel("gemini-1.5-flash") + + model = genai.GenerativeModel(model) + chat = model.start_chat( system_instruction=system, - history=[ - {"role": "user", "parts": "Hello"}, - {"role": "model", "parts": "Great to meet you. What would you like to know?"}, - ] + history=messages ) + + response = chat.send_message(message, stream=True) + for chunk in response: + return_class.ai_response[access_token] += chunk.text