-
Notifications
You must be signed in to change notification settings - Fork 4
fix: correct params in llm api call #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
088ee20
2c1f14d
7acff90
15c359a
dcd4065
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,12 +108,10 @@ def test_timeout(self, exception, mock_requests): | |
| def test_post_request_structure(self, mock_requests): | ||
| mock_requests.post = MagicMock() | ||
|
|
||
| mock_convo_hist_id = str(uuid.uuid5(uuid.NAMESPACE_URL, f'{self.user_id}_{self.course_id}')) | ||
|
|
||
| completion_endpoint = settings.CHAT_COMPLETION_API | ||
| connect_timeout = settings.CHAT_COMPLETION_API_CONNECT_TIMEOUT | ||
| read_timeout = settings.CHAT_COMPLETION_API_READ_TIMEOUT | ||
| headers = {'Content-Type': 'application/json', 'Conversation-History-ID': mock_convo_hist_id} | ||
| headers = {'Content-Type': 'application/json'} | ||
|
|
||
| response_body = { | ||
| 'message_list': [{'role': 'system', 'content': self.prompt_template}] + self.message_list, | ||
|
|
@@ -133,18 +131,20 @@ def test_post_request_structure_v2_endpoint(self, mock_requests, mock_v2_enabled | |
| mock_requests.post = MagicMock() | ||
| mock_v2_enabled.return_value = True | ||
|
|
||
| mock_convo_hist_id = str(uuid.uuid5(uuid.NAMESPACE_URL, f'{self.user_id}_{self.course_id}')) | ||
| mock_convo_id_seed = json.dumps([str(self.user_id), str(self.course_id)], separators=(',', ':')) | ||
| mock_convo_hist_id = str(uuid.uuid5(uuid.NAMESPACE_URL, str(mock_convo_id_seed))) | ||
|
Comment on lines
+134
to
+135
|
||
|
|
||
| completion_endpoint_v2 = settings.CHAT_COMPLETION_API_V2 | ||
| connect_timeout = settings.CHAT_COMPLETION_API_CONNECT_TIMEOUT | ||
| read_timeout = settings.CHAT_COMPLETION_API_READ_TIMEOUT | ||
| headers = {'Content-Type': 'application/json', 'Conversation-History-ID': mock_convo_hist_id} | ||
| headers = {'Content-Type': 'application/json'} | ||
|
|
||
| response_body = { | ||
| 'client_id': 'edx_olc_la', | ||
| 'system_message': self.prompt_template, | ||
| 'messages': self.message_list, | ||
| 'external_id': self.user_id, | ||
| 'conversation_id': mock_convo_hist_id, | ||
| } | ||
|
|
||
| self.get_response() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_request_body()now requiresconvo_id, but the v1 request body ignores it. This forcesget_chat_response()to always compute a conversation id even when the v2 endpoint is disabled, and makescreate_request_body()harder to reuse correctly. Consider makingconvo_idoptional (e.g., defaulting toNone) and only generating/passing it when building the v2 payload.