pritmanvar-bacancy commited on
Commit
423cbd4
ยท
verified ยท
1 Parent(s): c83b674

Update agents.py

Browse files
Files changed (1) hide show
  1. agents.py +10 -12
agents.py CHANGED
@@ -11,10 +11,17 @@ from langchain_core.prompts import PromptTemplate
11
 
12
  load_dotenv()
13
 
14
- langfuse_handler = CallbackHandler(
15
  secret_key=os.getenv("LANGFUSE_SECRET_KEY"),
16
  public_key=os.getenv("LANGFUSE_PUBLIC_KEY"),
17
  host="https://cloud.langfuse.com", # ๐Ÿ‡ช๐Ÿ‡บ EU region
 
 
 
 
 
 
 
18
  )
19
  langfuse = Langfuse()
20
 
@@ -41,11 +48,7 @@ def basic_analysis(news):
41
  try:
42
  response = analysis_llm.invoke(
43
  prompt.compile(news_object = news),
44
- config={"callbacks": [langfuse_handler],
45
- "metadata": {
46
- "langfuse_session_id": "news_analysis",
47
- },
48
- }
49
  )
50
  print("################ BASIC ANALYSIS AGENT RESPONSE ################")
51
  print(response.content)
@@ -88,12 +91,7 @@ def get_text_post_content(details, reference):
88
 
89
 
90
  user_query = prompt.compile(NEWS_CONTENT = details, CHAR_LENGTH = 490- len(reference))
91
- response = post_content_llm.invoke(user_query,
92
- config={"callbacks": [langfuse_handler],
93
- "metadata": {
94
- "langfuse_session_id": "post_content_generation",
95
- },
96
- })
97
 
98
  print("POST CONTENT RESPONSE:", response)
99
 
 
11
 
12
  load_dotenv()
13
 
14
+ langfuse_news_analysis_handler = CallbackHandler(
15
  secret_key=os.getenv("LANGFUSE_SECRET_KEY"),
16
  public_key=os.getenv("LANGFUSE_PUBLIC_KEY"),
17
  host="https://cloud.langfuse.com", # ๐Ÿ‡ช๐Ÿ‡บ EU region
18
+ session_id="news_analysis",
19
+ )
20
+ langfuse_post_generation_handler = CallbackHandler(
21
+ secret_key=os.getenv("LANGFUSE_SECRET_KEY"),
22
+ public_key=os.getenv("LANGFUSE_PUBLIC_KEY"),
23
+ host="https://cloud.langfuse.com", # ๐Ÿ‡ช๐Ÿ‡บ EU region
24
+ session_id="post_generation",
25
  )
26
  langfuse = Langfuse()
27
 
 
48
  try:
49
  response = analysis_llm.invoke(
50
  prompt.compile(news_object = news),
51
+ config={"callbacks": [langfuse_news_analysis_handler]}
 
 
 
 
52
  )
53
  print("################ BASIC ANALYSIS AGENT RESPONSE ################")
54
  print(response.content)
 
91
 
92
 
93
  user_query = prompt.compile(NEWS_CONTENT = details, CHAR_LENGTH = 490- len(reference))
94
+ response = post_content_llm.invoke(user_query, config={"callbacks": [langfuse_post_generation_handler]})
 
 
 
 
 
95
 
96
  print("POST CONTENT RESPONSE:", response)
97