neuralgeekroot commited on
Commit
7c3bb7a
·
1 Parent(s): cda8a27

Updated README.md file and app.py file. Fixed colorFrom and colorTo in README.md file

Browse files
Files changed (2) hide show
  1. README.md +2 -2
  2. app.py +9 -10
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: Blog Generation
3
  emoji: 🚀
4
- colorFrom: Green
5
- colorTo: Blue
6
  sdk: streamlit
7
  sdk_version: 1.42.0
8
  app_file: app.py
 
1
  ---
2
  title: Blog Generation
3
  emoji: 🚀
4
+ colorFrom: green
5
+ colorTo: blue
6
  sdk: streamlit
7
  sdk_version: 1.42.0
8
  app_file: app.py
app.py CHANGED
@@ -9,7 +9,7 @@ from typing import List, TypedDict, Annotated
9
  from langgraph.constants import Send
10
  import operator
11
  from langchain_core.messages import SystemMessage, HumanMessage
12
- from langsmith import
13
 
14
  # Load environment variables
15
  load_dotenv()
@@ -22,7 +22,6 @@ os.environ['LANGCHAIN_PROJECT_NAME'] = os.getenv('LANGCHAIN_PROJECT_NAME')
22
  llm = ChatGroq(model='llama3-70b-8192')
23
 
24
  # Define section structure
25
- @traceable
26
  class Section(BaseModel):
27
  section_name: str = Field(description="Section name")
28
  description: str = Field(description="Description of the section")
@@ -33,7 +32,6 @@ class Sections(BaseModel):
33
  structured_sections = llm.with_structured_output(Sections)
34
 
35
  # Define blog state
36
- @traceable
37
  class BlogState(TypedDict):
38
  topic: str
39
  outline: str
@@ -46,7 +44,6 @@ class BlogState(TypedDict):
46
  step: str
47
  final_blog: str
48
 
49
- @traceable
50
  class BlogStateSection(TypedDict):
51
  section: Section
52
  completed_sections: Annotated[list, operator.add]
@@ -169,15 +166,17 @@ def main():
169
  'send_seo_optimization': "",
170
  'revise_section_content': [],
171
  'finalize_blog': "",
172
- 'step': ""
 
173
  }
174
 
175
  # Invoke workflow
176
- result = workflow.invoke(initial_state)
177
-
178
- # Display final result
179
- st.subheader("Final Blog Content")
180
- st.write(result['final_blog'])
 
181
  else:
182
  st.error("Please enter a blog topic.")
183
 
 
9
  from langgraph.constants import Send
10
  import operator
11
  from langchain_core.messages import SystemMessage, HumanMessage
12
+ from langsmith import traceable
13
 
14
  # Load environment variables
15
  load_dotenv()
 
22
  llm = ChatGroq(model='llama3-70b-8192')
23
 
24
  # Define section structure
 
25
  class Section(BaseModel):
26
  section_name: str = Field(description="Section name")
27
  description: str = Field(description="Description of the section")
 
32
  structured_sections = llm.with_structured_output(Sections)
33
 
34
  # Define blog state
 
35
  class BlogState(TypedDict):
36
  topic: str
37
  outline: str
 
44
  step: str
45
  final_blog: str
46
 
 
47
  class BlogStateSection(TypedDict):
48
  section: Section
49
  completed_sections: Annotated[list, operator.add]
 
166
  'send_seo_optimization': "",
167
  'revise_section_content': [],
168
  'finalize_blog': "",
169
+ 'step': "",
170
+ 'final_blog': ""
171
  }
172
 
173
  # Invoke workflow
174
+ try:
175
+ result = workflow.invoke(initial_state)
176
+ st.subheader("Final Blog Content")
177
+ st.write(result['final_blog'])
178
+ except Exception as e:
179
+ st.error(f"An error occurred: {e}")
180
  else:
181
  st.error("Please enter a blog topic.")
182