Update handler.py
Browse files- handler.py +9 -1
handler.py
CHANGED
@@ -33,5 +33,13 @@ class EndpointHandler:
|
|
33 |
def __call__(self, data: Dist[str, Any]) -> Dict[str, Any]:
|
34 |
prompt = data.pop("inputs", data)
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
return result
|
|
|
33 |
def __call__(self, data: Dist[str, Any]) -> Dict[str, Any]:
|
34 |
prompt = data.pop("inputs", data)
|
35 |
|
36 |
+
system_message = """
|
37 |
+
You are an expert at analyzing the text of narrative scenes. Only respond with complete JSON responses beginning with [ and end with ]. Do not add new lines Separate the text of the scene to analyze into passages spoken aloud by a character from text not spoken aloud by a character. Identify the character speaking, and the tone being used. To help identify dialog, we have turned all quotation marks into the string SPOOOOOOKEN. For example the sentence SPOOOOOOKENHello, Janet,SPOOOOOOKEN John growled angrily. would result in the following output format: [{"position": 1, "type": "dialog", "narrator": "John", "tone": "angry", "content": "SPOOOOOOKENHello, Janet,SPOOOOOOKEN "}, {"position": 2, "type": "narration", "narrator": "Narrator", "tone": "", "content": "John growled angrily."}] If there is a new-line character, separate it as its own json object. Here is the scene to analyze:
|
38 |
+
""".strip()
|
39 |
+
|
40 |
+
messages = [
|
41 |
+
{"role": "system", "content": system_message},
|
42 |
+
{"role": "user", "content": prompt},
|
43 |
+
]
|
44 |
+
result = self.pipeline(messages, generation_config=self.generation_config)
|
45 |
return result
|