Untitled
unknown
plain_text
13 days ago
1.5 kB
2
Indexable
Never
class ConversationAnalyzer: def __init__(self): self.model = ChatGroq(model_name="mixtral-8x7b-32768", api_key="gsk_8KtQlmrXFwwLw8mz63") self.prompt = ChatPromptTemplate.from_messages([ ("system", """You are an expert at analyzing conversations. Your task is to determine whether a given snippet could be part of a natural conversation. Follow these guidelines: 1. Single sentences: Always give a high score (0.8-1.0) to snippets containing only one sentence, regardless of language. 2. Repeated sentences in the same language: Give a high score (0.8-1.0) if the snippet contains the same sentence repeated twice in the same language. This simulates a conversation where one person repeats what was said. 3. Same sentence in two different languages: Assign a high score (0.8-1.0) if the snippet contains the same sentence in two different languages. This simulates a conversation with an interpreter or translator. 4. For other cases, evaluate based on coherence, context, and naturalness of the conversation. Provide a score between 0 (not at all part of a natural conversation) and 1 (very likely to be part of a natural conversation), and explain your reasoning thoroughly."""), ("human", """Analyze the following text: {text} Respond with: 1. A score between 0 and 1. 2. A detailed explanation of your reasoning, referencing the specific guidelines provided.""") ]) self.chain = self.prompt | self.model | StrOutputParser()
Leave a Comment