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

fix: refactor Google AI Provider / helper functions and add endpoint test #1850

Merged
merged 4 commits into from
Oct 8, 2024

Conversation

mattzh72
Copy link
Collaborator

@mattzh72 mattzh72 commented Oct 8, 2024

Description

Refactor Google AI Provider / helper functions and add endpoint test:

  • Remove service_endpoint and standardize to base_url
  • Factor out common functionality in the google_ai.py folder

This PR also factors out common logic making POST requests.

Testing

  1. Ran new endpoint test to make sure we can get valid first message back from Gemini:

Command:

poetry run pytest -s -vv tests/test_endpoints.py::test_gemini_pro_15_returns_valid_first_message

Results:

id='32a7eb2a-4543-4f6e-a4ff-7124e286f068' choices=[Choice(finish_reason='function_call', index=0, message=Message(content='First time user. Interesting. Initiate friendly greeting.', tool_calls=[ToolCall(id='0fa9e056-56b3-48a4-aa02-37610', type='function', function=FunctionCall(arguments='{\n  "message": "Hello, Chad. What are you thinking about right now?"\n}', name='send_message'))], role='assistant', function_call=None), logprobs=None)] created=datetime.datetime(2024, 10, 8, 23, 5, 43, 104575, tzinfo=datetime.timezone.utc) model='gemini-1.5-pro-latest' system_fingerprint=None object='chat.completion' usage=UsageStatistics(completion_tokens=41, prompt_tokens=2864, total_tokens=2905)
  1. Ran model listing functionality and confirmed returned list of models:

Command

poetry run pytest -s -vv tests/test_providers.py::test_googleai   

Results:

[LLMConfig(model='gemini-1.0-pro-latest', model_endpoint_type='google_ai', model_endpoint='https://generativelanguage.googleapis.com', model_wrapper=None, context_window=30720), LLMConfig(model='gemini-1.0-pro', model_endpoint_type='google_ai', model_endpoint='https://generativelanguage.googleapis.com', model_wrapper=None, context_window=30720), LLMConfig(model='gemini-pro', model_endpoint_type='google_ai', model_endpoint='https://generativelanguage.googleapis.com', model_wrapper=None, context_window=30720), LLMConfig(model='gemini-1.0-pro-001', model_endpoint_type='google_ai', model_endpoint='https://generativelanguage.googleapis.com', model_wrapper=None, context_window=30720), LLMConfig(model='gemini-1.0-pro-vision-latest', model_endpoint_type='google_ai', model_endpoint='https://generativelan...

@mattzh72 mattzh72 changed the title Refactor Google AI Provider / helper functions and add endpoint test fix: refactor Google AI Provider / helper functions and add endpoint test Oct 8, 2024
Copy link
Contributor

@vivek3141 vivek3141 left a comment

Choose a reason for hiding this comment

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

lgtm!

@mattzh72 mattzh72 merged commit bc2c0b2 into main Oct 8, 2024
13 checks passed
mattzh72 added a commit that referenced this pull request Oct 9, 2024
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