Spaces:
Sleeping
Sleeping
File size: 773 Bytes
b2171fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from src.api_clients import init_clients
def structure_conversation(raw_text):
_, anthropic_client, _ = init_clients()
formatter_prompt = (
"Convert this dialogue into a turn-by-turn transcript where each line "
"starts with 'HUMAN:' or 'AI:'. Do not add any other commentary.\n\n"
+ raw_text
)
try:
resp = anthropic_client.messages.create(
model="claude-3-5-sonnet-20241022",
system="You are a conversation formatter.",
messages=[{"role": "user", "content": formatter_prompt}],
max_tokens=1000,
temperature=0.0
)
return resp.content[0].text.strip()
except Exception as e:
raise Exception(f"Error in structuring conversation: {str(e)}") |