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

Enable Custom LLMs to use Tools #4500

Merged

Conversation

nweatherburn
Copy link

@nweatherburn nweatherburn commented Mar 5, 2025

Description

This PR enables Custom LLMs to yield ChatMessage's as well as strings in customStreamChat. This enables customLLMs to use tools as well. The change is backwards compatible.

Checklist

  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screenshots

N/A

Testing instructions

After launching the application in debug mode, you can edit your config.ts to the below to see both messages getting correctly yielded.

export function modifyConfig(config: Config): Config {
  config.models = [
    {
      options: {
        model: "Example Model",
        title: "Example Title",    // Required for ModelDescription
      },
      streamChat: async function* (
        messages: ChatMessage[],
        signal: AbortSignal,
        options: CompletionOptions,
        fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>,
      ): AsyncGenerator<ChatMessage | string> {
        yield "This is a string";
        yield {role: "assistant", content: "This is a ChatMessage"};
      }
    }
  ];

  return config;
}```

Copy link

netlify bot commented Mar 5, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 14e30d8
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67c8d8a2cbcabe0008be894e

Copy link
Contributor

@sestinj sestinj left a comment

Choose a reason for hiding this comment

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

thanks @nweatherburn this is great!

@sestinj sestinj merged commit 058c29b into continuedev:main Mar 8, 2025
31 checks passed
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.

2 participants