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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

only with ollama "invalid escape sequences in the input string" when the data is having "_ " #610

Open
tsktech opened this issue May 13, 2024 · 1 comment

Comments

@tsktech
Copy link

tsktech commented May 13, 2024

# Ollama
        self.custom_llm = ChatOpenAI(
            model="mistral",
            #model="openhermes",
            base_url="http://localhost:11434/v1",
            api_key="ollama",  # something random
            temperature=0,
        )

main.py

def run():
    inURL = input("馃殌 Enter YouTube URL: ")
    video_id = extract_video_id(inURL)
    # video_id = extract_video_id(input("馃殌 Enter YouTube URL: "))
    if not video_id:
        print("馃毃 Invalid YouTube URL provided.")
        return

    inputs = {"video_id": video_id, "url": inURL}
    crew = YoutubeCommentsCrew()
    result = crew.crew().kickoff(inputs=inputs)
    print("Analysis Result:")
    print(result)'

when the url passed is https://www.youtube.com/watch?v=sNa_uiqSlJo therefore video_id is sNa_uiqSlJo

the resulting verbose 
Entering new CrewAgentExecutor chain...
 I need to retrieve all comments for the specified YouTube video ID "sNa\_uiqSlJo" using the YouTube Comments Fetcher tool.

Action: YouTube Comments Fetcher
Action Input: {"video\_id": "sNa\_uiqSlJo"}<unknown>:1: SyntaxWarning: invalid escape sequence '\_'
<unknown>:1: SyntaxWarning: invalid escape sequence '\_'

modified the main.py with video_id = str (video_id) but still does not work

def run():
    inURL = input("馃殌 Enter YouTube URL: ")
    video_id = extract_video_id(inURL)
    # video_id = extract_video_id(input("馃殌 Enter YouTube URL: "))
    if not video_id:
        print("馃毃 Invalid YouTube URL provided.")
        return

    # need to pass the video_id with _ without the escape ie sNa_uiqSlJo instead of sNa\_uiqSlJo
    # video_id = str (video_id)
    ## does not work

    inputs = {"video_id": video_id, "url": inURL}
    crew = YoutubeCommentsCrew()
    result = crew.crew().kickoff(inputs=inputs)
    print("Analysis Result:")
    print(result) #.encode("utf-8"))

fixes the issue of "sNa_uiqSlJo"

Entering new CrewAgentExecutor chain...
 I need to retrieve all comments for the specified YouTube video ID "sNa_uiqSlJo" using the YouTube Comments Fetcher tool.

Action: YouTube Comments Fetcher
Action Input: {"video_id": "sNa_uiqSlJo"} 

I am a newbie into AI, so dont know if this is bug or feature..

@noggynoggy
Copy link
Contributor

That's an old issue. (Dumb) LLMs seem to always think you have to escape underscores. Same if a tool is for example called "web_search". You can get around this by just writing python code that deletes all "" in the video_id. Then it doesn't matter if the model is dumb.

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