Spaces:
Sleeping
Sleeping
Download src/conversation.py from BrainDrive/Therapy-Model-Evaluator: direct link, hf CLI and curl.
- Browser
- Download file 773 Bytes
-
https://huggingface.co/spaces/BrainDrive/Therapy-Model-Evaluator/resolve/main/src/conversation.py
- Command line
-
hf download hf://spaces/BrainDrive/Therapy-Model-Evaluator/src/conversation.py
-
curl -L -o conversation.py https://huggingface.co/spaces/BrainDrive/Therapy-Model-Evaluator/resolve/main/src/conversation.py
773 Bytes
| 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)}") |