Skip to content
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
2 changes: 1 addition & 1 deletion dialog2graph/pipelines/d2g_llm/three_stages_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from langchain.output_parsers import PydanticOutputParser, OutputFixingParser
from langchain.schema import HumanMessage
from langchain_openai import ChatOpenAI
from langchain_community.embeddings import HuggingFaceEmbeddings
from langchain_huggingface.embeddings import HuggingFaceEmbeddings


from dialog2graph import metrics
Expand Down
2 changes: 1 addition & 1 deletion dialog2graph/pipelines/helpers/parse_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

logger = Logger(__name__)

RawDialogsType = dict | list[list] | list[dict] | Dialog | list[Dialog] | PosixPath
RawDialogsType = dict | list[list] | list[dict] | list[list[dict]] | Dialog | list[Dialog] | PosixPath
ValidatedDialogType = (
List[DialogMessage] | List[List[DialogMessage]] | Dialog | List[Dialog]
)
Expand Down
15 changes: 7 additions & 8 deletions dialog2graph/pipelines/model_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import yaml
import re
import dotenv
from pydantic._internal._model_construction import ModelMetaclass
from typing import Union, Dict
from typing import Union, Dict, Type
from pathlib import Path
from pydantic import BaseModel, Field, model_validator

from langchain_community.chat_models import ChatOpenAI
from langchain_openai.chat_models import ChatOpenAI
from langchain_core.language_models import BaseChatModel
from langchain_community.embeddings import HuggingFaceEmbeddings
from langchain_huggingface.embeddings import HuggingFaceEmbeddings

from dialog2graph.utils.logger import Logger

Expand Down Expand Up @@ -62,7 +61,7 @@ class StoredData(BaseModel):
Attributes:
key (str): Key for the stored model.
config (dict): Configuration for the stored model.
model_type (Union[Literal["llm"], Literal["emb"]]): Type of the stored model, either "llm" (language model) or "emb" (embedding model).
model_type (Type[BaseChatModel | HuggingFaceEmbeddings]): Type of the stored model, for example ChatOpenAI, HuggingFaceEmbeddings.
model (Union[HuggingFaceEmbeddings, BaseChatModel]): The actual model object, which can either be a HuggingFaceEmbeddings instance or a BaseChatModel instance.

Methods:
Expand All @@ -76,7 +75,7 @@ class StoredData(BaseModel):

