diff --git a/parea/cookbook/tracing_with_open_ai_endpoint_directly.py b/parea/cookbook/tracing_with_open_ai_endpoint_directly.py index 16bd903c..77c8ed8c 100644 --- a/parea/cookbook/tracing_with_open_ai_endpoint_directly.py +++ b/parea/cookbook/tracing_with_open_ai_endpoint_directly.py @@ -17,51 +17,63 @@ @trace def argument_chain(query: str, additional_description: str = "") -> str: - argument = openai.ChatCompletion.create( - model="gpt-3.5-turbo-0613", - temperature=0.0, - messages=[ - { - "role": "system", - "content": f"""You are a debater making an argument on a topic. {additional_description}. + argument = ( + openai.ChatCompletion.create( + model="gpt-3.5-turbo-0613", + temperature=0.0, + messages=[ + { + "role": "system", + "content": f"""You are a debater making an argument on a topic. {additional_description}. The current time is {datetime.now()}""", - }, - {"role": "user", "content": f"The discussion topic is {query}"}, - ], - ).choices[0].message["content"] + }, + {"role": "user", "content": f"The discussion topic is {query}"}, + ], + ) + .choices[0] + .message["content"] + ) - criticism = openai.ChatCompletion.create( - model="gpt-3.5-turbo-0613", - temperature=0.0, - messages=[ - { - "role": "system", - "content": f"""You are a critic. + criticism = ( + openai.ChatCompletion.create( + model="gpt-3.5-turbo-0613", + temperature=0.0, + messages=[ + { + "role": "system", + "content": f"""You are a critic. What unresolved questions or criticism do you have after reading the following argument? Provide a concise summary of your feedback.""", - }, - {"role": "user", "content": argument}, - ], - ).choices[0].message["content"] + }, + {"role": "user", "content": argument}, + ], + ) + .choices[0] + .message["content"] + ) - refined_argument = openai.ChatCompletion.create( - model="gpt-3.5-turbo-0613", - temperature=0.0, - messages=[ - { - "role": "system", - "content": f"""You are a debater making an argument on a topic. {additional_description}. + refined_argument = ( + openai.ChatCompletion.create( + model="gpt-3.5-turbo-0613", + temperature=0.0, + messages=[ + { + "role": "system", + "content": f"""You are a debater making an argument on a topic. {additional_description}. The current time is {datetime.now()}""", - }, - {"role": "user", "content": f"""The discussion topic is {query}"""}, - {"role": "assistant", "content": argument}, - {"role": "user", "content": criticism}, - { - "role": "system", - "content": f"Please generate a new argument that incorporates the feedback from the user.", - }, - ], - ).choices[0].message["content"] + }, + {"role": "user", "content": f"""The discussion topic is {query}"""}, + {"role": "assistant", "content": argument}, + {"role": "user", "content": criticism}, + { + "role": "system", + "content": f"Please generate a new argument that incorporates the feedback from the user.", + }, + ], + ) + .choices[0] + .message["content"] + ) return refined_argument