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

Pipeline rendering does not work properly #8348

Closed
anakin87 opened this issue Sep 10, 2024 · 3 comments · Fixed by #8349
Closed

Pipeline rendering does not work properly #8348

anakin87 opened this issue Sep 10, 2024 · 3 comments · Fixed by #8349
Assignees
Labels
type:bug Something isn't working
Milestone

Comments

@anakin87
Copy link
Member

Describe the bug
New versions of Mermaid and mermaid.ink have been released.
This broke our Pipeline rendering. Also, we cannot pin an older version of Mermaid, since we are using an external service.

My impression is that the Mermaid code we are producing is not compatible with the new version (see code below).

To Reproduce

from haystack import Pipeline
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
from haystack.components.generators import OpenAIGenerator
from haystack.components.builders.prompt_builder import PromptBuilder

prompt_template = """
Given these documents, answer the question.
Documents:
{% for doc in documents %}
    {{ doc.content }}
{% endfor %}
Question: {{question}}
Answer:
"""

retriever = InMemoryBM25Retriever(document_store=InMemoryDocumentStore())
prompt_builder = PromptBuilder(template=prompt_template)
llm = OpenAIGenerator()

rag_pipeline = Pipeline()
rag_pipeline.add_component("retriever", retriever)
rag_pipeline.add_component("prompt_builder", prompt_builder)
rag_pipeline.add_component("llm", llm)
rag_pipeline.connect("retriever", "prompt_builder.documents")
rag_pipeline.connect("prompt_builder", "llm")

rag_pipeline.draw("pipeline.png")

Rendering
image

Mermaid code

%%{ init: {'theme': 'neutral' } }%%

graph TD;

retriever["<b>retriever</b><br><small><i>InMemoryBM25Retriever<br><br>Optional inputs:<ul style='text-align:left;'><li>filters (Optional[Dict[str, Any]])</li><li>top_k (Optional[int])</li><li>scale_score (Optional[bool])</li></ul></i></small>"]:::component -. "documents -> documents (opt.)<br><small><i>List[Document]</i></small>" .-> prompt_builder["<b>prompt_builder</b><br><small><i>PromptBuilder<br><br>Optional inputs:<ul style='text-align:left;'><li>template (Optional[str])</li><li>template_variables (Optional[Dict[str, Any]])</li><li>question (Any)</li></ul></i></small>"]:::component
prompt_builder["<b>prompt_builder</b><br><small><i>PromptBuilder<br><br>Optional inputs:<ul style='text-align:left;'><li>template (Optional[str])</li><li>template_variables (Optional[Dict[str, Any]])</li><li>question (Any)</li></ul></i></small>"]:::component -- "prompt -> prompt<br><small><i>str</i></small>" --> llm["<b>llm</b><br><small><i>OpenAIGenerator<br><br>Optional inputs:<ul style='text-align:left;'><li>streaming_callback (Optional[Callable[]])</li><li>generation_kwargs (Optional[Dict[str, Any]])</li></ul></i></small>"]:::component
i{*} -- "query<br><small><i>str</i></small>" --> retriever["<b>retriever</b><br><small><i>InMemoryBM25Retriever<br><br>Optional inputs:<ul style='text-align:left;'><li>filters (Optional[Dict[str, Any]])</li><li>top_k (Optional[int])</li><li>scale_score (Optional[bool])</li></ul></i></small>"]:::component
llm["<b>llm</b><br><small><i>OpenAIGenerator<br><br>Optional inputs:<ul style='text-align:left;'><li>streaming_callback (Optional[Callable[]])</li><li>generation_kwargs (Optional[Dict[str, Any]])</li></ul></i></small>"]:::component -- "replies<br><small><i>List[str]</i></small>"--> o{*}
llm["<b>llm</b><br><small><i>OpenAIGenerator<br><br>Optional inputs:<ul style='text-align:left;'><li>streaming_callback (Optional[Callable[]])</li><li>generation_kwargs (Optional[Dict[str, Any]])</li></ul></i></small>"]:::component -- "meta<br><small><i>List[Dict[str, Any]]</i></small>"--> o{*}

classDef component text-align:center;
@anakin87 anakin87 added the type:bug Something isn't working label Sep 10, 2024
@anakin87
Copy link
Member Author

I discovered that the issue is simply related to the asterisk (*) character, which is unsupported in Mermaid markdown.

@TuanaCelik
Copy link
Contributor

Thabks @anakin87 i also just noticed this today.

Unfortunately this bug will persist in older versions of Haystack including the DLAI course I think correct?

@silvanocerza silvanocerza added this to the 2.5.1 milestone Sep 10, 2024
@anakin87
Copy link
Member Author

@TuanaCelik you are right.
If this is a problem, we can see if it makes sense/it is safe to update DLAI to 2.5.1 or otherwise release a 2.2.5 version with this fix and update DLAI to that.
Or otherwise do nothing.

@anakin87 anakin87 self-assigned this Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants