Skip to content
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

Upgrade openai version to 1.13 and langchain to version 0.1.9 #1529

Merged
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
21125c6
Upgrading `openai` to version 1.13
mdemoret-nv Feb 20, 2024
7bbff5b
Fixing issues with the conda solve
mdemoret-nv Feb 21, 2024
9a569d7
Removing duplicated conftest
mdemoret-nv Feb 21, 2024
fff3db4
Improving the LLM Services
mdemoret-nv Feb 21, 2024
28c257f
Style cleanup
mdemoret-nv Feb 21, 2024
47740ba
Removing quiet argument for debugging
mdemoret-nv Feb 21, 2024
5c85be2
Updating the runner versions
mdemoret-nv Feb 22, 2024
b379329
Style cleanup
mdemoret-nv Feb 22, 2024
af1d2fd
Adding numexpr
mdemoret-nv Feb 22, 2024
b1e2ec2
Adding ability to run CI locally with volume mounted source
mdemoret-nv Feb 23, 2024
402ef43
Fixing a test
mdemoret-nv Feb 23, 2024
b98cb68
Merge branch 'branch-24.03' into mdd_upgrade-openai-version
mdemoret-nv Feb 23, 2024
b06ead0
Reverting some changes
mdemoret-nv Feb 23, 2024
7da0b9e
Fixing deprecation message
mdemoret-nv Feb 23, 2024
a883a1f
Incorporating code review feedback
mdemoret-nv Feb 23, 2024
bb08a0b
Add pydantic to autodoc_mock_imports to prevent sphinx from trying to…
dagardner-nv Feb 23, 2024
ca34d76
update openai mocks
dagardner-nv Feb 23, 2024
69f7350
Update tests to match constructor arguments are now keyword only
dagardner-nv Feb 23, 2024
5bdfed6
Update tests to use updated mocks
dagardner-nv Feb 23, 2024
42e5305
get_client is keyword only now
dagardner-nv Feb 23, 2024
65dc0c6
Always need to pass in the parent object, we no longer send the syste…
dagardner-nv Feb 23, 2024
318931f
Update tests
dagardner-nv Feb 23, 2024
ed59700
pylint fixes
dagardner-nv Feb 23, 2024
d805858
Pass temperature directly
dagardner-nv Feb 23, 2024
4d952c8
Update langchain version to be compat with our openai version
dagardner-nv Feb 23, 2024
675b9ca
Fix paths to conda yamls
dagardner-nv Feb 23, 2024
73d2062
Update tests to match langchain changes
dagardner-nv Feb 23, 2024
ccdbdf6
Fix test
dagardner-nv Feb 23, 2024
d5f049c
pylint fix
dagardner-nv Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Incorporating code review feedback
  • Loading branch information
mdemoret-nv committed Feb 23, 2024
commit a883a1f5f260083627600ece21dda6805d4dc887
28 changes: 17 additions & 11 deletions morpheus/llm/services/openai_chat_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ class _ApiLogger:
Simple class that allows passing back and forth the inputs and outputs of an API call via a context manager.
"""

log_template: typing.ClassVar[str] = dedent("""
============= MESSAGE %d START ==============
--- Input ---
%s
--- Output --- (%f ms)
%s
============= MESSAGE %d END ==============
""").strip("\n")

def __init__(self, *, message_id: int, inputs: typing.Any) -> None:

self.message_id = message_id
Expand Down Expand Up @@ -123,16 +132,12 @@ def _api_logger(self, inputs: typing.Any):
end_time = time.time()
duration_ms = (end_time - start_time) * 1000.0

log_str = dedent("""
============= MESSAGE %d START ==============
--- Input ---
%s
--- Output --- (%f ms)
%s
============= MESSAGE %d END ==============
""").strip("\n")

self._parent._logger.info(log_str, message_id, api_logger.inputs, duration_ms, api_logger.outputs, message_id)
self._parent._logger.info(_ApiLogger.log_template,
message_id,
api_logger.inputs,
duration_ms,
api_logger.outputs,
message_id)

def _create_messages(self,
prompt: str,
Expand All @@ -158,7 +163,8 @@ def _extract_completion(self, completion: "openai.types.chat.chat_completion.Cha
def _generate(self, prompt: str, assistant: str = None) -> str:
messages = self._create_messages(prompt, assistant)

output = self._client.chat.completions.create(model=self._model_name, messages=messages, **self._model_kwargs)
output: openai.types.chat.chat_completion.ChatCompletion = self._client.chat.completions.create(
model=self._model_name, messages=messages, **self._model_kwargs)

return self._extract_completion(output)

Expand Down
Loading