@@ -33,7 +33,8 @@ def print_red(self, text: str, end: str = "\n"):
33
33
34
34
def inspect_history (self , n : int = 1 , skip : int = 0 ):
35
35
"""Prints the last n prompts and their completions.
36
- TODO: print the valid choice that contains filled output field instead of the first
36
+
37
+ TODO: print the valid choice that contains filled output field instead of the first.
37
38
"""
38
39
provider : str = self .provider
39
40
@@ -45,23 +46,15 @@ def inspect_history(self, n: int = 1, skip: int = 0):
45
46
prompt = x ["prompt" ]
46
47
47
48
if prompt != last_prompt :
48
-
49
- if provider == "clarifai" or provider == "google" or provider == "claude" :
50
- printed .append (
51
- (
52
- prompt ,
53
- x ['response' ],
54
- ),
55
- )
49
+ if provider == "clarifai" or provider == "google" :
50
+ printed .append ((prompt , x ["response" ]))
51
+ elif provider == "anthropic" :
52
+ blocks = [{"text" : block .text } for block in x ["response" ].content if block .type == "text" ]
53
+ printed .append ((prompt , blocks ))
54
+ elif provider == "cohere" :
55
+ printed .append ((prompt , x ["response" ].generations ))
56
56
else :
57
- printed .append (
58
- (
59
- prompt ,
60
- x ["response" ].generations
61
- if provider == "cohere"
62
- else x ["response" ]["choices" ],
63
- ),
64
- )
57
+ printed .append ((prompt , x ["response" ]["choices" ]))
65
58
66
59
last_prompt = prompt
67
60
@@ -79,9 +72,9 @@ def inspect_history(self, n: int = 1, skip: int = 0):
79
72
if provider == "cohere" :
80
73
text = choices [0 ].text
81
74
elif provider == "openai" or provider == "ollama" :
82
- text = ' ' + self ._get_choice_text (choices [0 ]).strip ()
83
- elif provider == "clarifai" or provider == "claude" :
84
- text = choices
75
+ text = " " + self ._get_choice_text (choices [0 ]).strip ()
76
+ elif provider == "clarifai" :
77
+ text = choices
85
78
elif provider == "google" :
86
79
text = choices [0 ].parts [0 ].text
87
80
else :
@@ -99,6 +92,6 @@ def __call__(self, prompt, only_completed=True, return_sorted=False, **kwargs):
99
92
def copy (self , ** kwargs ):
100
93
"""Returns a copy of the language model with the same parameters."""
101
94
kwargs = {** self .kwargs , ** kwargs }
102
- model = kwargs .pop (' model' )
95
+ model = kwargs .pop (" model" )
103
96
104
97
return self .__class__ (model = model , ** kwargs )
0 commit comments