Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
joschkabraun committed Sep 8, 2023
1 parent 498bf12 commit 2315d9c
Showing 1 changed file with 51 additions and 39 deletions.
90 changes: 51 additions & 39 deletions parea/cookbook/tracing_with_open_ai_endpoint_directly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2315d9c

Please sign in to comment.