Phoenix21 commited on
Commit
d71a43c
·
verified ·
1 Parent(s): 9431669

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +17 -15
pipeline.py CHANGED
@@ -77,11 +77,13 @@ logger = logging.getLogger(__name__)
77
  from langchain_core.tracers import LangChainTracer
78
  from langsmith import Client
79
 
80
- os.environ["LANGCHAIN_TRACING"] = "true"
 
81
  os.environ["LANGSMITH_ENDPOINT"]="https://api.smith.langchain.com"
82
- langsmith_client = Client()
83
- os.environ["LANGSMITH_PROJECT"]="Healthy_ai_expert"
84
- tracer = LangChainTracer(project_name=os.environ.get("LANGCHAIN_PROJECT", "healthy_ai_expert"))
 
85
 
86
 
87
 
@@ -592,17 +594,17 @@ def is_ethical_conflict(query: str) -> bool:
592
  # Main Pipeline
593
  # -------------------------------------------------------
594
  def run_with_chain(query: str) -> str:
595
- """
596
- Overall flow:
597
- 1) Validate & rate-limit
598
- 2) Mistral moderation =>
599
- - If self-harm => self_harm_chain
600
- - If hate => refusal
601
- - If violence/dangerous => we STILL produce a guided response (ethics) unless it's extreme
602
- 3) If not refused, check if query is aggression/ethical => route to chain
603
- 4) Otherwise classify => brand/wellness/out-of-scope => RAG => tailor
604
- """
605
- # with tracer.new_trace(name="wellness_pipeline_run") as run:
606
  start_time = time.time()
607
  try:
608
  # 1) Validate
 
77
  from langchain_core.tracers import LangChainTracer
78
  from langsmith import Client
79
 
80
+
81
+ os.environ["LANGCHAIN_TRACING_V2"]="true"
82
  os.environ["LANGSMITH_ENDPOINT"]="https://api.smith.langchain.com"
83
+ # langsmith_client = Client()
84
+ os.environ["LANGCHAIN_API_KEY"]=os.getenv("LANGCHAIN_API_KEY")
85
+ os.environ["LANGCHAIN_PROJECT"]=os.getenv("LANGCHAIN_PROJECT")
86
+ # tracer = LangChainTracer(project_name=os.environ.get("LANGCHAIN_PROJECT", "healthy_ai_expert"))
87
 
88
 
89
 
 
594
  # Main Pipeline
595
  # -------------------------------------------------------
596
  def run_with_chain(query: str) -> str:
597
+ """
598
+ Overall flow:
599
+ 1) Validate & rate-limit
600
+ 2) Mistral moderation =>
601
+ - If self-harm => self_harm_chain
602
+ - If hate => refusal
603
+ - If violence/dangerous => we STILL produce a guided response (ethics) unless it's extreme
604
+ 3) If not refused, check if query is aggression/ethical => route to chain
605
+ 4) Otherwise classify => brand/wellness/out-of-scope => RAG => tailor
606
+ """
607
+ # with tracer.new_trace(name="wellness_pipeline_run") as run:
608
  start_time = time.time()
609
  try:
610
  # 1) Validate