Skip to content

Conversation

@lifeizhou-ap
Copy link
Collaborator

@lifeizhou-ap lifeizhou-ap commented Dec 18, 2024

  • Added groq provider
  • Converted content object list in message (ToolResponse message) to string to match api schema only for Ollama and Groq.
  • Removed the duplications in providers that compatible wit openai api schema
  • Extracted open ai related utils function to a new file openai_utils
  • Added integration tests for google and groq providers and extract the utils to mock_server.rs

Note:
I could not get the capture screenshot working with groq provider as when the message include the toolResult with image the api returns bad request. So far I found they can categorised into 2 scenarios as below:

  • For most non-vision models, it does not accept the user message with image although in the doc it says it does.

    Error message:
    { "request_id": "req_01jfckkap9fcdv2c4cr4tepnfw", "created_at": "2024-12-18T10:04:15.434Z", "error": { "message": "message[0].content must be a string", "type": "invalid_request_error" } }

  • I also tried llama-3.2-11b-vision-preview, it does not accept the payload including the user message with image and system message at the same time.
    Error message:
    { "request_id": "req_01jfcmfx6yf0zbjt4028v4gkcd", "created_at": "2024-12-18T10:19:51.904Z", "error": { "message": "prompting with images is incompatible with system messages", "type": "invalid_request_error" } }

I tried with the python cli, it does not work either but with different reason. I did not look in-depth. I feel this feature does not work originally and we can enhance this in the future when we have more usages with groq

@github-actions
Copy link
Contributor

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Lifei/groq provider". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@lifeizhou-ap lifeizhou-ap changed the base branch from main to v1.0 December 18, 2024 06:40
@lifeizhou-ap lifeizhou-ap changed the title Lifei/groq provider feat: added groq provider Dec 18, 2024
@lifeizhou-ap lifeizhou-ap marked this pull request as ready for review December 18, 2024 06:47
* v1.0:
  requires foreign architectures
  more xcompile deps
  x compilation tools
  chore: Cargo build tokenizers (#491)
  feat: build and release binaries to GH releases (#477)
  fix: width of bubbles and logging errors (#487)
}
}
}
let concatenated_content = tool_content
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Converted content object list in message (ToolResponse message) to string to match api schema. In openai, it accepted "string" or "array", but in groq it only accepts "string" based on their api

Copy link
Collaborator

Choose a reason for hiding this comment

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

@baxen is this related to the error you were seeing on the llama3 databricks endpoint?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've changed to only apply the concatenate logic to ollama and groq

@lifeizhou-ap lifeizhou-ap requested a review from zakiali December 18, 2024 22:15
databricks::DatabricksProvider, google::GoogleProvider, ollama::OllamaProvider,
openai::OpenAiProvider,
};
use crate::providers::groq::GroqProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

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

prob move this up into the super

use crate::providers::openai_utils::{
check_openai_context_length_error, messages_to_openai_spec, openai_response_to_message,
tools_to_openai_spec,
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we should prob use the get_openai_usage and handle_response in this one as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

"ollama" => OLLAMA_MODEL,
"anthropic" => "claude-3-5-sonnet-2",
"google" => "gemini-1.5-flash",
"google" => GOOGLE_DEFAULT_MODEL,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this seems like something we should standardize in the providers for openai, databricks, and anthropic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Ok(Self { client, config })
}

fn get_usage(data: &Value) -> anyhow::Result<Usage> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should consider adding get_usage as a trait for Providers in the base object

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agree. This PR has many changes. I can create a follow-up PR after this PR is merged

@michaelneale
Copy link
Collaborator

@lifeizhou-ap I wouldn't worry about image support for groq and llama models for now if they are proving a problem.

#[serde(default)]
max_tokens: Option<i32>,
},
Groq {
Copy link
Collaborator

Choose a reason for hiding this comment

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

one thing I missed in the google provider and here initially was that we also want to add context_limit and estimate_factor here as well

host,
api_key,
model: ModelConfig::new(model)
.with_temperature(temperature)
Copy link
Collaborator

Choose a reason for hiding this comment

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

context_limit and estimate_factor should go here as well for Groq and Google

tools: &[Tool],
) -> anyhow::Result<(Message, ProviderUsage)> {
let payload =
create_openai_request_payload(&self.config.model, system, messages, tools, true)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

the boolean argument here (true) is a little confusing. I don't think there is a way to specify kwargs, but maybe setting a var before calling the function (e.g. concat_tool_response_contents=true) and passing that in to the function call would be a little more clear?

Copy link
Collaborator

@zakiali zakiali left a comment

Choose a reason for hiding this comment

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

looks good! left a few comments

@lifeizhou-ap lifeizhou-ap merged commit a30094b into v1.0 Dec 20, 2024
3 checks passed
lifeizhou-ap added a commit that referenced this pull request Dec 20, 2024
* v1.0:
  Update cli-release.yml
  feat: added groq provider (#494)
  fix: use rust tls (#500)
  fix: Ldelalande/fix scroll (#504)
  feat: MCP server sdk (simple version first) (#499)
  tiny change to use most recent in stack (#501)
  stop bubbles filling screen (#495)
  chore: V1.0 release automation (#493)
michaelneale added a commit that referenced this pull request Jan 6, 2025
* v1.0: (43 commits)
  feat: openrouter provider (#538)
  [ui] chore: tidy up gui providers (#537)
  [ui]: Polish and system theme fix (#533)
  [ui]: General ui polish to more closely match designs (#532)
  Latency issue fix with prepare_inference (#535)
  chore: use cross to build binaries (#507)
  feat: a system for non developers to augment developer system (#524)
  fix: Broken open directory and new session buttons in more menu (#520)
  refactor: move get_usage to provider trait (#506)
  fix: Make stop button more obvious (#516)
  fix: Enhance Dark mode menu dots visibility (#517)
  working on automating release of .zip and binaries and having them on each PR as well (#509)
  conditionally load memory system in goose server (#508)
  Adds 'instructions' field to InitializeResult (#511)
  feat: MCP client sdk (#505)
  Update cli-release.yml
  feat: added groq provider (#494)
  fix: use rust tls (#500)
  fix: Ldelalande/fix scroll (#504)
  feat: MCP server sdk (simple version first) (#499)
  ...
@yingjiehe-xyz yingjiehe-xyz deleted the lifei/groq-provider branch February 5, 2025 21:05
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.

4 participants