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

fixed gemma_hf #33

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions libs/vertexai/langchain_google_vertexai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from langchain_google_vertexai.chat_models import ChatVertexAI
from langchain_google_vertexai.functions_utils import PydanticFunctionsOutputParser
from langchain_google_vertexai.gemma import (
GemmaChatLocalHF,
GemmaChatLocalKaggle,
GemmaChatVertexAIModelGarden,
GemmaLocalHF,
Expand All @@ -12,6 +13,13 @@
from langchain_google_vertexai.llms import VertexAI
from langchain_google_vertexai.model_garden import VertexAIModelGarden
from langchain_google_vertexai.vectorstores.vectorstores import VectorSearchVectorStore
from langchain_google_vertexai.vision_models import (
VertexAIImageCaptioning,
VertexAIImageCaptioningChat,
VertexAIImageEditorChat,
VertexAIImageGeneratorChat,
VertexAIVisualQnAChat,
)

__all__ = [
"ChatVertexAI",
Expand All @@ -29,4 +37,9 @@
"PydanticFunctionsOutputParser",
"create_structured_runnable",
"VectorSearchVectorStore",
"VertexAIImageCaptioning",
"VertexAIImageCaptioningChat",
"VertexAIImageEditorChat",
"VertexAIImageGeneratorChat",
"VertexAIVisualQnAChat",
]
4 changes: 2 additions & 2 deletions libs/vertexai/langchain_google_vertexai/gemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def _generate(
"""Run the LLM on the given prompt and input."""
params = {"max_length": self.max_tokens} if self.max_tokens else {}
results = self.client.generate(prompts, **params)
results = results if isinstance(results, str) else [results]
results = [results] if isinstance(results, str) else results
if stop:
results = [enforce_stop_tokens(text, stop) for text in results]
return LLMResult(generations=[[Generation(text=result)] for result in results])
Expand Down Expand Up @@ -268,7 +268,7 @@ def _default_params(self) -> Dict[str, Any]:
params = {"max_length": self.max_tokens}
return {k: v for k, v in params.items() if v is not None}

def _run(self, prompt: str, kwargs: Any) -> str:
def _run(self, prompt: str, **kwargs: Any) -> str:
inputs = self.tokenizer(prompt, return_tensors="pt")
generate_ids = self.client.generate(inputs.input_ids, **kwargs)
return self.tokenizer.batch_decode(
Expand Down
2 changes: 1 addition & 1 deletion libs/vertexai/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langchain-google-vertexai"
version = "0.0.6"
version = "0.0.7"
description = "An integration package connecting GoogleVertexAI and LangChain"
authors = []
readme = "README.md"
Expand Down
5 changes: 5 additions & 0 deletions libs/vertexai/tests/unit_tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"PydanticFunctionsOutputParser",
"create_structured_runnable",
"VectorSearchVectorStore",
"VertexAIImageCaptioning",
"VertexAIImageCaptioningChat",
"VertexAIImageEditorChat",
"VertexAIImageGeneratorChat",
"VertexAIVisualQnAChat",
]


Expand Down
Loading