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

AI generated complex instructions. #21

Open
ngaut opened this issue Jul 3, 2023 · 1 comment
Open

AI generated complex instructions. #21

ngaut opened this issue Jul 3, 2023 · 1 comment

Comments

@ngaut
Copy link
Owner

ngaut commented Jul 3, 2023

python main.py --continuous --timeout 3 --config=./config.yaml --startseq=0 --verbose
Welcome to Jarvis, your personal assistant for everyday tasks!

2023-07-04 04:53:29,027 - INFO - [planner.py:92] - Loaded plan: {'goal': 'To provide a concise summary of the top three stories currently displayed on the homepage of the official Hacker News website, including their titles, sources, and additional information such as the number of upvotes and comments for each story.', 'clarification': 'You would like to retrieve the top three stories from the official Hacker News website, extract relevant details such as the titles, sources, number of upvotes, and comments for each story, and provide a concise summary of these details.', 'main_task_objective': 'To retrieve and extract the necessary information from the Hacker News website, and generate a concise summary of the top three stories.', 'task_list': [{'task_num': 1, 'task': 'Conduct a web search to find the official homepage of Hacker News', 'objective': 'To locate the official Hacker News website for further extraction of data', 'tools': ['WebSearch'], 'outcome': 'The URL of the official Hacker News website'}, {'task_num': 2, 'task': 'Fetch the content from the URL obtained in task 1', 'objective': 'To retrieve the HTML content of the Hacker News homepage', 'tools': ['Fetch'], 'outcome': 'The HTML content of the Hacker News homepage'}, {'task_num': 3, 'task': 'Extract the top three stories from the HTML content obtained in task 2', 'objective': 'To identify and extract the necessary details of the top three stories', 'tools': ['RunPython'], 'outcome': 'A list of the top three stories with their relevant details'}, {'task_num': 4, 'task': 'Generate a concise summary of the top three stories obtained in task 3', 'objective': 'To create a summary of the top three stories including their titles, sources, number of upvotes, and comments', 'tools': ['TextCompletion'], 'outcome': 'A concise summary of the top three stories'}], 'reasoning_for_each_task': ['Task 1: A web search is necessary to find the official homepage of Hacker News.', 'Task 2: Fetching the content of the Hacker News homepage allows for further analysis and extraction of data.', 'Task 3: Extracting the top three stories from the HTML content enables the retrieval of their relevant details.', 'Task 4: Generating a concise summary of the top three stories provides a clear and organized overview of the information.'], 'task_dependency': {'2': [1], '3': [2], '4': [3]}, 'hints_from_user': []}
2023-07-04 04:53:29,027 - INFO - [translator.py:248] - user prompt:
The overall goal is: |To provide a concise summary of the top three stories currently displayed on the homepage of the official Hacker News website, including their titles, sources, and additional information such as the number of upvotes and comments for each story.|
We are working on one of the tasks which is: |Conduct a web search to find the official homepage of Hacker News|
The objective of this task is: |To locate the official Hacker News website for further extraction of data|
The starting sequence is |1|
Let's create a series of JVM instructions to complete the task and fulfill the stated objective. Ensure you fully utilize the outcomes of previous tasks and user hints. |
Remember: | Every instruction must save its outcome to the database so it can be used in subsequent tasks. |
Here are some hints from user: This is the first task, so there are no previous tasks or outcomes.

Please provide your response in YAML format:

2023-07-04 04:53:34,137 - INFO - [translator.py:256] - Response from AI: 
goal: Provide a concise summary of the top three stories on the Hacker News homepage, including their titles, sources, and additional information such as the number of upvotes and comments for each story
objective: Locate the official Hacker News website for further extraction of data
hints_from_user:
start_seq: 1
thoughts: We need to find the official homepage of Hacker News in order to extract the necessary information. We can use a web search to locate the website.
reasoning_on_apply_instruction_selection_rules: Rule No.2 and Rule No.5 have been applied. We will start with a web search, as it is a basic instruction that can help us locate the official website. If the web search does not yield the desired results, we can consider using advanced instructions.
instructions:
  - seq: 1
    type: WebSearch
    inside_loop: false
    objective: Find the official homepage of Hacker News
    args:
      query: "official website of Hacker News"
      save_to: "hacker_news_urls.seq1.list"

end_seq: 1
overall_outcome: The official homepage of Hacker News has been located. It can be retrieved by using the key "hacker_news_urls.seq1.list".
2023-07-04 04:53:34,153 - INFO - [translator.py:248] - user prompt:
The overall goal is: |To provide a concise summary of the top three stories currently displayed on the homepage of the official Hacker News website, including their titles, sources, and additional information such as the number of upvotes and comments for each story.|
We are working on one of the tasks which is: |Fetch the content from the URL obtained in task 1|
The objective of this task is: |To retrieve the HTML content of the Hacker News homepage|
The starting sequence is |2|
Let's create a series of JVM instructions to complete the task and fulfill the stated objective. Ensure you fully utilize the outcomes of previous tasks and user hints. | 
Remember: | Every instruction must save its outcome to the database so it can be used in subsequent tasks. |
Here are some hints from user: The previous done tasks: |{1: 'Conduct a web search to find the official homepage of Hacker News'}|.
Outcome list from previous tasks: |['The official homepage of Hacker News has been located. It can be retrieved by using the key "hacker_news_urls.seq1.list".']|.

