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

Use agents in langchain example #21

Merged
merged 3 commits into from
Oct 27, 2023
Merged

Conversation

nicolewhite
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Oct 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
autoblocks-examples ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 27, 2023 0:26am

@review-agent-prime
Copy link

The changes in the PR are clear and well explained. However, there are a couple of things that could be improved:

  1. The images linked in the README files are not accessible. It seems like the path to the images is incorrect. Please make sure the images are available in the repository and the path is correct.

  2. The instructions for viewing the trace in Autoblocks are a bit verbose. It might be better to simplify them for better readability.

Here are the suggested changes:

In JavaScript/langchain/README.md and Python/langchain/README.md:

Replace:

Go to the [explore page](https://app.autoblocks.ai/explore). When you find the trace, switch to the Trace Tree view to
see a tree of all the spans in the trace.

The first span that is selected will show you the overall question and answer of the LangChain pipeline, but you can also
drill into individual spans by clicking on them to understand how LangChain is working under the hood.

With:

Visit the [explore page](https://app.autoblocks.ai/explore) and switch to the Trace Tree view to see the trace. The first selected span shows the overall LangChain pipeline's question and answer. Click on individual spans for more details.

And make sure the image links are correct:

![Trace Tree View](correct-path-to-image)

Please replace correct-path-to-image with the correct path to your image.
The changes in this PR mainly involve updating the versions of various dependencies in the package-lock.json and package.json files. Here are a few suggestions:

  1. Ensure that the updated versions of the dependencies are compatible with the existing codebase. This can be done by running the test suite and checking for any breaking changes in the updated packages.

  2. It's good practice to keep the package.json and package-lock.json files in sync. Make sure that any changes made to the package.json file are reflected in the package-lock.json file.

  3. Some dependencies have been added as optional in the package-lock.json file. Make sure these dependencies are indeed optional and the application can run smoothly without them.

  4. It's recommended to use fixed versions of the dependencies in the package.json file to avoid unexpected updates. You can do this by removing the caret (^) before the version number.

Here's a code suggestion for the package.json file:

"dependencies": {
  "@autoblocks/client": "0.0.15",
  "dotenv-cli": "7.3.0",
  "langchain": "0.0.173"
}

Remember to run npm install after making these changes to update the package-lock.json file.
The changes in the PR look good overall, but there are a few areas that could be improved:

  1. Error Handling: The run method in the executor object could potentially throw an error. It would be good to wrap this in a try-catch block to handle any potential errors that could occur during execution.
try {
  const output = await executor.run(
    "What is today's date? What is that date divided by 2?",
    { callbacks: [handler] }
  );
  console.log(`Output: ${output}`);
} catch (error) {
  console.error(`Error executing the model: ${error}`);
}
  1. Use of console.log: While console.log is fine for development, it's not ideal for production code. Consider using a logging library that can provide different levels of logging (info, debug, error, etc.) and can be configured to output to different locations (console, file, remote server, etc.).

  2. Magic Strings: The string "What is today's date? What is that date divided by 2?" is a magic string. It would be better to move this to a constant at the top of your file or even to a configuration file if it's something that might change.

const QUERY = "What is today's date? What is that date divided by 2?";
...
const output = await executor.run(QUERY, { callbacks: [handler] });
  1. Callbacks: It's not clear what the AutoblocksCallbackHandler does or why it's needed. If it's not necessary, consider removing it. If it is necessary, consider adding a comment explaining why.

  2. Unused Imports: The DynamicTool and Calculator imports are not used in the code. If they are not needed, consider removing them to clean up the code.
    The changes in the PR look good overall, but there are a few areas that could be improved:

  3. In the todays_date function, you are returning the day of the month, which might not be what users expect when they ask for "today's date". Consider returning the full date instead.

@tool
def todays_date(*args, **kwargs) -> str:
    """Returns today's date"""
    return datetime.now().strftime('%Y-%m-%d')
  1. The initialize_agent function is being called with tools and llm as positional arguments, but in the function definition, tools and llm are keyword arguments. To avoid confusion, consider specifying the arguments by their names.
agent = initialize_agent(
    tools=tools,
    llm=llm,
    agent_type=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
)
  1. The run method of agent is being called with a string that contains two questions. If these questions are meant to be processed separately, consider splitting them into separate calls.
output1 = agent.run("What is today's date?", callbacks=[handler])
output2 = agent.run(f"What is {output1} divided by 2?", callbacks=[handler])
  1. The print statement at the end of the script is missing a closing parenthesis. This will cause a syntax error.
print(f"Output: {output}")
print()
print("View your trace: https://app.autoblocks.ai/explore")

The changes in this PR seem to be mostly about updating package versions and adding a new package "numexpr". Here are a few suggestions:

  1. Ensure that the updated versions of the packages are compatible with the rest of the project. This includes not only direct compatibility, but also indirect compatibility through the project's dependencies.

  2. The new package "numexpr" has been added. Make sure that this package is actually needed in the project. Unnecessary dependencies can lead to larger build sizes and potential security risks.

  3. The python version for "numexpr" is specified as ">=3.9". Make sure that this is compatible with the python version used in the project.

  4. The content-hash has been updated. This is usually done automatically when the dependencies are updated, but it's a good idea to double-check that the new hash is correct.

  5. The "numpy" dependency for "numexpr" is specified as ">=1.13.3". Make sure that this version is compatible with the version of numpy used in the project.

  6. The python-versions for the project is specified as "^3.9". This means that the project is expected to work with Python 3.9 and any minor versions above that. Make sure that all the dependencies are compatible with these Python versions.

Please consider these points before merging the PR.
The changes in the PR look good overall. However, I would suggest keeping the dependencies in alphabetical order. This is not a hard rule, but it can make the file easier to read and maintain. Here's how you could rearrange them:

[tool.poetry.dependencies]
python = "^3.9"
autoblocksai = "^0.0.11"
langchain = "^0.0.323"
numexpr = "^2.8.7"
openai = "^0.28.1"
python-dotenv = "^1.0.0"

Also, please ensure that the new version of langchain (^0.0.323) and the added numexpr (^2.8.7) dependency do not introduce any breaking changes or conflicts with the existing codebase.

@nicolewhite nicolewhite merged commit ed3fa01 into main Oct 27, 2023
@nicolewhite nicolewhite deleted the use-agents-in-langchain-example branch October 27, 2023 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant