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

fix: async invokes langchain for agent executors #116

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions examples/langchain_toolcall.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from dotenv import load_dotenv

# Add OPENAI_API_KEY and TAVILY_API_KEY for this example.
load_dotenv()

model = ChatOpenAI(model="gpt-4o")
Expand Down Expand Up @@ -43,6 +44,7 @@

cb = lai_client.langchain_callback()

# Replace with ainvoke for asynchronous execution.
agent_executor.invoke(
{
"chat_history": [
Expand Down
3 changes: 3 additions & 0 deletions literalai/prompt_engineering/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ def format_messages(self, **kwargs: Any) -> List[BaseMessage]:

return rendered_messages

async def aformat_messages(self, **kwargs: Any) -> List[BaseMessage]:
return self.format_messages(**kwargs)

lc_messages = [(m["role"], m["content"]) for m in self.template_messages]

chat_template = CustomChatPromptTemplate.from_messages(lc_messages)
Expand Down
Loading