Skip to content

Commit

Permalink
Merge pull request #928 from parea-ai/PAI-1132-on-sdk-pass-root-id-fo…
Browse files Browse the repository at this point in the history
…r-update-to-mange-invalidate

add root_trace_id to update
  • Loading branch information
jalexanderII committed Jun 7, 2024
2 parents 36636ae + 7721dcc commit 03a4d51
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions parea/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
ListExperimentUUIDsFilters,
ProjectSchema,
TestCaseCollection,
TraceLog,
TraceLogFilters,
TraceLogTree,
UseDeployedPrompt,
UseDeployedPromptResponse,
)
from parea.utils.trace_utils import get_current_trace_id, get_root_trace_id, logger_all_possible, logger_record_log, trace_data
from parea.utils.trace_utils import get_current_trace_id, get_root_trace_id, logger_all_possible, trace_data

load_dotenv()


logger = logging.getLogger()

COMPLETION_ENDPOINT = "/completion"
Expand Down
2 changes: 1 addition & 1 deletion parea/cookbook/guidance/tracing_guidance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from dotenv import load_dotenv
from guidance import assistant, gen, models, select, user
from guidance import assistant, gen, models, user

from parea import Parea, trace

Expand Down
1 change: 0 additions & 1 deletion parea/cookbook/langchain/trace_langchain_RAG_evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
from langchain.text_splitter import TokenTextSplitter
from langchain.vectorstores import Chroma
from langchain_community.llms.bedrock import Bedrock
from langchain_community.vectorstores.faiss import FAISS

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import os

from dotenv import load_dotenv
Expand Down
3 changes: 1 addition & 2 deletions parea/evals/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
from openai import __version__ as openai_version

from parea.parea_logger import parea_logger
from parea.schemas import EvaluationResult, Log
from parea.schemas import EvaluationResult
from parea.schemas.log import Log
from parea.schemas.models import UpdateLog
from parea.utils.trace_utils import thread_ids_running_evals, trace_data

seg = pysbd.Segmenter(language="en", clean=False)
Expand Down
5 changes: 2 additions & 3 deletions parea/experiment/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import argparse
import csv
import importlib
import os
import sys
import traceback
Expand All @@ -18,8 +17,8 @@ def load_from_path(module_path):
sys.path.insert(0, dir_name)

module_name = os.path.basename(module_path)
spec = importlib.util.spec_from_file_location(module_name, module_path)
module = importlib.util.module_from_spec(spec)
spec = util.spec_from_file_location(module_name, module_path)
module = util.module_from_spec(spec)
spec.loader.exec_module(module)

if spec.name not in sys.modules:
Expand Down
3 changes: 0 additions & 3 deletions parea/parea_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ async def arecord_log(self, data: TraceLog) -> None:
data=asdict(data),
)

def write_log(self, data: TraceLog) -> None:
data = serialize_metadata_values(data)

def default_log(self, data: TraceLog) -> None:
if self._client:
if data.target:
Expand Down
1 change: 1 addition & 0 deletions parea/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class CacheRequest:
class UpdateLog:
trace_id: str
field_name_to_value_map: Dict[str, Any]
root_trace_id: Optional[str] = None


@define
Expand Down
3 changes: 2 additions & 1 deletion parea/utils/trace_integrations/instructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def __call__(
instructor_val_errs.set(instructor_val_errs.get() + reasons)

report_instructor_validation_errors()
logger_update_record(UpdateLog(trace_id=trace_id, field_name_to_value_map={"scores": trace_data.get()[trace_id].scores}))
current_log = trace_data.get()[trace_id]
logger_update_record(UpdateLog(trace_id=trace_id, field_name_to_value_map={"scores": current_log.scores}, root_trace_id=current_log.root_trace_id))

raise e

Expand Down
2 changes: 1 addition & 1 deletion parea/wrapper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from parea.constants import ALL_NON_AZURE_MODELS_INFO, AZURE_MODEL_INFO
from parea.parea_logger import parea_logger
from parea.schemas.log import LLMInputs, Message, ModelParams, Role
from parea.schemas.models import UpdateLog, UpdateTraceScenario
from parea.schemas.models import UpdateTraceScenario
from parea.utils.trace_utils import fill_trace_data, get_current_trace_id, log_in_thread, trace_data, trace_insert
from parea.utils.universal_encoder import json_dumps

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "parea-ai"
packages = [{ include = "parea" }]
version = "0.2.170"
version = "0.2.171"
description = "Parea python sdk"
readme = "README.md"
authors = ["joel-parea-ai <[email protected]>"]
Expand Down

0 comments on commit 03a4d51

Please sign in to comment.