-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
|
||
tutorial15/main.py | ||
tutorial57/main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from langchain_openai import ChatOpenAI | ||
import streamlit as st | ||
from langchain.prompts import ChatPromptTemplate | ||
from langchain.chains import LLMChain | ||
from streamlit_mermaid import st_mermaid | ||
|
||
def main(): | ||
st.title("MERMAID DIAGRAM APP") | ||
st.write("create diagram from any details") | ||
qsn=st.text_area("ask your question here") | ||
ts=""" | ||
Your job is to write the code to generate a colorful mermaid diagram | ||
describing the below | ||
{steps} information only , dont use any other information. | ||
only generate the code as output nothing extra. | ||
each line in the code must be terminated by ; | ||
Code: | ||
""" | ||
pt=ChatPromptTemplate.from_template(ts) | ||
llm=ChatOpenAI(model="gpt-4-turbo",temperature=0.0) | ||
qa_chain=LLMChain(llm=llm,prompt=pt) | ||
if qsn is not None: | ||
btn=st.button("submit") | ||
if btn: | ||
response=qa_chain.invoke({"steps":qsn}) | ||
data=response["text"] | ||
data=data.replace("`","") | ||
data=data.replace("mermaid","") | ||
st_mermaid(data,key="flow",height="600px") | ||
st.text(data) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
Your job is to write the code to generate a colorful mermaid diagram | ||
describing the below | ||
{steps} information only , dont use any other information. | ||
only generate the code as output nothing extra. | ||
each line in the code must be terminated by ; | ||
Code: | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
```mermaid | ||
graph TD; | ||
a-->b; | ||
b-->c; | ||
c-->a; | ||
``` |
Binary file not shown.