Skip to content

feat(examples/llm): flesh out OpenAI support in llm_load - #68

Open
0xDEC0DE wants to merge 2 commits into
geekscape:masterfrom
0xDEC0DE:issue/67
Open

0xDEC0DE wants to merge 2 commits into
geekscape:masterfrom
0xDEC0DE:issue/67

Conversation

@0xDEC0DE

Copy link
Copy Markdown
  • Pull langchain values from well-known environment variables for Ollama and OpenAI configuration instead of hardcoded/default values

  • Accept multiple LLM types, trying each one in turn as a simple fallback

Fixes: Issue #67

@0xDEC0DE
0xDEC0DE force-pushed the issue/67 branch 2 times, most recently from 0c089c7 to 4f575eb Compare August 14, 2026 01:51
Comment on lines +100 to +120
if llm_type == "openai":
from openai import OpenAIError
from langchain_openai import ChatOpenAI
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
OPENAI_BASE_URL = os.environ.get("OPENAI_BASE_URL")
return ChatOpenAI(
model=model_name,
temperature=LLM_TEMPERATURE,
base_url=OPENAI_BASE_URL,
api_key=OPENAI_API_KEY,
)
elif llm_type == "ollama":
from langchain_ollama import OllamaLLM
OLLAMA_HOST = os.environ.get("OLLAMA_HOST")
return OllamaLLM(
model=model_name,
temperature=LLM_TEMPERATURE,
base_url=OLLAMA_HOST,
)
else:
raise ImportError("Unknown model")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'd prefer this as a match/case block, but you support Python 3.9, which doesn't have them. Bummer.

Adds a `Dockerfile` and a `docker-compose.yaml` to allow for easier
spin-up and development of a sandboxed environment

Runs an MQTT bus, the registrar, and an example pipeline running
inside a Flask app.

Uses `uv` in lieu of `pip` for installing Python packages because
`uv`s installer is (much) faster and has a (much) better solver

fix: update dependency versions

Move away from Hatch's "most-compatible version" notation to using
plain minimum-version notation with explicit upper-bounds where
needed to mitigate breaking changes
- Pull langchain values from well-known environment variables for
  Ollama and OpenAI configuration instead of hardcoded/default values

- Accept multiple LLM types, trying each one in turn as a simple fallback

Fixes: Issue geekscape#67
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.

1 participant