Skip to content

Commit 45bbddd

Browse files
committed
fix example and type hints
1 parent 30043bc commit 45bbddd

File tree

4 files changed

+91
-100
lines changed

4 files changed

+91
-100
lines changed

dialog2graph/pipelines/d2g_llm/three_stages_llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from langchain.output_parsers import PydanticOutputParser, OutputFixingParser
1515
from langchain.schema import HumanMessage
1616
from langchain_openai import ChatOpenAI
17-
from langchain_community.embeddings import HuggingFaceEmbeddings
17+
from langchain_huggingface.embeddings import HuggingFaceEmbeddings
1818

1919

2020
from dialog2graph import metrics

dialog2graph/pipelines/model_storage.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import yaml
66
import re
77
import dotenv
8-
from pydantic._internal._model_construction import ModelMetaclass
9-
from typing import Union, Dict
8+
from typing import Union, Dict, Type
109
from pathlib import Path
1110
from pydantic import BaseModel, Field, model_validator
1211

13-
from langchain_community.chat_models import ChatOpenAI
12+
from langchain_openai.chat_models import ChatOpenAI
1413
from langchain_core.language_models import BaseChatModel
15-
from langchain_community.embeddings import HuggingFaceEmbeddings
14+
from langchain_huggingface.embeddings import HuggingFaceEmbeddings
1615

1716
from dialog2graph.utils.logger import Logger
1817

@@ -62,7 +61,7 @@ class StoredData(BaseModel):
6261
Attributes:
6362
key (str): Key for the stored model.
6463
config (dict): Configuration for the stored model.
65-
model_type (Union[Literal["llm"], Literal["emb"]]): Type of the stored model, either "llm" (language model) or "emb" (embedding model).
64+
model_type (Type[BaseChatModel | HuggingFaceEmbeddings]): Type of the stored model, for example ChatOpenAI, HuggingFaceEmbeddings.
6665
model (Union[HuggingFaceEmbeddings, BaseChatModel]): The actual model object, which can either be a HuggingFaceEmbeddings instance or a BaseChatModel instance.
6766
6867
Methods:
@@ -76,7 +75,7 @@ class StoredData(BaseModel):
7675

7776
key: str = Field(description="Key for the stored model")
7877
config: dict = Field(description="Configuration for the stored model")
79-
model_type: ModelMetaclass = Field(description="Type of the stored model")
78+
model_type: Type[BaseChatModel | HuggingFaceEmbeddings] = Field(description="Type of the stored model")
8079
model: Union[
8180
HuggingFaceEmbeddings,
8281
BaseChatModel,
@@ -140,7 +139,7 @@ def add(
140139
self,
141140
key: str,
142141
config: dict,
143-
model_type: ModelMetaclass,
142+
model_type: Type[BaseChatModel | HuggingFaceEmbeddings],
144143
overwright: bool = False,
145144
):
146145
"""
@@ -155,7 +154,7 @@ def add(
155154
Args:
156155
key (str): The unique identifier for the model configuration.
157156
config (dict): The configuration dictionary for initializing the model.
158-
model_type (ModelMetaclass): The type name of the model to be added.
157+
model_type (Type[BaseChatModel | HuggingFaceEmbeddings]): The type of the model to be added.
159158
overwright (bool): Whether to overwright model existing under same key
160159
.
161160
Raises:
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
d2g_llm_filling_llm:v1:
1+
my_filling_model:
22
config:
3-
name: o3-mini
4-
temperature: 1
5-
model_type: llm
6-
d2g_llm_grouping_llm:v1:
3+
model_name: gpt-3.5-turbo
4+
model_type: ChatOpenAI
5+
three_stages_llm_formatting_llm:v1:
76
config:
8-
name: gpt-4o-latest
7+
model_name: gpt-4o-mini
98
temperature: 0
10-
model_type: llm
11-
d2g_llm_sim_model:v1:
9+
model_type: ChatOpenAI
10+
three_stages_llm_grouping_llm:v1:
11+
config:
12+
model_name: chatgpt-4o-latest
13+
temperature: 0
14+
model_type: ChatOpenAI
15+
three_stages_llm_sim_model:v1:
1216
config:
1317
model_kwargs:
1418
device: cpu
15-
model_name: cointegrated/LaBSE-en-ru
16-
model_type: emb
17-
my_model:
18-
config:
19-
name: gpt-3.5-turbo
20-
model_type: llm
19+
model_name: BAAI/bge-m3
20+
model_type: HuggingFaceEmbeddings

examples/pipeline_usage/pipeline_example.ipynb

Lines changed: 69 additions & 77 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)