mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-22 16:34:25 +01:00
Add hooks for chat completion
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from ast import List
|
|
||||||
|
|
||||||
import openai
|
import openai
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
@@ -76,6 +75,20 @@ def create_chat_completion(
|
|||||||
+ f"Creating chat completion with model {model}, temperature {temperature},"
|
+ f"Creating chat completion with model {model}, temperature {temperature},"
|
||||||
f" max_tokens {max_tokens}" + Fore.RESET
|
f" max_tokens {max_tokens}" + Fore.RESET
|
||||||
)
|
)
|
||||||
|
for plugin in CFG.plugins:
|
||||||
|
if plugin.can_handle_chat_completion(
|
||||||
|
messages=messages,
|
||||||
|
model=model,
|
||||||
|
temperature=temperature,
|
||||||
|
max_tokens=max_tokens,
|
||||||
|
):
|
||||||
|
response = plugin.handle_chat_completion(
|
||||||
|
messages=messages,
|
||||||
|
model=model,
|
||||||
|
temperature=temperature,
|
||||||
|
max_tokens=max_tokens,
|
||||||
|
)
|
||||||
|
return response
|
||||||
for attempt in range(num_retries):
|
for attempt in range(num_retries):
|
||||||
backoff = 2 ** (attempt + 2)
|
backoff = 2 ** (attempt + 2)
|
||||||
try:
|
try:
|
||||||
@@ -99,7 +112,7 @@ def create_chat_completion(
|
|||||||
if CFG.debug_mode:
|
if CFG.debug_mode:
|
||||||
print(
|
print(
|
||||||
Fore.RED + "Error: ",
|
Fore.RED + "Error: ",
|
||||||
f"Reached rate limit, passing..." + Fore.RESET,
|
"Reached rate limit, passing..." + Fore.RESET,
|
||||||
)
|
)
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
if e.http_status == 502:
|
if e.http_status == 502:
|
||||||
|
|||||||
Reference in New Issue
Block a user