diff --git a/cookbook/parea_llm_proxy/deployments/tracing_with_deployed_prompt.py b/cookbook/parea_llm_proxy/deployments/tracing_with_deployed_prompt.py index ca61924e..9156765a 100644 --- a/cookbook/parea_llm_proxy/deployments/tracing_with_deployed_prompt.py +++ b/cookbook/parea_llm_proxy/deployments/tracing_with_deployed_prompt.py @@ -8,7 +8,7 @@ from dotenv import load_dotenv from parea import Parea, get_current_trace_id, trace -from parea.schemas import Completion, CompletionResponse, FeedbackRequest +from parea.schemas import Completion, CompletionResponse, LLMInputs, Message, Role load_dotenv() @@ -18,12 +18,13 @@ def deployed_argument_generator(query: str, additional_description: str = "") -> str: return p.completion( Completion( - deployment_id="p-RG8d9rfJc_0cctwfpb_n6", + deployment_id="p-XOh3kp8B0nIE82WgioPnr", llm_inputs={ "additional_description": additional_description, "date": f"{datetime.now()}", "query": query, }, + llm_configuration=LLMInputs(history=[Message(role=Role.user, content="Some history")]), ) ).content @@ -31,8 +32,9 @@ def deployed_argument_generator(query: str, additional_description: str = "") -> def deployed_critic(argument: str) -> str: return p.completion( Completion( - deployment_id="p-fXgZytT3dJjXD_71TDR4s", + deployment_id="p-PSOwRyIPaQRq4xQW3MbpV", llm_inputs={"argument": argument}, + llm_configuration=LLMInputs(history=[Message(role=Role.user, content="Some history")]), ) ).content @@ -40,7 +42,7 @@ def deployed_critic(argument: str) -> str: def deployed_refiner(query: str, additional_description: str, current_arg: str, criticism: str) -> str: return p.completion( Completion( - deployment_id="p--G2s9okMTvBEh3d8YqLY2", + deployment_id="p-bJ3-UKh9-ixapZafaRBsj", llm_inputs={ "additional_description": additional_description, "date": f"{datetime.now()}", @@ -48,6 +50,7 @@ def deployed_refiner(query: str, additional_description: str, current_arg: str, "argument": current_arg, "criticism": criticism, }, + llm_configuration=LLMInputs(history=[Message(role=Role.user, content="Some history")]), ) ).content @@ -55,7 +58,7 @@ def deployed_refiner(query: str, additional_description: str, current_arg: str, def deployed_refiner2(query: str, additional_description: str, current_arg: str, criticism: str) -> CompletionResponse: return p.completion( Completion( - deployment_id="p--G2s9okMTvBEh3d8YqLY2", + deployment_id="p-bJ3-UKh9-ixapZafaRBsj", llm_inputs={ "additional_description": additional_description, "date": f"{datetime.now()}", @@ -63,15 +66,16 @@ def deployed_refiner2(query: str, additional_description: str, current_arg: str, "argument": current_arg, "criticism": criticism, }, + llm_configuration=LLMInputs(history=[Message(role=Role.user, content="Some history")]), ) ) -# @trace -# def deployed_argument_chain(query: str, additional_description: str = "") -> str: -# argument = deployed_argument_generator(query, additional_description) -# criticism = deployed_critic(argument) -# return deployed_refiner(query, additional_description, argument, criticism) +@trace +def deployed_argument_chain(query: str, additional_description: str = "") -> str: + argument = deployed_argument_generator(query, additional_description) + criticism = deployed_critic(argument) + return deployed_refiner(query, additional_description, argument, criticism) @trace( @@ -86,21 +90,21 @@ def deployed_argument_chain_tags_metadata(query: str, additional_description: st if __name__ == "__main__": - # result1 = deployed_argument_chain( - # "Whether coffee is good for you.", - # additional_description="Provide a concise, few sentence argument on why coffee is good for you.", - # ) - # print(result1) + result1 = deployed_argument_chain( + "Whether coffee is good for you.", + additional_description="Provide a concise, few sentence argument on why coffee is good for you.", + ) + print(result1) result2, trace_id = deployed_argument_chain_tags_metadata( "Whether coffee is good for you.", additional_description="Provide a concise, few sentence argument on why coffee is good for you.", ) print(json.dumps(asdict(result2), indent=2)) - p.record_feedback( - FeedbackRequest( - trace_id=trace_id, - score=0.7, # 0.0 (bad) to 1.0 (good) - target="Coffee is wonderful. End of story.", - ) - ) + # p.record_feedback( + # FeedbackRequest( + # trace_id=trace_id, + # score=0.7, # 0.0 (bad) to 1.0 (good) + # target="Coffee is wonderful. End of story.", + # ) + # ) diff --git a/cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py b/cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py index 9191cfcc..1673bffc 100644 --- a/cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py +++ b/cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py @@ -6,7 +6,7 @@ from dotenv import load_dotenv from parea import Parea, get_current_trace_id, trace -from parea.schemas import Completion, CompletionResponse, FeedbackRequest, LLMInputs, Message, ModelParams +from parea.schemas import Completion, CompletionResponse, FeedbackRequest, LLMInputs, Message, ModelParams, Role load_dotenv() @@ -21,9 +21,7 @@ def call_llm( return p.completion( data=Completion( llm_configuration=LLMInputs( - model=model, - model_params=ModelParams(temp=temperature), - messages=[Message(**d) for d in data], + model=model, model_params=ModelParams(temp=temperature), messages=[Message(**d) for d in data], history=[Message(role=Role.user, content="Some history")] ) ) ) diff --git a/parea/schemas/log.py b/parea/schemas/log.py index 34e19aaf..6a4a7050 100644 --- a/parea/schemas/log.py +++ b/parea/schemas/log.py @@ -50,6 +50,7 @@ class LLMInputs: provider: Optional[str] = None model_params: Optional[ModelParams] = ModelParams() messages: Optional[List[Message]] = None + history: Optional[List[Message]] = None functions: Optional[List[Any]] = None function_call: Optional[Union[str, Dict[str, str]]] = None diff --git a/pyproject.toml b/pyproject.toml index b1a260ef..ae48a881 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "parea-ai" packages = [{ include = "parea" }] -version = "0.2.188" +version = "0.2.189" description = "Parea python sdk" readme = "README.md" authors = ["joel-parea-ai "]