Please provide your response in YAML format:

```yaml

2023-07-04 04:53:39,882 - INFO - [translator.py:256] - Response from AI: 
goal: Provide a concise summary of the top three stories on the homepage of Hacker News, including their titles, sources, and additional information such as the number of upvotes and comments for each story.
objective: Retrieve the HTML content of the Hacker News homepage
hints_from_user:
  previous_done_tasks:
    1: Conduct a web search to find the official homepage of Hacker News
start_seq: 2
thoughts: The objective of this task is to fetch the HTML content of the Hacker News homepage. We can use the URL obtained from the previous task to fetch the content. After fetching the content, we can extract the required information using appropriate string processing techniques.
reasoning_on_apply_instruction_selection_rules: We will first use the 'Fetch' instruction to fetch the content of the Hacker News homepage. This instruction satisfies the objective of retrieving the HTML content. Since the content is required for the next task, we will save it to the database using a dynamic key.
instructions:
  - seq: 2
    type: Fetch
    inside_loop: false
    objective: Fetch the content from the URL obtained in task 1
    args:
      url: jvm.get('hacker_news_urls.seq1.list')[0]
      save_to: content_fetched.seq2.str

end_seq: 2
overall_outcome: The HTML content of the Hacker News homepage has been fetched and stored in the database with the key 'content_fetched.seq2.str'. This content can be used in the subsequent tasks to extract the required information.
2023-07-04 04:53:39,895 - INFO - [translator.py:248] - user prompt:
The overall goal is: |To provide a concise summary of the top three stories currently displayed on the homepage of the official Hacker News website, including their titles, sources, and additional information such as the number of upvotes and comments for each story.|
We are working on one of the tasks which is: |Extract the top three stories from the HTML content obtained in task 2|
The objective of this task is: |To identify and extract the necessary details of the top three stories|
The starting sequence is |3|
Let's create a series of JVM instructions to complete the task and fulfill the stated objective. Ensure you fully utilize the outcomes of previous tasks and user hints. | 
Remember: | Every instruction must save its outcome to the database so it can be used in subsequent tasks. |
Here are some hints from user: The previous done tasks: |{2: 'Fetch the content from the URL obtained in task 1'}|.
Outcome list from previous tasks: |["The HTML content of the Hacker News homepage has been fetched and stored in the database with the key 'content_fetched.seq2.str'. This content can be used in the subsequent tasks to extract the required information."]|.

Please provide your response in YAML format:

```yaml

2023-07-04 04:53:58,077 - INFO - [translator.py:256] - Response from AI: 
goal: Extract the necessary details of the top three stories from the HTML content obtained in task 2
objective: To extract the titles, sources, number of upvotes, and number of comments for the top three stories
hints_from_user:
  - The HTML content obtained in task 2 is stored in the database with the key 'content_fetched.seq2.str'
start_seq: 3
thoughts: We will need to parse the HTML content to extract the required details. We can use Python's BeautifulSoup library to parse the HTML and retrieve the necessary information. We can then save the extracted details to the database using dynamic keys for further processing in subsequent tasks.
reasoning_on_apply_instruction_selection_rules:
  - Rule No.1: The task involves extracting details from multiple elements (top three stories), which indicates the need for a loop instruction.
  - Rule No.2: The objective can be achieved by using the Fetch instruction with the saved HTML content from task 2.
  - Rule No.3: TextCompletion may not be suitable for this task as it requires parsing and extracting specific elements from HTML.
  - Rule No.4: RunPython instruction can be used to execute Python code for parsing the HTML and extracting the necessary details. However, we will explore other instructions first.
  - Rule No.5: Advanced instructions like If and Loop may be needed to handle the iteration and extraction of details for multiple stories.

