lifeofcoding commited on
Commit
7ae55b3
·
verified ·
1 Parent(s): 71bab53

Update handler.py

Browse files
Files changed (1) hide show
  1. 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
- result = self.pipeline(prompt, generation_config=self.generation_config)
 
 
 
 
 
 
 
 
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