У меня есть urllib.error.httperror: http error 400: ошибка плохого запроса при использовании инструмента YoutubeVideoSearchTool в моей команде, построенном с Crewai для Python. Я следил за документацией, и это мой код для моего файла exat.py :
import re
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from crewai_tools import SerperDevTool, YoutubeVideoSearchTool
from .tools.docx_read_tool import DocxReadTool
# If you want to run a snippet of code before or after the crew starts,
# you can use the @before_kickoff and @after_kickoff decorators
# https://docs.crewai.com/concepts/crews#example-crew-class-with-decorators
@CrewBase
class YouTubeScript():
"""YouTubeScript crew"""
# Learn more about YAML configuration files here:
# Agents: https://docs.crewai.com/concepts/agents#yaml-configuration-recommended
# Tasks: https://docs.crewai.com/concepts/tasks#yaml-configuration-recommended
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
# If you would like to add tools to your agents, you can learn more about it here:
# https://docs.crewai.com/concepts/agents#agent-tools
@agent
def researcher(self) -> Agent:
return Agent(
config=self.agents_config['researcher'],
verbose=True,
tools=[SerperDevTool()]
)
@agent
def youtube_video_researcher(self) -> Agent:
youtube_search_tool = YoutubeVideoSearchTool(
youtube_video_url='https://youtube.com/watch?v=E4l91XKQSgw'
)
return Agent(
config=self.agents_config['youtube_video_researcher'],
verbose=True,
tools=[youtube_search_tool]
)
@agent
def screenwriter(self) -> Agent:
return Agent(
config=self.agents_config['screenwriter'],
verbose=True,
tools=[DocxReadTool(directory="/Users/danielerazo/Documents/yt-scripts")]
)
# To learn more about structured task outputs,
# task dependencies, and task callbacks, check out the documentation:
# https://docs.crewai.com/concepts/tasks#overview-of-a-task
@task
def research_task(self) -> Task:
return Task(
config=self.tasks_config['research_task'],
output_key="research_output"
)
@task
def youtube_research_task(self) -> Task:
def extract_youtube_link(context):
research_output = context["research_output"]
match = re.search(r"(https?://(?:www\.)?youtube\.com/\S+)", research_output)
if match:
return { "youtube_video_url": match.group(1) }
else:
raise ValueError("No YouTube URL found in research output!")
return Task(
config=self.tasks_config['youtube_research_task'],
)
@task
def screenwriting_task(self) -> Task:
return Task(
config=self.tasks_config['screenwriting_task'],
output_file='output/script.md'
)
@crew
def crew(self) -> Crew:
"""Creates the LatestTechAnalysis crew"""
# To learn how to add knowledge sources to your crew, check out the documentation:
# https://docs.crewai.com/concepts/knowledge#what-is-knowledge
return Crew(
agents=self.agents, # Automatically created by the @agent decorator
tasks=self.tasks, # Automatically created by the @task decorator
process=Process.sequential,
verbose=True,
# process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
)
Моя цель состоит в том, чтобы построить систему агента сценаризма на YouTube, в которой агент исследователя находит URL -адрес видео YT из своего исследования и передает URL -адрес для агента видео -исследователя на YouTube, я пытаюсь проверить youtubevideosearchtool в первую очередь со статическим URL, но здесь есть ошибка. /> return urlopen(request, timeout=timeout)
< /code>
Не уверен, почему дает ошибку 400, если URL кажется правильным, я не нашел аналогичную ошибку на другом сайте. Для контекста я использую Python 3.11.11 и последнюю версию Crewai.>
У меня есть urllib.error.httperror: http error 400: ошибка плохого запроса при использовании инструмента YoutubeVideoSearchTool в моей команде, построенном с Crewai для Python. Я следил за документацией, и это мой код для моего файла exat.py : [code]import re from crewai import Agent, Crew, Process, Task from crewai.project import CrewBase, agent, crew, task from crewai_tools import SerperDevTool, YoutubeVideoSearchTool
from .tools.docx_read_tool import DocxReadTool
# If you want to run a snippet of code before or after the crew starts, # you can use the @before_kickoff and @after_kickoff decorators # https://docs.crewai.com/concepts/crews#example-crew-class-with-decorators
@CrewBase class YouTubeScript(): """YouTubeScript crew"""
# Learn more about YAML configuration files here: # Agents: https://docs.crewai.com/concepts/agents#yaml-configuration-recommended # Tasks: https://docs.crewai.com/concepts/tasks#yaml-configuration-recommended agents_config = 'config/agents.yaml' tasks_config = 'config/tasks.yaml' # If you would like to add tools to your agents, you can learn more about it here: # https://docs.crewai.com/concepts/agents#agent-tools @agent def researcher(self) -> Agent: return Agent( config=self.agents_config['researcher'], verbose=True, tools=[SerperDevTool()] )
# To learn more about structured task outputs, # task dependencies, and task callbacks, check out the documentation: # https://docs.crewai.com/concepts/tasks#overview-of-a-task @task def research_task(self) -> Task: return Task( config=self.tasks_config['research_task'], output_key="research_output" )
@task def youtube_research_task(self) -> Task: def extract_youtube_link(context): research_output = context["research_output"] match = re.search(r"(https?://(?:www\.)?youtube\.com/\S+)", research_output) if match: return { "youtube_video_url": match.group(1) } else: raise ValueError("No YouTube URL found in research output!") return Task( config=self.tasks_config['youtube_research_task'], )
@crew def crew(self) -> Crew: """Creates the LatestTechAnalysis crew""" # To learn how to add knowledge sources to your crew, check out the documentation: # https://docs.crewai.com/concepts/knowledge#what-is-knowledge
return Crew( agents=self.agents, # Automatically created by the @agent decorator tasks=self.tasks, # Automatically created by the @task decorator process=Process.sequential, verbose=True, # process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/ ) [/code] Моя цель состоит в том, чтобы построить систему агента сценаризма на YouTube, в которой агент исследователя находит URL -адрес видео YT из своего исследования и передает URL -адрес для агента видео -исследователя на YouTube, я пытаюсь проверить youtubevideosearchtool в первую очередь со статическим URL, но здесь есть ошибка. /> return urlopen(request, timeout=timeout) < /code> Не уверен, почему дает ошибку 400, если URL кажется правильным, я не нашел аналогичную ошибку на другом сайте. Для контекста я использую Python 3.11.11 и последнюю версию Crewai.>
Я пытаюсь прочитать URL-адрес изображения из Интернета и получить возможность загрузить изображение на свой компьютер через Python. Я использовал пример, использованный в этом сообщении блога -an-image-from-the-url-in-pil/, который был однако, когда...
Я пытаюсь использовать pytube (v15.0.0), чтобы получить заголовки видео на YouTube. Тем не менее, для каждого видео, которое я пробую, мой скрипт не спускается с той же ошибкой: http error 400: плохой запрос .
Я уже обновил pytube к последней...
Я пытаюсь использовать pytube (v15.0.0), чтобы получить заголовки видео на YouTube. Тем не менее, для каждого видео, которое я пробую, мой скрипт не спускается с той же ошибкой: http error 400: плохой запрос .
Я уже обновил pytube к последней...
Я пытаюсь использовать pytube (v15.0.0), чтобы получить заголовки видео на YouTube. Тем не менее, для каждого видео, которое я пробую, мой скрипт не спускается с той же ошибкой: http error 400: плохой запрос .
Я уже обновил pytube к последней...
Я попытался создать загруженное видео с YouTube, и когда я его протестировал, появилось сообщение об ошибке: «urllib.error.HTTPError: Ошибка HTTP 400: неверный запрос». Вот полный код.
from pytube import YouTube