Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Add support for Async OpenAI
Browse files Browse the repository at this point in the history
  • Loading branch information
patcher9 committed Mar 8, 2024
1 parent d0a4fda commit 273b0ab
Show file tree
Hide file tree
Showing 2 changed files with 469 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/dokumetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"""

from .openai import init as init_openai
from .async_openai import init as init_async_openai
from .anthropic import init as init_anthropic
from .cohere import init as init_cohere
from openai import AsyncOpenAI, OpenAI

# pylint: disable=too-few-public-methods
class DokuConfig:
Expand Down Expand Up @@ -41,8 +43,11 @@ def init(llm, doku_url, api_key, environment="default", application_name="defaul
DokuConfig.skip_resp = skip_resp

# pylint: disable=no-else-return, line-too-long
if hasattr(llm.chat, 'completions') and callable(llm.chat.completions.create) and ('.openai.azure.com/' not in str(llm.base_url)):
init_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
if hasattr(llm, 'chat') and callable(llm.chat.completions.create) and ('.openai.azure.com/' not in str(llm.base_url)):
if isinstance(llm, OpenAI):
init_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
elif isinstance(llm, AsyncOpenAI):
init_async_openai(llm, doku_url, api_key, environment, application_name, skip_resp)
return
# pylint: disable=no-else-return
elif hasattr(llm, 'generate') and callable(llm.generate):
Expand Down
Loading

0 comments on commit 273b0ab

Please sign in to comment.