File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,25 @@ def run(self) -> None:
2222
2323 log_debug (f'Sending query: { self .query_string } ' )
2424
25- response = openai .Completion .create (
26- model = self .model ,
27- prompt = self .query_string ,
28- max_tokens = self .max_token_count ,
29- )
30- # Get the response text.
31- result : str = response .choices [0 ].text
25+ if self .model in ["gpt-3.5-turbo" ,"gpt-4" ,"gpt-4-32k" ]:
26+ response = openai .ChatCompletion .create (
27+ model = self .model ,
28+ messages = [{"role" :"user" ,"content" :self .query_string }],
29+ max_tokens = self .max_token_count ,
30+ )
31+ # Get the response text.
32+ result : str = response .choices [0 ].message .content
33+ else :
34+ response = openai .Completion .create (
35+ model = self .model ,
36+ prompt = self .query_string ,
37+ max_tokens = self .max_token_count ,
38+ )
39+ # Get the response text.
40+ result : str = response .choices [0 ].text
3241 # If there is a callback, do something with it.
3342 if self .callback :
3443 self .callback (result )
3544 # Otherwise, assume we just want to log it.
3645 else :
37- log_info (result )
46+ log_info (result )
You can’t perform that action at this time.
0 commit comments