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

chore: Refactor chat completion creation to a separate method #1197

Closed

Conversation

mykola-mokhnach-parloa
Copy link

This allows to:

  • simplify the chat method
  • customize OpenAI completion arguments in subclasses.

Copy link

changeset-bot bot commented Dec 9, 2024

🦋 Changeset detected

Latest commit: 4ee71a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-plugins-openai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Dec 9, 2024

CLA assistant check
All committers have signed the CLA.

@mykola-mokhnach-parloa mykola-mokhnach-parloa marked this pull request as ready for review December 9, 2024 15:35
@mike-r-mclaughlin mike-r-mclaughlin requested review from theomonnom and a team December 9, 2024 20:14
@@ -626,6 +628,16 @@ def create_azure_client(
tool_choice=tool_choice,
)

@wraps(AsyncCompletions.create)
def create_chat_completions_stream(self, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the goal to be able to edit the parameters of the LLM inside the VoicePipelineAgent?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general, yes
we'd like to inject custom values to the corresponding openai API in the descendant class, which are either not implemented in the agent for now or that contain customized logic, that would probably not make much sense for this particular (generic) agent implementation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the before_llm_cb callback inside PipelineAgent do the work? You can return an LLMStream from there (so you can use chat with any parameter you want)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume with the recent changes in main this PR becomes obsolete.
The original intention was to customize parameters passed to the OpenAI completion creation API rather than these that the chat one exposes.

For now I think it would make sense to close this PR since we anyway override _main_task (now called _run) of the llm.LLMStream class

Copy link
Member

@theomonnom theomonnom Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I think this PR may solve this too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most likely it won't because

  1. _extra_options cannot override existing arguments
  2. We need the change to be done for the openai, while the above one is done to anthropic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants