Skip to content

Commit

Permalink
update: gemini_sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
soumik12345 committed Aug 6, 2024
1 parent b2c7b42 commit 6aaf227
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions weave/integrations/gemini/gemini_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ def gemini_wrapper(name: str) -> Callable[[Callable], Callable]:
def wrapper(fn: Callable) -> Callable:
op = weave.op()(fn)
op.name = name # type: ignore
# return op
return add_accumulator(
op, # type: ignore
make_accumulator=lambda inputs: gemini_accumulator,
should_accumulate=should_use_accumulator,
)
return op

return wrapper

Expand All @@ -54,5 +49,32 @@ def wrapper(fn: Callable) -> Callable:
"GenerativeModel.generate_content",
gemini_wrapper(name="google.generativeai.GenerativeModel.generate_content"),
),
SymbolPatcher(
lambda: importlib.import_module(
"google.generativeai.types.generation_types"
),
"GenerateContentResponse.from_response",
gemini_wrapper(
name="google.generativeai.types.generation_types.GenerateContentResponse.from_response"
),
),
SymbolPatcher(
lambda: importlib.import_module(
"google.generativeai.types.generation_types"
),
"GenerateContentResponse.from_iterator",
gemini_wrapper(
name="google.generativeai.types.generation_types.GenerateContentResponse.from_iterator"
),
),
SymbolPatcher(
lambda: importlib.import_module(
"google.ai.generativelanguage_v1beta.services.generative_service.client"
),
"GenerativeServiceClient.generate_content",
gemini_wrapper(
name="google.ai.generativelanguage_v1beta.services.generative_service.client.GenerativeServiceClient.generate_content"
),
),
]
)

0 comments on commit 6aaf227

Please sign in to comment.