instructions:
  - seq: 3
    type: Fetch
    inside_loop: false
    objective: Fetch the HTML content obtained in task 2
    args:
      url: "jvm.eval(jvm.get('content_fetched.seq2.str'))"
      save_to: content_fetched.seq3.str

  - seq: 4
    type: RunPython
    inside_loop: false
    objective: Extract the necessary details from the HTML content
    args:
      code: |
        from bs4 import BeautifulSoup

        html_content = jvm.get('content_fetched.seq3.str')
        soup = BeautifulSoup(html_content, 'html.parser')

        stories = soup.select('.storylink')[:3]  # Get the top three stories

        titles = []
        sources = []
        upvotes = []
        comments = []

        for story in stories:
            titles.append(story.text)
            sources.append(story['href'])

        for story in stories:
            upvotes.append(int(story.find_next_sibling('td').text.split()[0]))
            comments.append(int(story.find_next_sibling('td').find_next_sibling('td').text.split()[0]))

        jvm.set('titles.seq4.list', titles)
        jvm.set('sources.seq4.list', sources)
        jvm.set('upvotes.seq4.list', upvotes)
        jvm.set('comments.seq4.list', comments)

      code_review: The code fetches the HTML content from the database, uses BeautifulSoup to parse the content, and then extracts the necessary details of the top three stories. The details are stored in separate lists and saved to the database using dynamic keys.
      pkg_dependencies: ['beautifulsoup4']

  - seq: 5
    type: TextCompletion
    inside_loop: false
    objective: Provide a summary of the extracted details
    args:
      command: "Provide a summary of the top three stories including their titles, sources, upvotes, and comments"
      output_fmt:
        kvs:
          - key: summary.seq5.str
            value: <to_fill>
      content: |
        titles = jvm.list_values_with_key_prefix('titles.seq4')
        sources = jvm.list_values_with_key_prefix('sources.seq4')
        upvotes = jvm.list_values_with_key_prefix('upvotes.seq4')
        comments = jvm.list_values_with_key_prefix('comments.seq4')

        summary = ''
        for i in range(3):
            summary += f"Story {i+1}:\n"
            summary += f"Title: {titles[i]}\n"
            summary += f"Source: {sources[i]}\n"
            summary += f"Upvotes: {upvotes[i]}\n"
            summary += f"Comments: {comments[i]}\n\n"

        jvm.set('summary.seq5.str', summary)

end_seq: 5
overall_outcome: The necessary details of the top three stories, including their titles, sources, upvotes, and comments, have been extracted and saved in the database. The summary of the details is stored with the key 'summary.seq5.str'. It can be retrieved using the key 'summary.seq5.str' for further processing or analysis.

2023-07-04 04:53:58,096 - INFO - [translator.py:248] - user prompt:
The overall goal is: |To provide a concise summary of the top three stories currently displayed on the homepage of the official Hacker News website, including their titles, sources, and additional information such as the number of upvotes and comments for each story.|
We are working on one of the tasks which is: |Generate a concise summary of the top three stories obtained in task 3|
The objective of this task is: |To create a summary of the top three stories including their titles, sources, number of upvotes, and comments|
The starting sequence is |6|
Let's create a series of JVM instructions to complete the task and fulfill the stated objective. Ensure you fully utilize the outcomes of previous tasks and user hints. | 
Remember: | Every instruction must save its outcome to the database so it can be used in subsequent tasks. |
Here are some hints from user: The previous done tasks: |{3: 'Extract the top three stories from the HTML content obtained in task 2'}|.
Outcome list from previous tasks: |["The necessary details of the top three stories, including their titles, sources, upvotes, and comments, have been extracted and saved in the database. The summary of the details is stored with the key 'summary.seq5.str'. It can be retrieved using the key 'summary.seq5.str' for further processing or analysis."]|.

Please provide your response in YAML format:

```yaml

2023-07-04 04:54:05,912 - INFO - [translator.py:256] - Response from AI: 
goal: Generate a concise summary of the top three stories obtained in task 3, including their titles, sources, number of upvotes, and comments, and save the summary to the database.
objective: Create a summary of the top three stories obtained in task 3, including their titles, sources, number of upvotes, and comments.
hints_from_user:
- Task 3: Extract the top three stories from the HTML content obtained in task 2.
start_seq: 6
thoughts: The objective can be achieved by using the outcomes of previous tasks and user hints. We need to retrieve the necessary details of the top three stories from the database and format them into a concise summary.
reasoning_on_apply_instruction_selection_rules:
  - Rule No.2: The objective can be achieved by using the outcomes of previous tasks, so we should use those outcomes.
instructions:
  - seq: 6
    type: TextCompletion
    inside_loop: false
    objective: Generate a concise summary of the top three stories
    args:
      command: Generate a concise summary of the top three stories obtained in task 3
      output_fmt:
        kvs:
          - key: summary.seq6.str
            value: <to_fill>
      content: "jvm.get('summary.seq5.str')"

end_seq: 6
overall_outcome: The summary of the top three stories obtained in task 3 has been generated and saved to the database with the key 'summary.seq6.str'. It can be retrieved using the key 'summary.seq6.str' for further processing or analysis.
@iamxy
Copy link
Collaborator

iamxy commented Jul 18, 2023

This issue has been addressed by adding a more detailed description of the Fetch instruction. According to the Rule 2 model, basic instructions should be preferred.

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

No branches or pull requests

2 participants