-
Notifications
You must be signed in to change notification settings - Fork 54
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
test: convert Google Gemini tests to VCR #118
Merged
+195
−53
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
packages/exchange/tests/providers/cassettes/test_google_complete.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
interactions: | ||
- request: | ||
body: '{"system_instruction": {"parts": [{"text": "You are a helpful assistant."}]}, | ||
"contents": [{"role": "user", "parts": [{"text": "Hello"}]}]}' | ||
headers: | ||
accept: | ||
- '*/*' | ||
accept-encoding: | ||
- gzip, deflate | ||
connection: | ||
- keep-alive | ||
content-length: | ||
- '139' | ||
content-type: | ||
- application/json | ||
host: | ||
- generativelanguage.googleapis.com | ||
user-agent: | ||
- python-httpx/0.27.2 | ||
method: POST | ||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=test_google_api_key | ||
response: | ||
body: | ||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\": | ||
[\n {\n \"text\": \"Hello! \U0001F44B How can I help | ||
you today? \U0001F60A \\n\"\n }\n ],\n \"role\": \"model\"\n | ||
\ },\n \"finishReason\": \"STOP\",\n \"index\": 0,\n \"safetyRatings\": | ||
[\n {\n \"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n | ||
\ \"probability\": \"NEGLIGIBLE\"\n },\n {\n \"category\": | ||
\"HARM_CATEGORY_HATE_SPEECH\",\n \"probability\": \"NEGLIGIBLE\"\n | ||
\ },\n {\n \"category\": \"HARM_CATEGORY_HARASSMENT\",\n | ||
\ \"probability\": \"NEGLIGIBLE\"\n },\n {\n \"category\": | ||
\"HARM_CATEGORY_DANGEROUS_CONTENT\",\n \"probability\": \"NEGLIGIBLE\"\n | ||
\ }\n ]\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\": | ||
8,\n \"candidatesTokenCount\": 12,\n \"totalTokenCount\": 20\n }\n}\n" | ||
headers: | ||
Alt-Svc: | ||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 | ||
Cache-Control: | ||
- private | ||
Content-Type: | ||
- application/json; charset=UTF-8 | ||
Date: | ||
- Wed, 02 Oct 2024 01:06:50 GMT | ||
Server: | ||
- scaffolding on HTTPServer2 | ||
Server-Timing: | ||
- gfet4t7; dur=426 | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Origin | ||
- X-Origin | ||
- Referer | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Frame-Options: | ||
- SAMEORIGIN | ||
X-XSS-Protection: | ||
- '0' | ||
content-length: | ||
- '855' | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
73 changes: 73 additions & 0 deletions
73
packages/exchange/tests/providers/cassettes/test_google_tools.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
interactions: | ||
- request: | ||
body: '{"system_instruction": {"parts": [{"text": "You are a helpful assistant. | ||
Expect to need to read a file using read_file."}]}, "contents": [{"role": "user", | ||
"parts": [{"text": "What are the contents of this file? test.txt"}]}], "tools": | ||
{"functionDeclarations": [{"name": "read_file", "description": "Read the contents | ||
of the file.", "parameters": {"type": "object", "properties": {"filename": {"type": | ||
"string", "description": "The path to the file, which can be relative or\nabsolute. | ||
If it is a plain filename, it is assumed to be in the\ncurrent working directory."}}, | ||
"required": ["filename"]}}]}}' | ||
headers: | ||
accept: | ||
- '*/*' | ||
accept-encoding: | ||
- gzip, deflate | ||
connection: | ||
- keep-alive | ||
content-length: | ||
- '600' | ||
content-type: | ||
- application/json | ||
host: | ||
- generativelanguage.googleapis.com | ||
user-agent: | ||
- python-httpx/0.27.2 | ||
method: POST | ||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=test_google_api_key | ||
response: | ||
body: | ||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\": | ||
[\n {\n \"functionCall\": {\n \"name\": \"read_file\",\n | ||
\ \"args\": {\n \"filename\": \"test.txt\"\n }\n | ||
\ }\n }\n ],\n \"role\": \"model\"\n },\n | ||
\ \"finishReason\": \"STOP\",\n \"index\": 0,\n \"safetyRatings\": | ||
[\n {\n \"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n | ||
\ \"probability\": \"NEGLIGIBLE\"\n },\n {\n \"category\": | ||
\"HARM_CATEGORY_HATE_SPEECH\",\n \"probability\": \"NEGLIGIBLE\"\n | ||
\ },\n {\n \"category\": \"HARM_CATEGORY_HARASSMENT\",\n | ||
\ \"probability\": \"NEGLIGIBLE\"\n },\n {\n \"category\": | ||
\"HARM_CATEGORY_DANGEROUS_CONTENT\",\n \"probability\": \"NEGLIGIBLE\"\n | ||
\ }\n ]\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\": | ||
101,\n \"candidatesTokenCount\": 17,\n \"totalTokenCount\": 118\n }\n}\n" | ||
headers: | ||
Alt-Svc: | ||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 | ||
Cache-Control: | ||
- private | ||
Content-Type: | ||
- application/json; charset=UTF-8 | ||
Date: | ||
- Wed, 02 Oct 2024 01:06:51 GMT | ||
Server: | ||
- scaffolding on HTTPServer2 | ||
Server-Timing: | ||
- gfet4t7; dur=449 | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Origin | ||
- X-Origin | ||
- Referer | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Frame-Options: | ||
- SAMEORIGIN | ||
X-XSS-Protection: | ||
- '0' | ||
content-length: | ||
- '947' | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of IDE warnings about call sites we use, as it is at the moment
tools: Tuple[Tool]
. So, this clears warnings about passing None. Though I wonder if it shouldn't betools: Tuple[Tool, ...]
? Seems that would be more explicit about possibly none, and also clear some other warnings. If you feel this is worthwhile I can in a follow-up or different PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#149