Update ontochat/chatbot.py
Browse files- ontochat/chatbot.py +6 -7
ontochat/chatbot.py
CHANGED
@@ -27,12 +27,11 @@ def chat_completion(api_key, messages):
|
|
27 |
|
28 |
def build_messages(history):
|
29 |
"""
|
30 |
-
|
31 |
-
:param history:
|
32 |
-
:return:
|
33 |
"""
|
34 |
-
messages =
|
35 |
for item in history:
|
36 |
-
messages.append({"role": "
|
37 |
-
|
38 |
-
return messages[1:]
|
|
|
27 |
|
28 |
def build_messages(history):
|
29 |
"""
|
30 |
+
Convert Gradio Chatbot history to OpenAI client messages
|
31 |
+
:param history: List of dictionaries with 'role' and 'content' keys
|
32 |
+
:return: List of OpenAI client messages
|
33 |
"""
|
34 |
+
messages = []
|
35 |
for item in history:
|
36 |
+
messages.append({"role": item["role"], "content": item["content"]})
|
37 |
+
return messages
|
|