fix: count down thread in completion db not commit (#1267)

This commit is contained in:
takatost
2023-10-02 10:19:26 +08:00
committed by GitHub
parent 86a9dea428
commit 41d4c5b424
3 changed files with 21 additions and 27 deletions

View File

@@ -106,13 +106,7 @@ class OpenAIModel(BaseLLM):
raise ModelCurrentlyNotSupportError("Dify Hosted OpenAI GPT-4 currently not support.")
prompts = self._get_prompt_from_messages(messages)
try:
return self._client.generate([prompts], stop, callbacks)
finally:
thread_context = api_requestor._thread_context
if hasattr(thread_context, "session") and thread_context.session:
thread_context.session.close()
return self._client.generate([prompts], stop, callbacks)
def get_num_tokens(self, messages: List[PromptMessage]) -> int:
"""