Skip to content

Add Sample Research Assistant App built with AutoGen #196 #509

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

Closed
wants to merge 0 commits into from

Conversation

victordibia
Copy link
Collaborator

Why are these changes needed?

This PR provides an example of a research assistant web application (React) built with AutoGen.

Related issue number

#196

Checks

@victordibia victordibia requested review from pcdeadeasy, afourney and gagb and removed request for pcdeadeasy October 31, 2023 21:30
@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2023

Codecov Report

Merging #509 (899b432) into main (503c243) will decrease coverage by 0.84%.
Report is 1 commits behind head on main.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #509      +/-   ##
==========================================
- Coverage   42.59%   41.75%   -0.84%     
==========================================
  Files          21       21              
  Lines        2592     2632      +40     
  Branches      581      592      +11     
==========================================
- Hits         1104     1099       -5     
- Misses       1398     1442      +44     
- Partials       90       91       +1     
Flag Coverage Δ
unittests 41.75% <ø> (-0.77%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 2 files with indirect coverage changes

Copy link
Member

@afourney afourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this earlier, and it looks good to me.
I agree with the plan to separate the front-end generated artifacts from this PR.

Also, if you plan to use bing search, set the `BING_API_KEY`

```bash
export OAI_CONFIG_LIST=/path/to/OAI_CONFIG_LIST
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample app should use config instructions that are consistent with the rest of autogen repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify what consistency issues you see?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure:

AutoGen:

Set OAI_CONFIG_LIST env to the content of the json with models etc
or
Ensure there is a file called OAI_CONFIG_LIST in the file_location

RA:

Set OAI_CONFIG_LIST env to the path of the json
Even when I set the path to ~/OAI_CONFIG_LIST the code failed with "No api key error". That file exists on my machine.

If the current way is better, AutoGen repo should change the instructions?

Copy link
Member

@afourney afourney Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh. I think that documentation is wrong. That's what was confusing me.

There is no condition where it should be set to the file path. ..It would never work. It only works when set to the file contents.

The Readme in the backend folder is correct, while the Readme in the root is incorrect. The correct Readme states:

Create a file called `OAI_CONFIG_LIST` in `backend` with the following (JSON) format.
AutoGen can read this file and use it to initialize the OpenAI API.

@@ -0,0 +1,5 @@

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is present in the repo but never referenced in the readme. Delete or refer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run_server.sh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely do not delete that file. It greatly simplifies getting the environment set up. Better to document it I guess.

"title": "Coder Only",
"description": "A two agent workflow with a coder and an assistant",
},
# {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these lines commented out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we only demonstrate the Coder workflow.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, but the code contains files for the planner workflow? Commented lines without any context can cause confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gagb, the planner code never got tested. This code is a sample and as is. We could add a comment saying this code demonstrate a planner workflow.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either more testing + uncomment or no testing + more clarifying documentation is okay with me. Both reduce confusion.

@@ -0,0 +1,50 @@
## FastAPI Backend for AutoGen Research Assistant
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is inconsistency and overlap between the README in root of the app and the backend/ folder.

allow_headers=["*"],
)

root_file_path = os.path.dirname(os.path.abspath(__file__))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global variables in python should be capitalized. Refactor.

files_static_root = os.path.join(root_file_path, "files/")
static_folder_root = os.path.join(root_file_path, "ui")

os.makedirs(files_static_root, exist_ok=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add documentation for these statements.



# Example usage:
path_to_config_list = "./OAI_CONFIG_LIST"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with instructions in the README. Uses a hardcoded path.


# Example usage:
path_to_config_list = "./OAI_CONFIG_LIST"
resulting_config = create_llm_config(path_to_config_list)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a global variable, capitalize and define on the top. Is it even being used?

ra_type=ra_type,
silent=False,
# agent_on_receive=pretty_print_agent_message,
path_to_config_list="./OAI_CONFIG_LIST",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded path. Inconsistent with instructions in the README.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a quirk of autogen's config_list_from_json. It actually doesn't matter what this file path is. If there's an environment variable, Autogen will use it.

Copy link
Collaborator

@gagb gagb Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your argument. README asks to set a env variable but the code instead is using a hard coded path. This will confuse users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I mean we can remove this probably. My point was that if there's an OAI_CONFIG_LIST in os.environ, it won't even look at the filesystem. Having it in the environment supersedes everything else, so this is likely superfluous.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is another reason consistency with AutoGen repo is important.

@gagb
Copy link
Collaborator

gagb commented Nov 1, 2023

Per the AutoGen contributing guidelines we need to add test cases. https://microsoft.github.io/autogen/docs/Contribute

@@ -0,0 +1,88 @@
# ARA - AutoGen Research Assistant

ARA is an Autogen-powered AI research assistant that can converse with you to help you conduct research, write and execute code, run saved skills, learn new skills by demonstration, and adapt in response to your interactions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify that this is a prototype


ARA is an Autogen-powered AI research assistant that can converse with you to help you conduct research, write and execute code, run saved skills, learn new skills by demonstration, and adapt in response to your interactions.

Project Structure:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use markdown syntax


To update the web ui, navigate to the frontend directory, make changes and rebuild the ui.

## Capabilities
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlight how to switch agent workflow. Add example of how to add a new workflow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have not tested the code paths when we switch the workflow. So we probably don’t want to highlight that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be? @samershi what do you think?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What other agent workflows do we have built-in at the moment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not have any others. The planner agent is commented out, and very untested. The Group Chat agent is in another branch, and... needs work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samershi, IMO that workflow testing will block the PR. We can add it as an issue for the future iterations of the RA?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just remove all mention of the Planner workflow... comments and otherwise. It's not tested. We abandoned it quickly back in September. Having it here adds work on testing something we already opted not to use. We can add in the ability to switch workflows in a later PR, when we add GroupChat.


```bash
cd backend
uvicorn main:app --reload --port 8000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clarify the usage of --reload


config_list = autogen.config_list_from_json(path_to_config_list)
llm_config = {
# "request_timeout": 600,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because OpenAI v0.2 does not have this parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay the comment should clarify that.

import ast
from datetime import datetime

from autogen.code_utils import extract_code
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name of this file overlaps with autogen.code_utils which is confusing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe even the code is an overlap since I might have seen a comment somewhere that parts of it were borrowed from AutoGen. That said, the codes exists in completely different modules and shouldn't be an issue?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a sample app we should follow best principles and reduce redundant code. Naming conflict did create confusion for me. But I agree that it does not affect functionality.

import autogen # Assuming you have the autogen module imported or installed
from autogen import oai
from typing import Dict, List, Optional, Tuple, Union

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add documentation for what kind of utils this file contains

import utils.utils
from utils import generate_oai_reply, copy_utils

from enum import Enum
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In built python modules should be imported before external/project modules?

@gagb
Copy link
Collaborator

gagb commented Nov 3, 2023

@victordibia and @pcdeadeasy, I have too much on my plate until Wednesday to push commits to this PR beyond reviewing it but lmk (here) if any of my review comments aren't clear or don't make sense.

jackgerrits pushed a commit that referenced this pull request Oct 2, 2024
* added litellm+ollama cookbook

* fix annotations

* fix type

* fix for ruff

* fix for ruff

* resolve comments

* add to index.rst

* reverting index.rst

* fix to ignore type

---------

Co-authored-by: prankur <[email protected]>
Co-authored-by: Eric Zhu <[email protected]>
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.

6 participants