langchain-ai / rag-from-scratch

2.73k stars 814 forks source link

USER_AGENT environment variable not set, consider setting it to identify your requests. #24

Open NicoleRR opened 4 months ago

NicoleRR commented 4 months ago

when I run first step, it says I don't set USER_AGENT.I don't konw how to set it ,just use langchain1.0 or other ways.

HudsonArauj commented 4 months ago

I had the same problem. You are probably using AsyncHtml or another library that has html settings. I looked it up and maybe it's a request regarding the browser. In POST or GET requests, we have a header, and in this a user-agent with settings such as Chrome, Mozila and others. So I think this is a way to solve the problem, but I haven't solved it yet. if you are not using the asyncHtml library, just remove this import

pnkjsaini commented 4 months ago

i changed in langchain_community>utils>user_agent.py for workaround in if code block added else statement to get default value langchain_fix

jianmomo commented 4 months ago

我遇到了同样的问题,请问有解决办法吗?

yaoyun1 commented 4 months ago

import os os.environ['USER_AGENT'] = 'myagent'

jianmomo commented 4 months ago

导入操作系统 os.environ['USER_AGENT'] = 'myagent'

好的,非常感谢,这解决了我的问题

HudsonArauj commented 4 months ago

import os os.environ['USER_AGENT'] = 'myagent'

This solved my problem.

Mooo49 commented 4 months ago

import os os.environ['USER_AGENT'] = 'myagent'

it is not working with me in streamlit

annv-ltv commented 3 months ago

I don't know why, when i set USER_AGENT=MyCustomAgent/1.0 inside .env then not working but when I run export USER_AGENT="MyCustomAgent/1.0" on terminal it works

Razgaleh commented 2 months ago

import os os.environ['USER_AGENT'] = 'myagent'

it is not working with me in streamlit

Having same issue as Mooo49 - would appreciate any help!

dewflowersp commented 1 month ago

import os os.environ['USER_AGENT'] = 'myagent'

it is not working with me in streamlit

Having same issue as Mooo49 - would appreciate any help!

Try adding USER_AGENT=myagent in .env file. It worked for me.

ronbruce commented 1 month ago

I tried using the following code to set the environment variable:

import os 
os.environ['USER_AGENT'] = 'myagent'

However, it didn’t work for me. When I added USER_AGENT="myagent" to the .env file instead, it worked! Now, my code no longer throws the USER_AGENT error, but it still isn’t producing any output. I'm running this in a Jupyter Notebook, and the code seems to be stuck, running indefinitely without stopping.

ferrinheight commented 1 month ago

Hi @ronbruce. is your code using a local or remote agent? If you are sure the agent itself is working then it could be the jupyter notebook itself. I am using jupyter-notebook and encountered similar issues. Try shutting down all(or just the notebook in question) kernels from the left sidebar. I am using the os module to set USER_AGENT and it did not work until I restarted the kernel.

ronbruce commented 1 month ago

I am using a local agent. It worked!! Thank you so much, @ferrinheight.