-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(llm): add support for fine-tuned OpenAI models #682
Changes from all commits
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 | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -130,3 +130,10 @@ def test_call_supported_chat_model(self, mocker, prompt): | |||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
result = openai.call(instruction=prompt) | ||||||||||||||||||||||||||||
assert result == "response" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
def test_call_finetuned_model(self, mocker, prompt): | ||||||||||||||||||||||||||||
openai = OpenAI(api_token="test", model="ft:gpt-3.5-turbo:my-org:custom_suffix:id") | ||||||||||||||||||||||||||||
mocker.patch.object(openai, "chat_completion", return_value="response") | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
result = openai.call(instruction=prompt) | ||||||||||||||||||||||||||||
assert result == "response" | ||||||||||||||||||||||||||||
Comment on lines
+134
to
+139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new test case - mocker.patch.object(openai, "chat_completion", return_value="response")
+ chat_completion_mock = mocker.patch.object(openai, "chat_completion", return_value="response") - assert result == "response"
+ assert result == "response"
+ chat_completion_mock.assert_called_once_with(instruction=prompt, model="gpt-3.5-turbo") Committable suggestion (Beta)
Suggested change
|
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.
The code checks if the model name contains "ft:" and extracts the base model name accordingly. This is a good approach to handle fine-tuned models. However, it assumes that the model name after "ft:" is always valid. It would be better to add a check to ensure that the extracted model name is not empty or invalid. This will prevent potential errors when calling the OpenAI API.
Committable suggestion (Beta)