Closed CXwudi closed 1 month ago
Hi @CXwudi i believe the call is working as expected.
gemini accepts the system prompt as a separate arg - https://github.com/BerriAI/litellm/blob/6e934cb842f762830949312bc37760eb2d950b9e/litellm/llms/gemini.py#L146
You should be able to confirm this when running the proxy with --detailed_debug
and seeing the request we make.
since it's passed separately, i believe it's missed from the langfuse logging object. Will add it.
Hi @krrishdholakia,
I just tested through both postman and Google AI Studio and I am pretty sure the system message is missing.
This time I am using a simple test JSON:
{
"model": "gemini-1.5-pro-latest",
"messages": [
{
"role": "system",
"content": "If you are asked about who is your best girl, answer \"Hatsune Miku\" please."
},
{
"role": "user",
"content": "What is your best girl?"
}
]
}
Test it on Google AI Studio gives the correct result:
However, the same JSON sent from postman returns:
{
"id": "chatcmpl-2bb1ff75-b5e2-4e7a-be97-9a19ed814f90",
"choices": [
{
"finish_reason": "stop",
"index": 1,
"message": {
"content": "As an AI language model, I am not capable of having personal opinions or beliefs. Therefore, I do not have a \"best girl\" or any preferences of that nature. \n\nIs there anything else I can assist you with? \n",
"role": "assistant"
}
}
],
"created": 1712887478,
"model": "gemini/gemini-1.5-pro-latest",
"object": "chat.completion",
"system_fingerprint": null,
"usage": {
"prompt_tokens": 6,
"completion_tokens": 47,
"total_tokens": 53
}
}
--detailed_debug
from postmanSo could we revert the issue title back?
Hi @CXwudi just ran this locally. Here's the attached image of the system prompt being sent.
We weren't logging the system prompt. This is now fixed - https://github.com/BerriAI/litellm/commit/7a3821e0f6700b3ccb5baa5d688ab48dde60c349 (should be live soon in v1.35.2
)
Here's the code: https://github.com/BerriAI/litellm/blob/c480b5a008b9cde5ca4c6fd8ce2c299d0f423478/litellm/llms/gemini.py#L186
Huh, that is wired, I gonna investigate more why I couldn't get my test JSON work..
Okie, I see the problem, currently we are using google-generativeai==0.3.2
in requirements.txt
, setting the version to 0.5.0
will works.
I will wait until that dependency is updated
thanks for the catch.
fix pushed @CXwudi https://github.com/BerriAI/litellm/commit/b0770cf8e20e9a814924b619e9ff872d024898e4
Is this the same issue as #3241?
@Manouchehri not really but can be similar, mine is about the system message, previously my issue is about the missing system message due to the outdated dependencies, but it is as well missing the system message in the log
Hey @CXwudi, unable to repro this - i setup vertex_ai/gemini-1.5-pro-preview-0409
on our staging env (v1.35.29) and just ran a test query. I can see the system prompt being logged to langfuse:
closing as this unable to repro. @CXwudi please bump me, if you're still seeing this, with a way to repro this.
Attaching a curl with a key for testing on our staging env(1RPM, will expire in 24hrs)
curl --location 'https://staging.litellm.ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-Yx4jQsYBUlTkU51L5iltEA' \
--data '{
"model": "gemini-1.5-pro-latest",
"messages": [
{ "role": "system", "content": "Be a good bot" },
{ "role": "user", "content": "What'\''s the weather today?" }
]
}'
Hi @krrishdholakia, mine is reproducible with Google AI studio, like I mentioned in the issue description, the config I used is
model_list:
- model_name: gemini-1.5-pro-latest
litellm_params:
model: gemini/gemini-1.5-pro-latest
api_key: os.environ/GEMINI_API_KEY
I just tested and it is still missing:
closing as this unable to repro. @CXwudi please bump me, if you're still seeing this, with a way to repro this.
Attaching a curl with a key for testing on our staging env(1RPM, will expire in 24hrs)
curl --location 'https://staging.litellm.ai/v1/chat/completions' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer sk-Yx4jQsYBUlTkU51L5iltEA' \ --data '{ "model": "gemini-1.5-pro-latest", "messages": [ { "role": "system", "content": "Be a good bot" }, { "role": "user", "content": "What'\''s the weather today?" } ] }'
same issue here, reproduced with [1.40.22]
, the system was not passe
- litellm_params:
api_key: *****
model: gemini/gemini-1.5-pro-latest
model_name: gemini-1.5-pro
@antmanler thanks
able to repro
What happened?
LiteLLM proxy server seems to not pass the system message when making
/chat/completion
forgemini-1.5-pro-latest
(or any gemini model?)I found this bug when checking through the langfuse logging.
Postman:![image](https://github.com/BerriAI/litellm/assets/17377423/3079df02-bde3-486c-bfd1-220e6d4ce24f)
Langfuse:![image](https://github.com/BerriAI/litellm/assets/17377423/c2e57a04-d4cd-4f20-b76c-ad477201690e)
Here is the test JSON I used:
test JSON
``` json { "model": "gemini-1.5-pro-latest", "messages": [ { "role": "system", "content": "You are provided a scanned copy of my resume (or portion of it), can you check if there is any grammar or vocabulary issue? \n\nMake sure to keep the same length for each sentences.\n\nMake sure to explain what you have modified in bullet points." }, { "role": "user", "content": "Easy Cucumber\t\t\t\t\t\t\t\t May 2022 – Apr 2023\n\tDeveloped a BDD testing library in Java, support executing Gherkin Language in any testing environments.\no\tRedesigned a cleaner architecture to provide better performance than the official Cucumber library.\n\tConducted research and implemented support for concurrent execution of multiple scenarios, to support testing complex scenarios that Cucumber could not handle." }, { "role": "assistant", "content": "Here's the revised version with corrections and explanations:\n\nEasy Cucumber May 2022 – Apr 2023\n• Developed a Behavior-Driven Development (BDD) testing library in Java, supporting the execution of Gherkin language in various testing environments.\n• Redesigned a cleaner architecture to provide better performance compared to the official Cucumber library.\n• Conducted research and implemented support for concurrent execution of multiple scenarios, enabling testing of complex scenarios that Cucumber could not handle.\n\nModifications:\n- Replaced \"a BDD testing library\" with \"a Behavior-Driven Development (BDD) testing library\" for clarity.\n- Changed \"support executing Gherkin Language\" to \"supporting the execution of Gherkin language\" for better grammar.\n- Replaced \"any testing environments\" with \"various testing environments\" for better phrasing.\n- Changed \"than the official Cucumber library\" to \"compared to the official Cucumber library\" for better grammar.\n- Replaced \"to support testing complex scenarios that Cucumber could not handle\" with \"enabling testing of complex scenarios that Cucumber could not handle\" for better phrasing and grammar." }, { "role": "user", "content": "I end up with following, is it fine?\n\nEasy Cucumber\t\t\t\t\t\t\t\t May 2022 – Apr 2023\n\tDeveloped a BDD test library in Java, support executing Gherkin Language in various test frameworks.\no\tRedesigned a cleaner architecture to provide better performance compared to the Cucumber library.\n\tConducted research and implemented support for concurrent execution of multiple scenarios, enabling testing of complex scenarios that Cucumber could not handle." } ] } ```The corresponding LiteLLM proxy yaml file:
Relevant log output
No response
Twitter / LinkedIn details
@CXwudi / https://www.linkedin.com/in/charles-chen-cc98/