88from dotenv import load_dotenv
99
1010from parea import Parea , get_current_trace_id , trace
11- from parea .schemas import Completion , CompletionResponse , FeedbackRequest
11+ from parea .schemas import Completion , CompletionResponse , LLMInputs , Message , Role
1212
1313load_dotenv ()
1414
1818def deployed_argument_generator (query : str , additional_description : str = "" ) -> str :
1919 return p .completion (
2020 Completion (
21- deployment_id = "p-RG8d9rfJc_0cctwfpb_n6 " ,
21+ deployment_id = "p-XOh3kp8B0nIE82WgioPnr " ,
2222 llm_inputs = {
2323 "additional_description" : additional_description ,
2424 "date" : f"{ datetime .now ()} " ,
2525 "query" : query ,
2626 },
27+ llm_configuration = LLMInputs (history = [Message (role = Role .user , content = "Some history" )]),
2728 )
2829 ).content
2930
3031
3132def deployed_critic (argument : str ) -> str :
3233 return p .completion (
3334 Completion (
34- deployment_id = "p-fXgZytT3dJjXD_71TDR4s " ,
35+ deployment_id = "p-PSOwRyIPaQRq4xQW3MbpV " ,
3536 llm_inputs = {"argument" : argument },
37+ llm_configuration = LLMInputs (history = [Message (role = Role .user , content = "Some history" )]),
3638 )
3739 ).content
3840
3941
4042def deployed_refiner (query : str , additional_description : str , current_arg : str , criticism : str ) -> str :
4143 return p .completion (
4244 Completion (
43- deployment_id = "p--G2s9okMTvBEh3d8YqLY2 " ,
45+ deployment_id = "p-bJ3-UKh9-ixapZafaRBsj " ,
4446 llm_inputs = {
4547 "additional_description" : additional_description ,
4648 "date" : f"{ datetime .now ()} " ,
4749 "query" : query ,
4850 "argument" : current_arg ,
4951 "criticism" : criticism ,
5052 },
53+ llm_configuration = LLMInputs (history = [Message (role = Role .user , content = "Some history" )]),
5154 )
5255 ).content
5356
5457
5558def deployed_refiner2 (query : str , additional_description : str , current_arg : str , criticism : str ) -> CompletionResponse :
5659 return p .completion (
5760 Completion (
58- deployment_id = "p--G2s9okMTvBEh3d8YqLY2 " ,
61+ deployment_id = "p-bJ3-UKh9-ixapZafaRBsj " ,
5962 llm_inputs = {
6063 "additional_description" : additional_description ,
6164 "date" : f"{ datetime .now ()} " ,
6265 "query" : query ,
6366 "argument" : current_arg ,
6467 "criticism" : criticism ,
6568 },
69+ llm_configuration = LLMInputs (history = [Message (role = Role .user , content = "Some history" )]),
6670 )
6771 )
6872
6973
70- # @trace
71- # def deployed_argument_chain(query: str, additional_description: str = "") -> str:
72- # argument = deployed_argument_generator(query, additional_description)
73- # criticism = deployed_critic(argument)
74- # return deployed_refiner(query, additional_description, argument, criticism)
74+ @trace
75+ def deployed_argument_chain (query : str , additional_description : str = "" ) -> str :
76+ argument = deployed_argument_generator (query , additional_description )
77+ criticism = deployed_critic (argument )
78+ return deployed_refiner (query , additional_description , argument , criticism )
7579
7680
7781@trace (
@@ -86,21 +90,21 @@ def deployed_argument_chain_tags_metadata(query: str, additional_description: st
8690
8791
8892if __name__ == "__main__" :
89- # result1 = deployed_argument_chain(
90- # "Whether coffee is good for you.",
91- # additional_description="Provide a concise, few sentence argument on why coffee is good for you.",
92- # )
93- # print(result1)
93+ result1 = deployed_argument_chain (
94+ "Whether coffee is good for you." ,
95+ additional_description = "Provide a concise, few sentence argument on why coffee is good for you." ,
96+ )
97+ print (result1 )
9498
9599 result2 , trace_id = deployed_argument_chain_tags_metadata (
96100 "Whether coffee is good for you." ,
97101 additional_description = "Provide a concise, few sentence argument on why coffee is good for you." ,
98102 )
99103 print (json .dumps (asdict (result2 ), indent = 2 ))
100- p .record_feedback (
101- FeedbackRequest (
102- trace_id = trace_id ,
103- score = 0.7 , # 0.0 (bad) to 1.0 (good)
104- target = "Coffee is wonderful. End of story." ,
105- )
106- )
104+ # p.record_feedback(
105+ # FeedbackRequest(
106+ # trace_id=trace_id,
107+ # score=0.7, # 0.0 (bad) to 1.0 (good)
108+ # target="Coffee is wonderful. End of story.",
109+ # )
110+ # )
0 commit comments