# Download the article's content with a timeout of 10 seconds
article.download()
# Check if the download was successful before parsing the article
if article.download_state == 2:
article.parse()
# Get the main text content of the article
article_text = article.text
return article_text
else:
print("Error: Unable to download article from URL:", url)
return None
except Exception as e:
print("An error occurred while processing the URL:", url)
print(str(e))
return None
def get_article_from_url(url):
try:
# Scrape the web page for content using newspaper
article = newspaper.Article(url)
# Download the article's content with a timeout of 10 seconds
article.download()
# Check if the download was successful before parsing the article
if article.download_state == 2:
article.parse()
# Get the main text content of the article
article_text = article.text
return article_text
else:
print("Error: Unable to download article from URL:", url)
return None
except Exception as e:
print("An error occurred while processing the URL:", url)
print(str(e))
return None
def get_article_from_url(url):
try:
# Scrape the web page for content using newspaper
article = newspaper.Article(url)
# Download the article's content with a timeout of 10 seconds
article.download()
# Check if the download was successful before parsing the article
if article.download_state == 2:
article.parse()
# Get the main text content of the article
article_text = article.text
return article_text
else:
print("Error: Unable to download article from URL:", url)
return None
except Exception as e:
print("An error occurred while processing the URL:", url)
print(str(e))
return None
# Getting assistant prompt from "prompts.py" file, edit on left panel if you want to change the prompt
instructions=assistant_instructions,
model="gpt-3.5-turbo-1106",
tools=[
{
"type": "retrieval"# This adds the knowledge base as a tool
},
],
file_ids=[file.id])
file = client.files.create(file=open("my_cover.pdf", "rb"),
purpose='assistants')
assistant = client.beta.assistants.create(
# Getting assistant prompt from "prompts.py" file, edit on left panel if you want to change the prompt
instructions=assistant_instructions,
model="gpt-3.5-turbo-1106",
tools=[
{
"type": "retrieval" # This adds the knowledge base as a tool
},
],
file_ids=[file.id])
file = client.files.create(file=open("my_cover.pdf", "rb"),
purpose='assistants')
assistant = client.beta.assistants.create(
# Getting assistant prompt from "prompts.py" file, edit on left panel if you want to change the prompt
instructions=assistant_instructions,
model="gpt-3.5-turbo-1106",
tools=[
{
"type": "retrieval" # This adds the knowledge base as a tool
},
],
file_ids=[file.id])
利用gpt的 “retrieval”, 向量数据库存储和索引搜索内容。
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
client.beta.threads.messages.create(
thread_id=thread_id,
role="user",
content=user_input
)
# Start the Assistant Run
run = client.beta.threads.runs.create(
thread_id=thread_id,
assistant_id=assistant_id
)
client.beta.threads.messages.create(
thread_id=thread_id,
role="user",
content=user_input
)
# Start the Assistant Run
run = client.beta.threads.runs.create(
thread_id=thread_id,
assistant_id=assistant_id
)
client.beta.threads.messages.create(
thread_id=thread_id,
role="user",
content=user_input
)
# Start the Assistant Run
run = client.beta.threads.runs.create(
thread_id=thread_id,
assistant_id=assistant_id
)
利用gpt的 assistant api 可以作为“慢思考”,深度思考和自动分析,获得更好的分析结果。