Skip to content

Commit

Permalink
[Partner] Update google integration test (#14883)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Dec 19, 2023
1 parent f88af1f commit 0d4cbbc
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ def test_chat_google_genai_stream() -> None:
"""Test streaming tokens from OpenAI."""
llm = ChatGoogleGenerativeAI(model=_MODEL)

for token in llm.stream("I'm Pickle Rick"):
for token in llm.stream("This is a test. Say 'foo'"):
assert isinstance(token.content, str)


async def test_chat_google_genai_astream() -> None:
"""Test streaming tokens from OpenAI."""
llm = ChatGoogleGenerativeAI(model=_MODEL)

async for token in llm.astream("I'm Pickle Rick"):
async for token in llm.astream("This is a test. Say 'foo'"):
assert isinstance(token.content, str)


async def test_chat_google_genai_abatch() -> None:
"""Test streaming tokens from ChatGoogleGenerativeAI."""
llm = ChatGoogleGenerativeAI(model=_MODEL)

result = await llm.abatch(["I'm Pickle Rick", "I'm not Pickle Rick"])
result = await llm.abatch(
["This is a test. Say 'foo'", "This is a test, say 'bar'"]
)
for token in result:
assert isinstance(token.content, str)

Expand All @@ -42,7 +44,7 @@ async def test_chat_google_genai_abatch_tags() -> None:
llm = ChatGoogleGenerativeAI(model=_MODEL)

result = await llm.abatch(
["I'm Pickle Rick", "I'm not Pickle Rick"], config={"tags": ["foo"]}
["This is a test", "This is another test"], config={"tags": ["foo"]}
)
for token in result:
assert isinstance(token.content, str)
Expand All @@ -52,7 +54,7 @@ def test_chat_google_genai_batch() -> None:
"""Test batch tokens from ChatGoogleGenerativeAI."""
llm = ChatGoogleGenerativeAI(model=_MODEL)

result = llm.batch(["I'm Pickle Rick", "I'm not Pickle Rick"])
result = llm.batch(["This is a test. Say 'foo'", "This is a test, say 'bar'"])
for token in result:
assert isinstance(token.content, str)

Expand All @@ -61,7 +63,7 @@ async def test_chat_google_genai_ainvoke() -> None:
"""Test invoke tokens from ChatGoogleGenerativeAI."""
llm = ChatGoogleGenerativeAI(model=_MODEL)

result = await llm.ainvoke("I'm Pickle Rick", config={"tags": ["foo"]})
result = await llm.ainvoke("This is a test. Say 'foo'", config={"tags": ["foo"]})
assert isinstance(result.content, str)


Expand All @@ -70,7 +72,7 @@ def test_chat_google_genai_invoke() -> None:
llm = ChatGoogleGenerativeAI(model=_MODEL)

result = llm.invoke(
"I'm Pickle Rick",
"This is a test. Say 'foo'",
config=dict(tags=["foo"]),
generation_config=dict(top_k=2, top_p=1, temperature=0.7),
)
Expand Down

0 comments on commit 0d4cbbc

Please sign in to comment.