Merge pull request #183 from VinciGit00/182-googlegenerativeaiembeddings-is-not-defined

fixed gemini embeddings
This commit is contained in:
Marco Perini 2024-05-09 15:30:55 +02:00 committed by GitHub
commit 7e00c1497e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 3373 additions and 6 deletions

3346
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,16 +4,16 @@ AbstractGraph Module
from abc import ABC, abstractmethod
from typing import Optional
from langchain_openai import AzureOpenAIEmbeddings, OpenAIEmbeddings
from langchain_community.embeddings import HuggingFaceHubEmbeddings, OllamaEmbeddings
from langchain_community.embeddings import HuggingFaceHubEmbeddings, OllamaEmbeddings, BedrockEmbeddings
from langchain_google_genai import GoogleGenerativeAIEmbeddings
from ..helpers import models_tokens
from ..models import AzureOpenAI, Bedrock, Gemini, Groq, HuggingFace, Ollama, OpenAI, Anthropic
from ..models import AzureOpenAI, Bedrock, Gemini, Groq, HuggingFace, Ollama, OpenAI, Anthropic, Claude
class AbstractGraph(ABC):
"""
Scaffolding class for creating a graph representation and executing it.
Attributes:
prompt (str): The prompt for the graph.
source (str): The source of the graph.
config (dict): Configuration parameters for the graph.
@ -162,7 +162,7 @@ class AbstractGraph(ABC):
try:
self.model_token = models_tokens["ollama"][llm_params["model"]]
except KeyError as exc:
raise KeyError("Model not supported") from exc
self.model_token = 8192
else:
self.model_token = 8192
except AttributeError:

View File

@ -110,4 +110,4 @@ class ScriptCreatorGraph(AbstractGraph):
inputs = {"user_prompt": self.prompt, self.input_key: self.source}
self.final_state, self.execution_info = self.graph.execute(inputs)
return self.final_state.get("answer", "No answer found.")
return self.final_state.get("answer", "No answer found ")

View File

@ -39,7 +39,8 @@ models_tokens = {
"dolphin-mixtral": 32000,
"mistral-openorca": 32000,
"stablelm-zephyr": 8192,
"nomic-embed-text": 8192
"nomic-embed-text": 8192,
"mxbai-embed-large'": 8192
},
"groq": {
"llama3-8b-8192": 8192,

View File

@ -12,3 +12,4 @@ from .hugging_face import HuggingFace
from .groq import Groq
from .bedrock import Bedrock
from .anthropic import Anthropic
from .claude import Claude

View File

@ -0,0 +1,19 @@
"""
Claude model
"""
from langchain_anthropic import ChatAnthropic
class Claude(ChatAnthropic):
"""Class for wrapping bedrock module"""
def __init__(self, llm_config: dict):
"""
A wrapper for the Claude class that provides default configuration
and could be extended with additional methods if needed.
Args:
llm_config (dict): Configuration parameters for the language model.
"""
# Initialize the superclass (ChatAnthropic) with provided config parameters
super().__init__(**llm_config)