fix LangSmith project config error (#7996)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from langsmith import Client
|
||||
from langsmith.schemas import RunBase
|
||||
|
||||
from core.ops.base_trace_instance import BaseTraceInstance
|
||||
from core.ops.entities.config_entity import LangSmithConfig
|
||||
@@ -371,3 +373,24 @@ class LangSmithDataTrace(BaseTraceInstance):
|
||||
except Exception as e:
|
||||
logger.debug(f"LangSmith API check failed: {str(e)}")
|
||||
raise ValueError(f"LangSmith API check failed: {str(e)}")
|
||||
|
||||
def get_project_url(self):
|
||||
try:
|
||||
run_data = RunBase(
|
||||
id=uuid.uuid4(),
|
||||
name="tool",
|
||||
inputs={"input": "test"},
|
||||
outputs={"output": "test"},
|
||||
run_type=LangSmithRunType.tool,
|
||||
start_time=datetime.now(),
|
||||
)
|
||||
|
||||
project_url = self.langsmith_client.get_run_url(run=run_data,
|
||||
project_id=self.project_id,
|
||||
project_name=self.project_name)
|
||||
return project_url.split('/r/')[0]
|
||||
except Exception as e:
|
||||
logger.debug(f"LangSmith get run url failed: {str(e)}")
|
||||
raise ValueError(f"LangSmith get run url failed: {str(e)}")
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user