Skip to content

Commit

Permalink
tutorial61
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed May 11, 2024
1 parent 20934ae commit 512382a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

tutorial15/main.py
tutorial57/main.py
34 changes: 34 additions & 0 deletions tutorial61/main.py
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()
8 changes: 8 additions & 0 deletions tutorial61/prompt.txt
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:
"""
6 changes: 6 additions & 0 deletions tutorial61/test.md
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 added tutorial61/tutorial61.pptx
Binary file not shown.

0 comments on commit 512382a

Please sign in to comment.