Skip to content

Automatically switch provider based on envirnment variables, Ollama support: closes #13 #50

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Le09
Copy link

@Le09 Le09 commented Apr 24, 2025

Fairly straightforward. In the spirit of the repo, I've kept things simple rather than also automatically add everything (like optional Anthropic libraries or others).

I think asking beginners to modify directly call_llm poses a risk of them putting their private keys on Github, so it's better to have them learn how to use environment variables to avoid taking chances.

@zachary62
Copy link
Contributor

Thank you! I'm a bit worried that env will add friction to semi-technical people, but will add notes about security issue

Copy link

@eliliam eliliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and clean, very extensible too if anyone wanted to add new providers down the line.

@redliu312
Copy link

hihi @Le09

do you think it is required to add

from dotenv import load_dotenv
load_dotenv()

in the top section of the call_llm.py

I tried your branch and it seems this is needed for load the .env file when the script executed

@Le09
Copy link
Author

Le09 commented Apr 30, 2025

@redliu312 Oh, I see.
Environment variables are variables that are set in you terminal. So a standard development workflow is to do

workon Tutorial-Codebase-Knowledge-venv  # activate your virtual environment with the correct set of python dependencies
source .env  # load the API keys
python file.py

If done this way, the variables are available in everything that you do in this terminal. So python main.py and python utils.call_llm.py would both get variables.
If you do the call from main, then main loads the variable first so call_llm should get them.
So, the issue is that calling utils/call_llm directly does not get them from main; since this is for testing purpose, the load_dotenv() should indeed be added to this file, but under the if __name__ == "__main__": line.

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

Successfully merging this pull request may close these issues.

5 participants