EZ-hwh / AutoScraper

Official implement of paper "AutoCrawler: A Progressive Understanding Web Agent for Web Crawler Generation"
Apache License 2.0
403 stars 34 forks source link

ms_api_copy.py file doesn't existing in the repo #3

Closed asciiwalker closed 1 month ago

asciiwalker commented 5 months ago

ModuleNotFoundError: No module named 'utils.ms_api_copy'

NozoMizore7 commented 5 months ago

same issue met

asciiwalker commented 5 months ago

hey @EZ-hwh , Can you help here? I saw this file is excluded in .gitignore but this file import is there at a few places which is causing errors in running the mentioned command in READMe file.

asciiwalker commented 4 months ago

hey @EZ-hwh , Can you help test the repository code? I have been able to set up the repo with requirements.txt installation successfully. Just need ms_api_copy.py file for running those command mentioned in README.md file

EZ-hwh commented 4 months ago

hey @EZ-hwh , Can you help test the repository code? I have been able to set up the repo with requirements.txt installation successfully. Just need ms_api_copy.py file for running those command mentioned in README.md file

ms_api_copy.py is just a file that just contains simple OpenAI API execution code. You can reimplement it refering to utils/api.py.

11PRiyansh commented 4 months ago

@asciiwalker Were you able to re-implement it?

JanusChoi commented 4 months ago

Should be just like:

import openai

# Replace 'your-api-key' with your actual OpenAI API key
OPENAI_API_KEY = 'your-api-key'

openai.api_key = OPENAI_API_KEY

def ms_chatgpt(query):
    query_session = [{"role":"user", "content": query}]
    resp = client.chat.completions.create(
        model='gpt-3.5-turbo',
        messages=query_session,
        temperature=0.1,
        max_tokens=512,
        top_p=1,
        frequency_penalty=0.0,
        presence_penalty=0.0,
    )
    ret = resp.choices[0].message.content
    return ret

def ms_gpt4(query):
    query_session = [{"role":"user", "content": query}]
    resp = client.chat.completions.create(
        model='gpt-4-1106-preview',
        messages=query_session,
        temperature=0.1,
        max_tokens=512,
        top_p=1,
        frequency_penalty=0.0,
        presence_penalty=0.0,
    )
    ret = resp.choices[0].message.content
    return ret

# Example usage
if __name__ == "__main__":
    print(ms_chatgpt("How do I calculate the 100th prime number in Python?"))