key: str = Field(description="Key for the stored model")
config: dict = Field(description="Configuration for the stored model")
model_type: ModelMetaclass = Field(description="Type of the stored model")
model_type: Type[BaseChatModel | HuggingFaceEmbeddings] = Field(description="Type of the stored model")
model: Union[
HuggingFaceEmbeddings,
BaseChatModel,
Expand Down Expand Up @@ -140,7 +139,7 @@ def add(
self,
key: str,
config: dict,
model_type: ModelMetaclass,
model_type: Type[BaseChatModel | HuggingFaceEmbeddings],
overwright: bool = False,
):
"""
Expand All @@ -155,7 +154,7 @@ def add(
Args:
key (str): The unique identifier for the model configuration.
config (dict): The configuration dictionary for initializing the model.
model_type (ModelMetaclass): The type name of the model to be added.
model_type (Type[BaseChatModel | HuggingFaceEmbeddings]): The type of the model to be added.
overwright (bool): Whether to overwright model existing under same key
.
Raises:
Expand Down
28 changes: 14 additions & 14 deletions examples/pipeline_usage/models_config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
d2g_llm_filling_llm:v1:
my_filling_model:
config:
name: o3-mini
temperature: 1
model_type: llm
d2g_llm_grouping_llm:v1:
model_name: gpt-3.5-turbo
model_type: ChatOpenAI
three_stages_llm_formatting_llm:v1:
config:
name: gpt-4o-latest
model_name: gpt-4o-mini
temperature: 0
model_type: llm
d2g_llm_sim_model:v1:
model_type: ChatOpenAI
three_stages_llm_grouping_llm:v1:
config:
model_name: chatgpt-4o-latest
temperature: 0
model_type: ChatOpenAI
three_stages_llm_sim_model:v1:
config:
model_kwargs:
device: cpu
model_name: cointegrated/LaBSE-en-ru
model_type: emb
my_model:
config:
name: gpt-3.5-turbo
model_type: llm
model_name: BAAI/bge-m3
model_type: HuggingFaceEmbeddings
240 changes: 240 additions & 0 deletions examples/pipeline_usage/multiple_dialogs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
[
[
{
"text": "Hello! How can I assist you with your calendar today?",
"participant": "assistant"
},
{
"text": "I'm having trouble with my calendar not syncing properly.",
"participant": "user"
},
{
"text": "I'm sorry to hear you're experiencing a sync delay. Can you tell me more about the issue?",
"participant": "assistant"
},
{
"text": "Yes, I checked but it still doesn't sync.",
"participant": "user"
},
{
"text": "Could you verify that the time zone settings are properly configured on your devices?",
"participant": "assistant"
},
{
"text": "Alright, please guide me through the steps.",
"participant": "user"
},
{
"text": "Sure, let me guide you through adjusting your time zone settings.",
"participant": "assistant"
},
{
"text": "I want to change the time zone instead.",
"participant": "user"
},
{
"text": "Of course! Which device would you like to adjust the time zone settings on?",
"participant": "assistant"
},
{
"text": "Sure, let's adjust the time zone settings.",
"participant": "user"
},
{
"text": "Sure, let me guide you through adjusting your time zone settings.",
"participant": "assistant"
},
{
"text": "I've followed the steps and it seems to be working now.",
"participant": "user"
},
{
"text": "Great! Is your calendar syncing correctly now?",
"participant": "assistant"
},
{
"text": "Actually, it's still not syncing. I want to try something else.",
"participant": "user"
},
{
"text": "I'm sorry we couldn't resolve the issue. If you need further assistance, feel free to reach out anytime. Have a great day!",
"participant": "assistant"
}
],
[
{
"text": "Hello! How can I assist you with your calendar today?",
"participant": "assistant"
},
{
"text": "I'm having trouble with my calendar not syncing properly.",
"participant": "user"
},
{
"text": "I'm sorry to hear you're experiencing a sync delay. Can you tell me more about the issue?",
"participant": "assistant"
},
{
"text": "Yes, I checked but it still doesn't sync.",
"participant": "user"
},
{
"text": "Have you checked if your time zone settings are correct on all your devices?",
"participant": "assistant"
},
{
"text": "Alright, please guide me through the steps.",
"participant": "user"
},
{
"text": "Sure, let me guide you through adjusting your time zone settings.",
"participant": "assistant"
},
{
"text": "I want to change the time zone instead.",
"participant": "user"
},
{
"text": "Of course! Which device would you like to adjust the time zone settings on?",
"participant": "assistant"
},
{
"text": "Sure, let's adjust the time zone settings.",
"participant": "user"
},
{
"text": "Sure, let me guide you through adjusting your time zone settings.",
"participant": "assistant"
},
{
"text": "I've followed the steps and it seems to be working now.",
"participant": "user"
},
{
"text": "Great! Is your calendar syncing correctly now?",
"participant": "assistant"
},
{
"text": "Actually, it's still not syncing. I want to try something else.",
"participant": "user"
},
{
"text": "I'm sorry we couldn't resolve the issue. If you need further assistance, feel free to reach out anytime. Have a great day!",
"participant": "assistant"
}
],
[
{
"text": "Hello! How can I assist you with your calendar today?",
"participant": "assistant"
},
{
"text": "I'm having trouble with my calendar not syncing properly.",
"participant": "user"
},
{
"text": "I'm sorry to hear you're experiencing a sync delay. Can you tell me more about the issue?",
"participant": "assistant"
},
{
"text": "Yes, I checked but it still doesn't sync.",
"participant": "user"
},
{
"text": "Could you verify that the time zone settings are properly configured on your devices?",
"participant": "assistant"
},
{
"text": "Time zone settings are correct, but the issue persists.",
"participant": "user"
},
{
"text": "If time zone settings are correct, we can try refreshing the calendar app or reinstalling it.",
"participant": "assistant"
},
{
"text": "After adjusting, it still doesn't sync.",
"participant": "user"
},
{
"text": "Great! Is your calendar syncing correctly now?",
"participant": "assistant"
},
{
"text": "Actually, it's still not syncing. I want to try something else.",
"participant": "user"
},
{
"text": "I'm sorry we couldn't resolve the issue. If you need further assistance, feel free to reach out anytime. Have a great day!",
"participant": "assistant"
}
],
[
{
"text": "Hello! How can I assist you with your calendar today?",
"participant": "assistant"
},
{
"text": "I'm having trouble with my calendar not syncing properly.",
"participant": "user"
},
{
"text": "I'm sorry to hear you're experiencing a sync delay. Can you tell me more about the issue?",
"participant": "assistant"
},
{
"text": "Yes, I checked but it still doesn't sync.",
"participant": "user"
},
{
"text": "Have you checked if your time zone settings are correct on all your devices?",
"participant": "assistant"
},
{
"text": "Time zone settings are correct, but the issue persists.",
"participant": "user"
},
{
"text": "If time zone settings are correct, we can try refreshing the calendar app or reinstalling it.",
"participant": "assistant"
},
{
"text": "After adjusting, it still doesn't sync.",
"participant": "user"
},
{
"text": "Great! Is your calendar syncing correctly now?",
"participant": "assistant"
},
{
"text": "Actually, it's still not syncing. I want to try something else.",
"participant": "user"
},
{
"text": "I'm sorry we couldn't resolve the issue. If you need further assistance, feel free to reach out anytime. Have a great day!",
"participant": "assistant"
}
],
[
{
"text": "Hello! How can I assist you with your calendar today?",
"participant": "assistant"
},
{
"text": "I'm having trouble with my calendar not syncing properly.",
"participant": "user"
},
{
"text": "I'm sorry to hear you're experiencing a sync delay. Can you tell me more about the issue?",
"participant": "assistant"
},
{
"text": "I think I'll handle it later. Thanks anyway.",
"participant": "user"
},
{
"text": "I'm sorry we couldn't resolve the issue. If you need further assistance, feel free to reach out anytime. Have a great day!",
"participant": "assistant"
}
]
]
Loading
Loading