Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating PromptLayer request in PromptLayer Models to be async in agenerate #2058

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions langchain/chat_models/promptlayer_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def _agenerate(
self, messages: List[BaseMessage], stop: Optional[List[str]] = None
) -> ChatResult:
"""Call ChatOpenAI agenerate and then call PromptLayer to log."""
from promptlayer.utils import get_api_key, promptlayer_api_request
from promptlayer.utils import get_api_key, promptlayer_api_request_async

request_start_time = datetime.datetime.now().timestamp()
generated_responses = await super()._agenerate(messages, stop)
Expand All @@ -82,7 +82,7 @@ async def _agenerate(
response_dict, params = super()._create_message_dicts(
[generation.message], stop
)
pl_request_id = promptlayer_api_request(
pl_request_id = await promptlayer_api_request_async(
"langchain.PromptLayerChatOpenAI.async",
"langchain",
message_dicts,
Expand Down
8 changes: 4 additions & 4 deletions langchain/llms/promptlayer_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _generate(
async def _agenerate(
self, prompts: List[str], stop: Optional[List[str]] = None
) -> LLMResult:
from promptlayer.utils import get_api_key, promptlayer_api_request
from promptlayer.utils import get_api_key, promptlayer_api_request_async

request_start_time = datetime.datetime.now().timestamp()
generated_responses = await super()._agenerate(prompts, stop)
Expand All @@ -85,7 +85,7 @@ async def _agenerate(
"text": generation.text,
"llm_output": generated_responses.llm_output,
}
pl_request_id = promptlayer_api_request(
pl_request_id = await promptlayer_api_request_async(
"langchain.PromptLayerOpenAI.async",
"langchain",
[prompt],
Expand Down Expand Up @@ -171,7 +171,7 @@ def _generate(
async def _agenerate(
self, prompts: List[str], stop: Optional[List[str]] = None
) -> LLMResult:
from promptlayer.utils import get_api_key, promptlayer_api_request
from promptlayer.utils import get_api_key, promptlayer_api_request_async

request_start_time = datetime.datetime.now().timestamp()
generated_responses = await super()._agenerate(prompts, stop)
Expand All @@ -183,7 +183,7 @@ async def _agenerate(
"text": generation.text,
"llm_output": generated_responses.llm_output,
}
pl_request_id = promptlayer_api_request(
pl_request_id = await promptlayer_api_request_async(
"langchain.PromptLayerOpenAIChat.async",
"langchain",
[prompt],
Expand Down