chansung commited on
Commit
05ddd47
1 Parent(s): 8ad8cb4

Update palmapi.py

Browse files
Files changed (1) hide show
  1. palmapi.py +22 -11
palmapi.py CHANGED
@@ -25,17 +25,28 @@ class PaLMChatPromptFmt(PromptFmt):
25
  @classmethod
26
  def prompt(cls, pingpong, truncate_size):
27
  ping = pingpong.ping[:truncate_size]
28
- pong = "" if pingpong.pong is None else pingpong.pong[:truncate_size]
29
- return [
30
- {
31
- "author": "USER",
32
- "content": ping
33
- },
34
- {
35
- "author": "AI",
36
- "content": pong
37
- },
38
- ]
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  class PaLMChatPPManager(PPManager):
41
  def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=PaLMChatPromptFmt, truncate_size: int=None):
 
25
  @classmethod
26
  def prompt(cls, pingpong, truncate_size):
27
  ping = pingpong.ping[:truncate_size]
28
+ pong = pingpong.pong
29
+
30
+ if pong is None:
31
+ return [
32
+ {
33
+ "author": "USER",
34
+ "content": ping
35
+ },
36
+ ]
37
+ else:
38
+ pong = pong[:truncate_size]
39
+
40
+ return [
41
+ {
42
+ "author": "USER",
43
+ "content": ping
44
+ },
45
+ {
46
+ "author": "AI",
47
+ "content": pong
48
+ },
49
+ ]
50
 
51
  class PaLMChatPPManager(PPManager):
52
  def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=PaLMChatPromptFmt, truncate_size: int=None):